This commit is contained in:
@@ -564,7 +564,7 @@ namespace AyaNovaQBI
|
|||||||
|
|
||||||
//PFC - get global setttings for use inventory and others await window.$gz.api.get("global-biz-setting/client");
|
//PFC - get global setttings for use inventory and others await window.$gz.api.get("global-biz-setting/client");
|
||||||
r = await GetAsync("global-biz-setting/client");
|
r = await GetAsync("global-biz-setting/client");
|
||||||
USE_INVENTORY=r.ObjectResponse["data"]["UseInventory"].Value<bool>();
|
USE_INVENTORY = r.ObjectResponse["data"]["UseInventory"].Value<bool>();
|
||||||
//return object for future reference
|
//return object for future reference
|
||||||
//var ret = new
|
//var ret = new
|
||||||
//{
|
//{
|
||||||
@@ -3539,7 +3539,7 @@ namespace AyaNovaQBI
|
|||||||
var r = await GetAsync($"customer/{id}");
|
var r = await GetAsync($"customer/{id}");
|
||||||
var c = r.ObjectResponse["data"].ToObject<Customer>();
|
var c = r.ObjectResponse["data"].ToObject<Customer>();
|
||||||
RefreshAyaNovaClientFromQB(c);
|
RefreshAyaNovaClientFromQB(c);
|
||||||
r=await PutAsync($"customer", Newtonsoft.Json.JsonConvert.SerializeObject(c));
|
r = await PutAsync($"customer", Newtonsoft.Json.JsonConvert.SerializeObject(c));
|
||||||
}
|
}
|
||||||
catch { };
|
catch { };
|
||||||
}
|
}
|
||||||
@@ -3558,8 +3558,7 @@ namespace AyaNovaQBI
|
|||||||
CopyQBCustomerInfoToAyaNovaClient(dr, c);
|
CopyQBCustomerInfoToAyaNovaClient(dr, c);
|
||||||
|
|
||||||
string sName = dr["FullName"].ToString();
|
string sName = dr["FullName"].ToString();
|
||||||
if (sName.Length > 255)
|
|
||||||
sName = sName.Substring(0, 255);
|
|
||||||
|
|
||||||
c.Name = sName;
|
c.Name = sName;
|
||||||
|
|
||||||
@@ -3610,13 +3609,13 @@ namespace AyaNovaQBI
|
|||||||
CopyQBCustomerInfoToAyaNovaClient(dr, c);
|
CopyQBCustomerInfoToAyaNovaClient(dr, c);
|
||||||
|
|
||||||
//Try to save and return errors if not in alerrors
|
//Try to save and return errors if not in alerrors
|
||||||
r=await PostAsync($"customer", Newtonsoft.Json.JsonConvert.SerializeObject(c));
|
r = await PostAsync($"customer", Newtonsoft.Json.JsonConvert.SerializeObject(c));
|
||||||
long newCustomerId=IdFromResponse(r);
|
long newCustomerId = IdFromResponse(r);
|
||||||
|
|
||||||
//Link
|
//Link
|
||||||
var m = new IntegrationItem { AType = AyaType.Customer, IntegrationItemName = sName, IntegrationItemId = QuickBooksID, LastSync = DateTime.Now, ObjectId = newCustomerId };
|
var m = new IntegrationItem { AType = AyaType.Customer, IntegrationItemName = sName, IntegrationItemId = QuickBooksID, LastSync = DateTime.Now, ObjectId = newCustomerId };
|
||||||
QBIntegration.Items.Add(m);
|
QBIntegration.Items.Add(m);
|
||||||
await util.SaveIntegrationObject();
|
await SaveIntegrationObject();
|
||||||
//IntegrationMap m = QBI.Maps.Add(QBI);
|
//IntegrationMap m = QBI.Maps.Add(QBI);
|
||||||
//m.Name = sName;
|
//m.Name = sName;
|
||||||
//m.RootObjectID = c.ID;
|
//m.RootObjectID = c.ID;
|
||||||
@@ -3754,11 +3753,10 @@ namespace AyaNovaQBI
|
|||||||
c.PostCode = a.Postal;
|
c.PostCode = a.Postal;
|
||||||
|
|
||||||
a = (Address)dr["StreetAddress"];
|
a = (Address)dr["StreetAddress"];
|
||||||
c.GoToAddress.DeliveryAddress = a.DeliveryAddress;
|
c.Address = a.DeliveryAddress;
|
||||||
c.GoToAddress.City = a.City;
|
c.City = a.City;
|
||||||
c.GoToAddress.StateProv = a.StateProv;
|
c.Region = a.StateProv;
|
||||||
c.GoToAddress.Country = a.Country;
|
c.Country = a.Country;
|
||||||
c.GoToAddress.Postal = a.Postal;
|
|
||||||
|
|
||||||
|
|
||||||
//Contact cn=c.Contacts.Add(RootObjectTypes.Vendor,c.ID);
|
//Contact cn=c.Contacts.Add(RootObjectTypes.Vendor,c.ID);
|
||||||
@@ -3819,7 +3817,7 @@ namespace AyaNovaQBI
|
|||||||
//Email field
|
//Email field
|
||||||
if (dr["Email"].ToString() != "")
|
if (dr["Email"].ToString() != "")
|
||||||
{
|
{
|
||||||
c.Email = dr["Email"].ToString();
|
c.EmailAddress = dr["Email"].ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Account number
|
//Account number
|
||||||
@@ -3828,23 +3826,32 @@ namespace AyaNovaQBI
|
|||||||
c.AccountNumber = dr["Account"].ToString();
|
c.AccountNumber = dr["Account"].ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!c.IsSavable)
|
//Try to save and return errors if not in alerrors
|
||||||
{
|
var r = await PostAsync($"vendor", Newtonsoft.Json.JsonConvert.SerializeObject(c));
|
||||||
alErrors.Add("ImportQBVendor: AyaNova won't allow import of " + c.Name + "\r\n" +
|
long newId = IdFromResponse(r);
|
||||||
"Due to the following broken rules:\r\n" + c.GetBrokenRulesString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
c = (Vendor)c.Save();
|
|
||||||
//Link
|
//Link
|
||||||
IntegrationMap m = QBI.Maps.Add(QBI);
|
var m = new IntegrationItem { AType = AyaType.Vendor, IntegrationItemName = sName, IntegrationItemId = QuickBooksID, LastSync = DateTime.Now, ObjectId = newId };
|
||||||
m.Name = sName;
|
QBIntegration.Items.Add(m);
|
||||||
m.RootObjectID = c.ID;
|
await util.SaveIntegrationObject();
|
||||||
m.RootObjectType = RootObjectTypes.Vendor;
|
|
||||||
m.LastSync = DateTime.Now;
|
//if (!c.IsSavable)
|
||||||
m.ForeignID = QuickBooksID;
|
//{
|
||||||
QBI = (Integration)QBI.Save();
|
// alErrors.Add("ImportQBVendor: AyaNova won't allow import of " + c.Name + "\r\n" +
|
||||||
|
// "Due to the following broken rules:\r\n" + c.GetBrokenRulesString());
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
//c = (Vendor)c.Save();
|
||||||
|
////Link
|
||||||
|
//IntegrationMap m = QBI.Maps.Add(QBI);
|
||||||
|
//m.Name = sName;
|
||||||
|
//m.RootObjectID = c.ID;
|
||||||
|
//m.RootObjectType = RootObjectTypes.Vendor;
|
||||||
|
//m.LastSync = DateTime.Now;
|
||||||
|
//m.ForeignID = QuickBooksID;
|
||||||
|
//QBI = (Integration)QBI.Save();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -3876,59 +3883,69 @@ namespace AyaNovaQBI
|
|||||||
}
|
}
|
||||||
|
|
||||||
string sName = dr["FullName"].ToString();
|
string sName = dr["FullName"].ToString();
|
||||||
if (sName.Length > 255)
|
//if (sName.Length > 255)
|
||||||
{
|
//{
|
||||||
alErrors.Add("ImportQBRate: QuickBooks Rate name exceeds 255 character limit for AyaNova\r\n" +
|
// alErrors.Add("ImportQBRate: QuickBooks Rate name exceeds 255 character limit for AyaNova\r\n" +
|
||||||
"Name: " + dr["FullName"].ToString() + "\r\n" +
|
// "Name: " + dr["FullName"].ToString() + "\r\n" +
|
||||||
"was imported as: " + sName);
|
// "was imported as: " + sName);
|
||||||
sName = sName.Substring(0, 255);
|
// sName = sName.Substring(0, 255);
|
||||||
}
|
//}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//already a Rate by that name
|
//already a Rate by that name
|
||||||
if (Rate.Exists(Guid.Empty, dr["FullName"].ToString()))
|
//if (Rate.Exists(Guid.Empty, dr["FullName"].ToString()))
|
||||||
|
if (QBIntegration.Items.Any(z => z.AType == AyaType.ServiceRate && z.IntegrationItemName == dr["FullName"].ToString()))
|
||||||
{
|
{
|
||||||
alErrors.Add("ImportQBRate: " + dr["FullName"].ToString() + " already exists in AyaNova");
|
alErrors.Add("ImportQBServiceRate: " + dr["FullName"].ToString() + " already exists in AyaNova");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Import seems safe...
|
//Import seems safe...
|
||||||
Rates rates = Rates.GetItems(false);
|
//Rates rates = Rates.GetItems(false);
|
||||||
Rate c = rates.Add();
|
//Rate c = rates.Add();
|
||||||
c.RateType = AsRateType;
|
//c.RateType = AsRateType;
|
||||||
|
ServiceRate c = new ServiceRate();
|
||||||
|
|
||||||
c.Name = sName;
|
c.Name = sName;
|
||||||
c.Charge = (decimal)dr["Price"];
|
c.Charge = (decimal)dr["Price"];
|
||||||
c.ContractRate = false;
|
//c.ContractRate = false;
|
||||||
c.Cost = (decimal)dr["Cost"];
|
c.Cost = (decimal)dr["Cost"];
|
||||||
c.Description = T(255, dr["SalesDesc"].ToString());
|
c.Notes = T(255, dr["SalesDesc"].ToString());
|
||||||
// c.RateUnitChargeDescriptionID = MostLikelyRateUnitChargeDescriptionID;
|
// c.RateUnitChargeDescriptionID = MostLikelyRateUnitChargeDescriptionID;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!c.IsSavable)
|
//if (!c.IsSavable)
|
||||||
{
|
//{
|
||||||
alErrors.Add("ImportQBRate: AyaNova won't allow import of " + c.Name + "\r\n" +
|
// alErrors.Add("ImportQBRate: AyaNova won't allow import of " + c.Name + "\r\n" +
|
||||||
"Due to the following broken rules:\r\n" + c.GetBrokenRulesString());
|
// "Due to the following broken rules:\r\n" + c.GetBrokenRulesString());
|
||||||
return;
|
// return;
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
rates = (Rates)rates.Save();
|
//rates = (Rates)rates.Save();
|
||||||
|
////Link
|
||||||
|
//IntegrationMap m = QBI.Maps.Add(QBI);
|
||||||
|
//m.Name = sName;
|
||||||
|
//m.RootObjectID = c.ID;
|
||||||
|
//m.RootObjectType = RootObjectTypes.Rate;
|
||||||
|
//m.LastSync = DateTime.Now;
|
||||||
|
//m.ForeignID = QuickBooksID;
|
||||||
|
//QBI = (Integration)QBI.Save();
|
||||||
|
var r = await PostAsync($"service-rate", Newtonsoft.Json.JsonConvert.SerializeObject(c));
|
||||||
|
long newId = IdFromResponse(r);
|
||||||
|
|
||||||
//Link
|
//Link
|
||||||
IntegrationMap m = QBI.Maps.Add(QBI);
|
var m = new IntegrationItem { AType = AyaType.ServiceRate, IntegrationItemName = sName, IntegrationItemId = QuickBooksID, LastSync = DateTime.Now, ObjectId = newId };
|
||||||
m.Name = sName;
|
QBIntegration.Items.Add(m);
|
||||||
m.RootObjectID = c.ID;
|
await util.SaveIntegrationObject();
|
||||||
m.RootObjectType = RootObjectTypes.Rate;
|
|
||||||
m.LastSync = DateTime.Now;
|
|
||||||
m.ForeignID = QuickBooksID;
|
|
||||||
QBI = (Integration)QBI.Save();
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
//crack the exception in case it's a generic dataportal one
|
//crack the exception in case it's a generic dataportal one
|
||||||
//and it is if it's got an inner exception of any kind
|
//and it is if it's got an inner exception of any kind
|
||||||
if (ex.InnerException != null) ex = ex.InnerException;
|
if (ex.InnerException != null) ex = ex.InnerException;
|
||||||
alErrors.Add("ImportQBRate: AyaNova won't allow import / link of " + sName + "\r\n" +
|
alErrors.Add("ImportQBServiceRate: AyaNova won't allow import / link of " + sName + "\r\n" +
|
||||||
"Due to the following error:\r\n" + ex.Message);
|
"Due to the following error:\r\n" + ex.Message);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3953,59 +3970,69 @@ namespace AyaNovaQBI
|
|||||||
}
|
}
|
||||||
|
|
||||||
string sName = dr["FullName"].ToString();
|
string sName = dr["FullName"].ToString();
|
||||||
if (sName.Length > 255)
|
//if (sName.Length > 255)
|
||||||
{
|
//{
|
||||||
alErrors.Add("ImportQBRate: QuickBooks Rate name exceeds 255 character limit for AyaNova\r\n" +
|
// alErrors.Add("ImportQBRate: QuickBooks Rate name exceeds 255 character limit for AyaNova\r\n" +
|
||||||
"Name: " + dr["FullName"].ToString() + "\r\n" +
|
// "Name: " + dr["FullName"].ToString() + "\r\n" +
|
||||||
"was imported as: " + sName);
|
// "was imported as: " + sName);
|
||||||
sName = sName.Substring(0, 255);
|
// sName = sName.Substring(0, 255);
|
||||||
}
|
//}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//already a Rate by that name
|
//already a Rate by that name
|
||||||
if (Rate.Exists(Guid.Empty, dr["FullName"].ToString()))
|
//if (Rate.Exists(Guid.Empty, dr["FullName"].ToString()))
|
||||||
|
if (QBIntegration.Items.Any(z => z.AType == AyaType.TravelRate && z.IntegrationItemName == dr["FullName"].ToString()))
|
||||||
{
|
{
|
||||||
alErrors.Add("ImportQBRate: " + dr["FullName"].ToString() + " already exists in AyaNova");
|
alErrors.Add("ImportQBTravelRate: " + dr["FullName"].ToString() + " already exists in AyaNova");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Import seems safe...
|
//Import seems safe...
|
||||||
Rates rates = Rates.GetItems(false);
|
//Rates rates = Rates.GetItems(false);
|
||||||
Rate c = rates.Add();
|
//Rate c = rates.Add();
|
||||||
c.RateType = AsRateType;
|
//c.RateType = AsRateType;
|
||||||
|
TravelRate c = new TravelRate();
|
||||||
c.Name = sName;
|
c.Name = sName;
|
||||||
c.Charge = (decimal)dr["Price"];
|
c.Charge = (decimal)dr["Price"];
|
||||||
c.ContractRate = false;
|
//c.ContractRate = false;
|
||||||
c.Cost = (decimal)dr["Cost"];
|
c.Cost = (decimal)dr["Cost"];
|
||||||
c.Description = T(255, dr["SalesDesc"].ToString());
|
c.Notes = T(255, dr["SalesDesc"].ToString());
|
||||||
// c.RateUnitChargeDescriptionID = MostLikelyRateUnitChargeDescriptionID;
|
// c.RateUnitChargeDescriptionID = MostLikelyRateUnitChargeDescriptionID;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!c.IsSavable)
|
//if (!c.IsSavable)
|
||||||
{
|
//{
|
||||||
alErrors.Add("ImportQBRate: AyaNova won't allow import of " + c.Name + "\r\n" +
|
// alErrors.Add("ImportQBRate: AyaNova won't allow import of " + c.Name + "\r\n" +
|
||||||
"Due to the following broken rules:\r\n" + c.GetBrokenRulesString());
|
// "Due to the following broken rules:\r\n" + c.GetBrokenRulesString());
|
||||||
return;
|
// return;
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
rates = (Rates)rates.Save();
|
//rates = (Rates)rates.Save();
|
||||||
|
////Link
|
||||||
|
//IntegrationMap m = QBI.Maps.Add(QBI);
|
||||||
|
//m.Name = sName;
|
||||||
|
//m.RootObjectID = c.ID;
|
||||||
|
//m.RootObjectType = RootObjectTypes.Rate;
|
||||||
|
//m.LastSync = DateTime.Now;
|
||||||
|
//m.ForeignID = QuickBooksID;
|
||||||
|
//QBI = (Integration)QBI.Save();
|
||||||
|
|
||||||
|
var r = await PostAsync($"travel-rate", Newtonsoft.Json.JsonConvert.SerializeObject(c));
|
||||||
|
long newId = IdFromResponse(r);
|
||||||
|
|
||||||
//Link
|
//Link
|
||||||
IntegrationMap m = QBI.Maps.Add(QBI);
|
var m = new IntegrationItem { AType = AyaType.TravelRate, IntegrationItemName = sName, IntegrationItemId = QuickBooksID, LastSync = DateTime.Now, ObjectId = newId };
|
||||||
m.Name = sName;
|
QBIntegration.Items.Add(m);
|
||||||
m.RootObjectID = c.ID;
|
await util.SaveIntegrationObject();
|
||||||
m.RootObjectType = RootObjectTypes.Rate;
|
|
||||||
m.LastSync = DateTime.Now;
|
|
||||||
m.ForeignID = QuickBooksID;
|
|
||||||
QBI = (Integration)QBI.Save();
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
//crack the exception in case it's a generic dataportal one
|
//crack the exception in case it's a generic dataportal one
|
||||||
//and it is if it's got an inner exception of any kind
|
//and it is if it's got an inner exception of any kind
|
||||||
if (ex.InnerException != null) ex = ex.InnerException;
|
if (ex.InnerException != null) ex = ex.InnerException;
|
||||||
alErrors.Add("ImportQBRate: AyaNova won't allow import / link of " + sName + "\r\n" +
|
alErrors.Add("ImportQBTravelRate: AyaNova won't allow import / link of " + sName + "\r\n" +
|
||||||
"Due to the following error:\r\n" + ex.Message);
|
"Due to the following error:\r\n" + ex.Message);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4014,39 +4041,38 @@ namespace AyaNovaQBI
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void RefreshAyaNovaPartFromQB(List<Guid> objectIDList)
|
public static async Task RefreshAyaNovaPartFromQB(List<long> objectIDList)
|
||||||
{
|
{
|
||||||
PopulateQBItemCache();
|
await PopulateQBItemCache();
|
||||||
foreach (Guid g in objectIDList)
|
foreach (long id in objectIDList)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Part c = Part.GetItem(g);
|
var r = await GetAsync($"part/{id}");
|
||||||
RefreshAyaNovaPartFromQB(c);
|
var c = r.ObjectResponse["data"].ToObject<Part>();
|
||||||
if (c.IsSavable)
|
await RefreshAyaNovaPartFromQB(c);
|
||||||
c.Save();
|
r = await PutAsync($"part", Newtonsoft.Json.JsonConvert.SerializeObject(c));
|
||||||
}
|
}
|
||||||
catch { };
|
catch { };
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RefreshAyaNovaPartFromQB(Part c)
|
public static async Task RefreshAyaNovaPartFromQB(Part c)
|
||||||
{
|
{
|
||||||
PopulateQBItemCache();
|
await PopulateQBItemCache();
|
||||||
IntegrationMap im = QBI.Maps[c.ID];
|
IntegrationItem im = util.QBIntegration.Items.FirstOrDefault(z => z.ObjectId == c.Id && z.AType == AyaType.Part);
|
||||||
if (im == null) return;//this part is not linked
|
if (im == null) return;//this part is not linked
|
||||||
|
|
||||||
DataRow dr = _dtQBItems.Rows.Find(im.ForeignID);
|
DataRow dr = _dtQBItems.Rows.Find(im.IntegrationItemId);
|
||||||
if (dr == null) return; //QBListID not found in part list?
|
if (dr == null) return; //QBListID not found in part list?
|
||||||
|
|
||||||
string sName = dr["FullName"].ToString();
|
string sName = dr["FullName"].ToString();
|
||||||
if (sName.Length > 255)
|
|
||||||
sName = sName.Substring(0, 255);
|
|
||||||
c.PartNumber = sName;
|
|
||||||
|
|
||||||
c.Name = T(255, dr["SalesDesc"].ToString());
|
c.Name = sName;
|
||||||
c.WholesalerID = AyaVendorForQBItem(im.ForeignID);
|
|
||||||
|
c.Description = T(255, dr["SalesDesc"].ToString());
|
||||||
|
c.WholeSalerId = AyaVendorForQBItem(im.ForeignID);
|
||||||
c.Retail = (decimal)dr["Price"];
|
c.Retail = (decimal)dr["Price"];
|
||||||
c.Cost = (decimal)dr["Cost"];
|
c.Cost = (decimal)dr["Cost"];
|
||||||
|
|
||||||
@@ -4074,52 +4100,61 @@ namespace AyaNovaQBI
|
|||||||
}
|
}
|
||||||
|
|
||||||
string sName = dr["FullName"].ToString();
|
string sName = dr["FullName"].ToString();
|
||||||
if (sName.Length > 255)
|
//if (sName.Length > 255)
|
||||||
{
|
//{
|
||||||
alErrors.Add("ImportQBPart: QuickBooks Part name exceeds 255 character limit for AyaNova part number\r\n" +
|
// alErrors.Add("ImportQBPart: QuickBooks Part name exceeds 255 character limit for AyaNova part number\r\n" +
|
||||||
"Name: " + dr["FullName"].ToString() + "\r\n" +
|
// "Name: " + dr["FullName"].ToString() + "\r\n" +
|
||||||
"was imported as: " + sName);
|
// "was imported as: " + sName);
|
||||||
sName = sName.Substring(0, 255);
|
// sName = sName.Substring(0, 255);
|
||||||
}
|
//}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//already a Part by that number?
|
//already a Part by that number?
|
||||||
if (Part.Exists(Guid.Empty, dr["FullName"].ToString()))
|
if (QBIntegration.Items.Any(z => z.AType == AyaType.Part && z.IntegrationItemName == dr["FullName"].ToString()))
|
||||||
{
|
{
|
||||||
alErrors.Add("ImportQBPart: Part number " + dr["FullName"].ToString() + " already exists in AyaNova");
|
alErrors.Add("ImportQBPart: Part name " + dr["FullName"].ToString() + " already exists in AyaNova");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Import seems safe...
|
//Import seems safe...
|
||||||
Part c = Part.NewItem();
|
Part c = new Part();
|
||||||
|
|
||||||
|
|
||||||
c.PartNumber = sName;
|
c.Name = sName;
|
||||||
c.Name = T(255, dr["SalesDesc"].ToString());
|
c.Description = T(255, dr["SalesDesc"].ToString());
|
||||||
c.WholesalerID = AyaVendorForQBItem(QuickBooksID);
|
c.WholeSalerId = AyaVendorForQBItem(QuickBooksID);
|
||||||
c.Retail = (decimal)dr["Price"];
|
c.Retail = (decimal)dr["Price"];
|
||||||
c.Cost = (decimal)dr["Cost"];
|
c.Cost = (decimal)dr["Cost"];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!c.IsSavable)
|
//if (!c.IsSavable)
|
||||||
{
|
//{
|
||||||
alErrors.Add("ImportQBPart: AyaNova won't allow import of " + c.Name + "\r\n" +
|
// alErrors.Add("ImportQBPart: AyaNova won't allow import of " + c.Name + "\r\n" +
|
||||||
"Due to the following broken rules:\r\n" + c.GetBrokenRulesString());
|
// "Due to the following broken rules:\r\n" + c.GetBrokenRulesString());
|
||||||
return;
|
// return;
|
||||||
}
|
//}
|
||||||
|
|
||||||
//Save and get ready to provide the ID
|
////Save and get ready to provide the ID
|
||||||
c = (Part)c.Save();
|
//c = (Part)c.Save();
|
||||||
|
|
||||||
|
////Link
|
||||||
|
//IntegrationMap m = QBI.Maps.Add(QBI);
|
||||||
|
//m.Name = sName;
|
||||||
|
//m.RootObjectID = c.ID;
|
||||||
|
//m.RootObjectType = RootObjectTypes.Part;
|
||||||
|
//m.LastSync = DateTime.Now;
|
||||||
|
//m.ForeignID = QuickBooksID;
|
||||||
|
//QBI = (Integration)QBI.Save();
|
||||||
|
|
||||||
|
//Try to save and return errors if not in alerrors
|
||||||
|
var r = await PostAsync($"part", Newtonsoft.Json.JsonConvert.SerializeObject(c));
|
||||||
|
long newId = IdFromResponse(r);
|
||||||
|
|
||||||
//Link
|
//Link
|
||||||
IntegrationMap m = QBI.Maps.Add(QBI);
|
var m = new IntegrationItem { AType = AyaType.Customer, IntegrationItemName = sName, IntegrationItemId = QuickBooksID, LastSync = DateTime.Now, ObjectId = newId };
|
||||||
m.Name = sName;
|
QBIntegration.Items.Add(m);
|
||||||
m.RootObjectID = c.ID;
|
await SaveIntegrationObject();
|
||||||
m.RootObjectType = RootObjectTypes.Part;
|
|
||||||
m.LastSync = DateTime.Now;
|
|
||||||
m.ForeignID = QuickBooksID;
|
|
||||||
QBI = (Integration)QBI.Save();
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -5224,9 +5259,9 @@ namespace AyaNovaQBI
|
|||||||
if (USE_INVENTORY)
|
if (USE_INVENTORY)
|
||||||
{
|
{
|
||||||
var rstocklevel = await GetAsync($"part/stock-levels/{c.Id}");
|
var rstocklevel = await GetAsync($"part/stock-levels/{c.Id}");
|
||||||
var partstocklevel= rstocklevel.ObjectResponse["data"].ToObject<PartStockLevel>();
|
var partstocklevel = rstocklevel.ObjectResponse["data"].ToObject<PartStockLevel>();
|
||||||
var rinventorylevel = await GetAsync($"part/latest-inventory/{c.Id}");
|
var rinventorylevel = await GetAsync($"part/latest-inventory/{c.Id}");
|
||||||
var partinventories = rstocklevel.ObjectResponse["data"].ToObject< List<PartInventory>>();
|
var partinventories = rstocklevel.ObjectResponse["data"].ToObject<List<PartInventory>>();
|
||||||
|
|
||||||
ca.QuantityOnHand.SetValue((double)partinventories.Sum(z => z.Balance));
|
ca.QuantityOnHand.SetValue((double)partinventories.Sum(z => z.Balance));
|
||||||
ca.ReorderPoint.SetValue((double)partstocklevel.MinimumQuantity);
|
ca.ReorderPoint.SetValue((double)partstocklevel.MinimumQuantity);
|
||||||
|
|||||||
Reference in New Issue
Block a user