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