This commit is contained in:
2022-07-05 21:20:40 +00:00
parent c22a439011
commit 9a07c05401

View File

@@ -3170,7 +3170,7 @@ namespace AyaNovaQBI
} }
//----Get the edit sequence----- //----Get the edit sequence-----
string sEditSequence = GetInventoryItemEditSequence(QBListID); string sEditSequence = await GetInventoryItemEditSequenceAsync(QBListID);
//Connect to QB and fill //Connect to QB and fill
// IY: Create the session manager object using QBFC // IY: Create the session manager object using QBFC
@@ -3529,30 +3529,33 @@ namespace AyaNovaQBI
#region Import / refresh to AyaNova #region Import / refresh to AyaNova
public static void RefreshAyaNovaClientFromQB(List<Guid> objectIDList) public static async Task RefreshAyaNovaClientFromQB(List<long> objectIDList)
{ {
PopulateQBClientCache(); await PopulateQBClientCacheAsync();
foreach (Guid g in objectIDList) foreach (long id in objectIDList)
{ {
try try
{ {
Client c = Client.GetItemNoMRU(g); var r = await GetAsync($"customer/{id}");
var c = r.ObjectResponse["data"].ToObject<Customer>();
RefreshAyaNovaClientFromQB(c); RefreshAyaNovaClientFromQB(c);
if (c.IsSavable) r=await PostAsync($"customer/{id}", Newtonsoft.Json.JsonConvert.SerializeObject(c));
c.Save();
//if (c.IsSavable)
// c.Save();
} }
catch { }; catch { };
} }
} }
public static async void RefreshAyaNovaClientFromQB(Client c) public static async void RefreshAyaNovaClientFromQB(Customer c)
{ {
await PopulateQBClientCacheAsync(); await PopulateQBClientCacheAsync();
IntegrationMap im = QBI.Maps[c.ID]; IntegrationItem im = util.QBIntegration.Items.FirstOrDefault(z => z.ObjectId == c.Id && z.AType == AyaType.Customer);
if (im == null) return;//this client is not linked if (im == null) return;//this client is not linked
DataRow dr = _dtQBClients.Rows.Find(im.ForeignID); DataRow dr = _dtQBClients.Rows.Find(im.IntegrationItemId);
if (dr == null) return; //QBListID not found in client list? if (dr == null) return; //QBListID not found in client list?
CopyQBCustomerInfoToAyaNovaClient(dr, c); CopyQBCustomerInfoToAyaNovaClient(dr, c);
@@ -3658,15 +3661,20 @@ namespace AyaNovaQBI
//Case 518 //Case 518
if (string.IsNullOrWhiteSpace(c.Address)) c.Address = c.PostAddress; if (string.IsNullOrWhiteSpace(c.Address)) c.Address = c.PostAddress;
if (string.IsNullOrWhiteSpace(c.PostAddress)) c.PostAddress = c.Address; if (string.IsNullOrWhiteSpace(c.PostAddress)) c.PostAddress = c.Address;
CopyToEmptyString(c.Address, c.PostAddress);
CopyToEmptyString(c.City, c.PostCity); if (string.IsNullOrWhiteSpace(c.City)) c.City = c.PostCity;
CopyToEmptyString(c.Region, c.PostRegion); if (string.IsNullOrWhiteSpace(c.PostCity)) c.PostCity = c.City;
CopyToEmptyString(c.Country, c.PostCountry);
if (string.IsNullOrWhiteSpace(c.Region)) c.Region = c.PostRegion;
if (string.IsNullOrWhiteSpace(c.PostRegion)) c.PostRegion = c.Region;
if (string.IsNullOrWhiteSpace(c.Country)) c.Country = c.PostCountry;
if (string.IsNullOrWhiteSpace(c.PostCountry)) c.PostCountry = c.Country;
//Contact cn=c.Contacts.Add(RootObjectTypes.Client,c.ID); //Contact cn=c.Contacts.Add(RootObjectTypes.Client,c.ID);
c.Notes = $"QB Contact - {dr["Contact"].ToString()}"; c.Notes = $"QB Contact - {dr["Contact"]}";
//Phone field //Phone field