This commit is contained in:
@@ -3539,10 +3539,7 @@ namespace AyaNovaQBI
|
||||
var r = await GetAsync($"customer/{id}");
|
||||
var c = r.ObjectResponse["data"].ToObject<Customer>();
|
||||
RefreshAyaNovaClientFromQB(c);
|
||||
r=await PostAsync($"customer/{id}", Newtonsoft.Json.JsonConvert.SerializeObject(c));
|
||||
|
||||
//if (c.IsSavable)
|
||||
// c.Save();
|
||||
r=await PutAsync($"customer", Newtonsoft.Json.JsonConvert.SerializeObject(c));
|
||||
}
|
||||
catch { };
|
||||
}
|
||||
@@ -3589,17 +3586,18 @@ namespace AyaNovaQBI
|
||||
}
|
||||
|
||||
string sName = dr["FullName"].ToString();
|
||||
if (sName.Length > 255)
|
||||
{
|
||||
alErrors.Add("ImportQBCustomer: QuickBooks customer name exceeds 255 character limit for AyaNova\r\n" +
|
||||
"Name: " + dr["FullName"].ToString() + "\r\n" +
|
||||
"was imported as: " + sName);
|
||||
sName = sName.Substring(0, 255);
|
||||
}
|
||||
//if (sName.Length > 255)
|
||||
//{
|
||||
// alErrors.Add("ImportQBCustomer: QuickBooks customer name exceeds 255 character limit for AyaNova\r\n" +
|
||||
// "Name: " + dr["FullName"].ToString() + "\r\n" +
|
||||
// "was imported as: " + sName);
|
||||
// sName = sName.Substring(0, 255);
|
||||
//}
|
||||
ApiResponse r = null;
|
||||
try
|
||||
{
|
||||
//already a client by that name cached here? (qbi7 would check directly if existing but we'll let save handle that if there is a conflict for v8 and just check the obvious first)
|
||||
if (util.QBIntegration.Items.Any(z => z.AType == AyaType.Customer && z.IntegrationItemName == dr["FullName"].ToString()))
|
||||
if (QBIntegration.Items.Any(z => z.AType == AyaType.Customer && z.IntegrationItemName == dr["FullName"].ToString()))
|
||||
{
|
||||
alErrors.Add("ImportQBCustomer: " + dr["FullName"].ToString() + " already exists in AyaNova");
|
||||
return;
|
||||
@@ -3608,26 +3606,24 @@ namespace AyaNovaQBI
|
||||
//Import seems safe...
|
||||
|
||||
Customer c = new Customer();
|
||||
c.Name = sName;//1
|
||||
|
||||
c.Name = sName;
|
||||
CopyQBCustomerInfoToAyaNovaClient(dr, c);
|
||||
|
||||
if (!c.IsSavable)
|
||||
{
|
||||
alErrors.Add("ImportQBCustomer: AyaNova won't allow import of " + c.Name + "\r\n" +
|
||||
"Due to the following broken rules:\r\n" + c.GetBrokenRulesString());
|
||||
return;
|
||||
}
|
||||
//Try to save and return errors if not in alerrors
|
||||
r=await PostAsync($"customer", Newtonsoft.Json.JsonConvert.SerializeObject(c));
|
||||
long newCustomerId=IdFromResponse(r);
|
||||
|
||||
c = (Client)c.Save();
|
||||
//Link
|
||||
IntegrationMap m = QBI.Maps.Add(QBI);
|
||||
m.Name = sName;
|
||||
m.RootObjectID = c.ID;
|
||||
m.RootObjectType = RootObjectTypes.Client;
|
||||
m.LastSync = DateTime.Now;
|
||||
m.ForeignID = QuickBooksID;
|
||||
QBI = (Integration)QBI.Save();
|
||||
var m = new IntegrationItem { AType = AyaType.Customer, IntegrationItemName = sName, IntegrationItemId = QuickBooksID, LastSync = DateTime.Now, ObjectId = newCustomerId };
|
||||
QBIntegration.Items.Add(m);
|
||||
await util.SaveIntegrationObject();
|
||||
//IntegrationMap m = QBI.Maps.Add(QBI);
|
||||
//m.Name = sName;
|
||||
//m.RootObjectID = c.ID;
|
||||
//m.RootObjectType = RootObjectTypes.Client;
|
||||
//m.LastSync = DateTime.Now;
|
||||
//m.ForeignID = QuickBooksID;
|
||||
//QBI = (Integration)QBI.Save();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -3727,17 +3723,18 @@ namespace AyaNovaQBI
|
||||
}
|
||||
|
||||
string sName = dr["FullName"].ToString();
|
||||
if (sName.Length > 255)
|
||||
{
|
||||
alErrors.Add("ImportQBVendor: QuickBooks Vendor name exceeds 255 character limit for AyaNova\r\n" +
|
||||
"Name: " + dr["FullName"].ToString() + "\r\n" +
|
||||
"was imported as: " + sName);
|
||||
sName = sName.Substring(0, 255);
|
||||
}
|
||||
//if (sName.Length > 255)
|
||||
//{
|
||||
// alErrors.Add("ImportQBVendor: QuickBooks Vendor name exceeds 255 character limit for AyaNova\r\n" +
|
||||
// "Name: " + dr["FullName"].ToString() + "\r\n" +
|
||||
// "was imported as: " + sName);
|
||||
// sName = sName.Substring(0, 255);
|
||||
//}
|
||||
try
|
||||
{
|
||||
//already a Vendor by that name
|
||||
if (Vendor.Exists(Guid.Empty, dr["FullName"].ToString()))
|
||||
// if (Vendor.Exists(Guid.Empty, dr["FullName"].ToString()))
|
||||
if (QBIntegration.Items.Any(z => z.AType == AyaType.Vendor && z.IntegrationItemName == dr["FullName"].ToString()))
|
||||
{
|
||||
alErrors.Add("ImportQBVendor: " + dr["FullName"].ToString() + " already exists in AyaNova");
|
||||
return;
|
||||
@@ -3745,17 +3742,16 @@ namespace AyaNovaQBI
|
||||
|
||||
//Import seems safe...
|
||||
|
||||
Vendor c = Vendor.NewItem();
|
||||
c.VendorType = AsVendorType;
|
||||
Vendor c = new Vendor();
|
||||
c.Name = sName;
|
||||
|
||||
|
||||
Address a = (Address)dr["MailAddress"];
|
||||
c.MailToAddress.DeliveryAddress = a.DeliveryAddress;
|
||||
c.MailToAddress.City = a.City;
|
||||
c.MailToAddress.StateProv = a.StateProv;
|
||||
c.MailToAddress.Country = a.Country;
|
||||
c.MailToAddress.Postal = a.Postal;
|
||||
c.PostAddress = a.DeliveryAddress;
|
||||
c.PostCity = a.City;
|
||||
c.PostRegion = a.StateProv;
|
||||
c.PostCountry = a.Country;
|
||||
c.PostCode = a.Postal;
|
||||
|
||||
a = (Address)dr["StreetAddress"];
|
||||
c.GoToAddress.DeliveryAddress = a.DeliveryAddress;
|
||||
|
||||
Reference in New Issue
Block a user