This commit is contained in:
@@ -3956,7 +3956,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>();
|
||||||
RefreshQBClientFromAyaNova(c);
|
await RefreshQBClientFromAyaNova(c);
|
||||||
}
|
}
|
||||||
catch { };
|
catch { };
|
||||||
}
|
}
|
||||||
@@ -3967,7 +3967,7 @@ namespace AyaNovaQBI
|
|||||||
/// Refresh the indicated AyaNova client
|
/// Refresh the indicated AyaNova client
|
||||||
/// to it's linked QuickBooks customer record
|
/// to it's linked QuickBooks customer record
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static async void RefreshQBClientFromAyaNova(Customer c)
|
public static async Task RefreshQBClientFromAyaNova(Customer c)
|
||||||
{
|
{
|
||||||
IntegrationItem im = util.QBIntegration.Items.FirstOrDefault(z => z.ObjectId == c.Id && z.AType == AyaType.Customer);
|
IntegrationItem im = util.QBIntegration.Items.FirstOrDefault(z => z.ObjectId == c.Id && z.AType == AyaType.Customer);
|
||||||
|
|
||||||
@@ -4274,7 +4274,7 @@ namespace AyaNovaQBI
|
|||||||
public static async Task ImportAyaCustomer(long CustomerId, ArrayList alErrors)
|
public static async Task ImportAyaCustomer(long CustomerId, ArrayList alErrors)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (AyaClientList.Any(z => z.Id == CustomerId))
|
if (!AyaClientList.Any(z => z.Id == CustomerId))
|
||||||
{
|
{
|
||||||
alErrors.Add("ImportAyaClient: Client not found in AyaNova (deleted recently?) (" + CustomerId.ToString() + ")");
|
alErrors.Add("ImportAyaClient: Client not found in AyaNova (deleted recently?) (" + CustomerId.ToString() + ")");
|
||||||
return;
|
return;
|
||||||
@@ -4548,18 +4548,17 @@ namespace AyaNovaQBI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="VendorID"></param>
|
/// <param name="VendorID"></param>
|
||||||
/// <param name="alErrors">An arraylist to hold strings indicating errors on fail</param>
|
/// <param name="alErrors">An arraylist to hold strings indicating errors on fail</param>
|
||||||
public static void ImportAyaVendor(Guid VendorID, ArrayList alErrors)
|
public static async Task ImportAyaVendor(long VendorID, ArrayList alErrors)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!Vendor.Exists(VendorID, ""))
|
if (!AyaVendorList.Any(z => z.Id == VendorID))
|
||||||
{
|
{
|
||||||
alErrors.Add("ImportAyaVendor: Vendor not found in AyaNova (deleted recently?) (" + VendorID.ToString() + ")");
|
alErrors.Add("ImportAyaVendor: Vendor not found in AyaNova (deleted recently?) (" + VendorID.ToString() + ")");
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
Vendor c = Vendor.GetItem(VendorID);
|
var r = await GetAsync($"vendor/{VendorID}");
|
||||||
|
var c = r.ObjectResponse["data"].ToObject<Vendor>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
string sName = c.Name;
|
string sName = c.Name;
|
||||||
@@ -4573,7 +4572,6 @@ namespace AyaNovaQBI
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//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
|
||||||
QBSessionManager sessionManager = new QBSessionManager();
|
QBSessionManager sessionManager = new QBSessionManager();
|
||||||
@@ -4625,11 +4623,11 @@ namespace AyaNovaQBI
|
|||||||
ca.Phone.SetValue("");
|
ca.Phone.SetValue("");
|
||||||
ca.Fax.SetValue(T(21, c.Phone2));
|
ca.Fax.SetValue(T(21, c.Phone2));
|
||||||
ca.AltPhone.SetValue(T(21, c.Phone3));
|
ca.AltPhone.SetValue(T(21, c.Phone3));
|
||||||
ca.Email.SetValue(T(99, c.Email));
|
ca.Email.SetValue(T(99, c.EmailAddress));
|
||||||
|
|
||||||
if (c.MailToAddress.DeliveryAddress != "")
|
if (!string.IsNullOrWhiteSpace(c.PostAddress))
|
||||||
{
|
{
|
||||||
string[] sad = c.MailToAddress.DeliveryAddress.Replace("\r\n", "\n").Split('\n');
|
string[] sad = c.PostAddress.Replace("\r\n", "\n").Split('\n');
|
||||||
if (sad.GetLength(0) > 0)
|
if (sad.GetLength(0) > 0)
|
||||||
ca.VendorAddress.Addr1.SetValue(T(21, sad[0].TrimEnd()));
|
ca.VendorAddress.Addr1.SetValue(T(21, sad[0].TrimEnd()));
|
||||||
if (sad.GetLength(0) > 1)
|
if (sad.GetLength(0) > 1)
|
||||||
@@ -4640,25 +4638,10 @@ namespace AyaNovaQBI
|
|||||||
ca.VendorAddress.Addr4.SetValue(T(21, sad[3].TrimEnd()));
|
ca.VendorAddress.Addr4.SetValue(T(21, sad[3].TrimEnd()));
|
||||||
|
|
||||||
}
|
}
|
||||||
ca.VendorAddress.City.SetValue(T(31, c.MailToAddress.City));
|
ca.VendorAddress.City.SetValue(T(31, c.PostCity));
|
||||||
ca.VendorAddress.Country.SetValue(T(31, c.MailToAddress.Country));
|
ca.VendorAddress.Country.SetValue(T(31, c.PostCountry));
|
||||||
ca.VendorAddress.PostalCode.SetValue(T(13, c.MailToAddress.Postal));
|
ca.VendorAddress.PostalCode.SetValue(T(13, c.PostCode));
|
||||||
|
ca.VendorAddress.State.SetValue(T(21, c.PostRegion));
|
||||||
//QBFC7 - unifies county and province to "State"
|
|
||||||
ca.VendorAddress.State.SetValue(T(21, c.MailToAddress.StateProv));
|
|
||||||
//switch(QCountry)
|
|
||||||
//{
|
|
||||||
// case "CA":
|
|
||||||
// ca.VendorAddress.Province.SetValue(T(21,c.MailToAddress.StateProv));
|
|
||||||
// break;
|
|
||||||
// case "UK":
|
|
||||||
// ca.VendorAddress.County.SetValue(T(21,c.MailToAddress.StateProv));
|
|
||||||
// break;
|
|
||||||
// default:
|
|
||||||
// ca.VendorAddress.State.SetValue(T(21,c.MailToAddress.StateProv));
|
|
||||||
// break;
|
|
||||||
|
|
||||||
//}
|
|
||||||
|
|
||||||
ca.AccountNumber.SetValue(T(99, c.AccountNumber));
|
ca.AccountNumber.SetValue(T(99, c.AccountNumber));
|
||||||
|
|
||||||
@@ -4706,13 +4689,16 @@ namespace AyaNovaQBI
|
|||||||
_dtQBVendors.Rows.Add(dr);
|
_dtQBVendors.Rows.Add(dr);
|
||||||
|
|
||||||
//Link
|
//Link
|
||||||
IntegrationMap m = QBI.Maps.Add(QBI);
|
var m = new IntegrationItem { AType = AyaType.Vendor, IntegrationItemName = sName, IntegrationItemId = sNewCustID, LastSync = DateTime.Now, ObjectId = c.Id };
|
||||||
m.Name = sName;
|
QBIntegration.Items.Add(m);
|
||||||
m.RootObjectID = c.ID;
|
await util.SaveIntegrationObject();
|
||||||
m.RootObjectType = RootObjectTypes.Vendor;
|
//IntegrationMap m = QBI.Maps.Add(QBI);
|
||||||
m.LastSync = DateTime.Now;
|
//m.Name = sName;
|
||||||
m.ForeignID = sNewCustID;
|
//m.RootObjectID = c.ID;
|
||||||
QBI = (Integration)QBI.Save();
|
//m.RootObjectType = RootObjectTypes.Vendor;
|
||||||
|
//m.LastSync = DateTime.Now;
|
||||||
|
//m.ForeignID = sNewCustID;
|
||||||
|
//QBI = (Integration)QBI.Save();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -4739,14 +4725,15 @@ namespace AyaNovaQBI
|
|||||||
/// Refresh the list of AyaNova parts to their linked QuickBooks item records
|
/// Refresh the list of AyaNova parts to their linked QuickBooks item records
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="objectIDList"></param>
|
/// <param name="objectIDList"></param>
|
||||||
public static void RefreshQBPartFromAyaNova(List<Guid> objectIDList)
|
public static async Task RefreshQBPartFromAyaNova(List<long> objectIDList)
|
||||||
{
|
{
|
||||||
foreach (Guid g in objectIDList)
|
foreach (long id in objectIDList)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Part c = Part.GetItem(g);
|
var r = await GetAsync($"part/{id}");
|
||||||
RefreshQBPartFromAyaNova(c);
|
var c = r.ObjectResponse["data"].ToObject<Part>();
|
||||||
|
await RefreshQBPartFromAyaNova(c);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch { };
|
catch { };
|
||||||
@@ -4758,7 +4745,7 @@ namespace AyaNovaQBI
|
|||||||
/// Refresh the indicated AyaNova part
|
/// Refresh the indicated AyaNova part
|
||||||
/// to it's linked QuickBooks item record
|
/// to it's linked QuickBooks item record
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void RefreshQBPartFromAyaNova(Part c)
|
public static async Task RefreshQBPartFromAyaNova(Part c)
|
||||||
{
|
{
|
||||||
|
|
||||||
IntegrationMap im = QBI.Maps[c.ID];
|
IntegrationMap im = QBI.Maps[c.ID];
|
||||||
|
|||||||
Reference in New Issue
Block a user