This commit is contained in:
@@ -199,7 +199,7 @@ namespace AyaNovaQBI
|
||||
switch (_Type)
|
||||
{
|
||||
case AyaType.Customer:
|
||||
await util.ImportAyaCustomer(AyaId, alErrors);
|
||||
util.ImportAyaCustomer(AyaId, alErrors);
|
||||
break;
|
||||
case AyaType.Vendor:
|
||||
await util.ImportAyaVendor(AyaId, alErrors);
|
||||
|
||||
@@ -5,3 +5,5 @@ Test persisted form settings for server url (ONCE POSTED NEW BUILD OF AYANOVA TO
|
||||
Docs should not refer to autoclose anymore, it's status driven now
|
||||
DOCS UI use "Link" and do not use "map" anywhere
|
||||
TEST auto-linking not tested due to import not coded yet so would be fuckery to do
|
||||
Integration object is saved too often as copied the code from v7, oncce working change that to save when ops are done only as it's a much more potentially expensive operation now
|
||||
e.g.Util.ImportAyaCustomer at bottom
|
||||
@@ -3948,18 +3948,15 @@ namespace AyaNovaQBI
|
||||
|
||||
#region Export / refresh to QuickBooks
|
||||
|
||||
|
||||
|
||||
|
||||
public static void RefreshQBClientFromAyaNova(List<Guid> objectIDList)
|
||||
public static async Task RefreshQBClientFromAyaNova(List<long> objectIDList)
|
||||
{
|
||||
foreach (Guid g in objectIDList)
|
||||
foreach (long id in objectIDList)
|
||||
{
|
||||
try
|
||||
{
|
||||
Client c = Client.GetItemNoMRU(g);
|
||||
var r = await GetAsync($"customer/{id}");
|
||||
var c = r.ObjectResponse["data"].ToObject<Customer>();
|
||||
RefreshQBClientFromAyaNova(c);
|
||||
|
||||
}
|
||||
catch { };
|
||||
}
|
||||
@@ -4047,7 +4044,7 @@ namespace AyaNovaQBI
|
||||
ca.Email.SetValue(T(99, c.EmailAddress));
|
||||
|
||||
|
||||
|
||||
|
||||
bool bHasBillAddress = false;
|
||||
|
||||
//Mailing address
|
||||
@@ -4233,7 +4230,7 @@ namespace AyaNovaQBI
|
||||
|
||||
|
||||
|
||||
public static void ImportAyaClient(List<long> objectIDList)
|
||||
public static async Task ImportAyaCustomer(List<long> objectIDList)
|
||||
{
|
||||
ArrayList alErrors = new ArrayList();
|
||||
foreach (long ayid in objectIDList)
|
||||
@@ -4241,7 +4238,7 @@ namespace AyaNovaQBI
|
||||
try
|
||||
{
|
||||
|
||||
ImportAyaClient(ayid, alErrors);
|
||||
await ImportAyaCustomer(ayid, alErrors);
|
||||
|
||||
}
|
||||
catch { };
|
||||
@@ -4274,19 +4271,17 @@ namespace AyaNovaQBI
|
||||
/// </summary>
|
||||
/// <param name="CustomerId"></param>
|
||||
/// <param name="alErrors">An arraylist to hold strings indicating errors on fail</param>
|
||||
public static void ImportAyaClient(long CustomerId, ArrayList alErrors)
|
||||
public static async Task ImportAyaCustomer(long CustomerId, ArrayList alErrors)
|
||||
{
|
||||
|
||||
if (!Client.Exists(CustomerId, ""))
|
||||
if (AyaClientList.Any(z => z.Id == CustomerId))
|
||||
{
|
||||
alErrors.Add("ImportAyaClient: Client not found in AyaNova (deleted recently?) (" + CustomerId.ToString() + ")");
|
||||
return;
|
||||
|
||||
}
|
||||
Client c = Client.GetItem(CustomerId);
|
||||
|
||||
|
||||
|
||||
var r = await GetAsync($"customer/{CustomerId}");
|
||||
var c = r.ObjectResponse["data"].ToObject<Customer>();
|
||||
|
||||
string sName = c.Name;
|
||||
if (sName.Length > 41)
|
||||
@@ -4298,8 +4293,6 @@ namespace AyaNovaQBI
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Connect to QB and fill
|
||||
// IY: Create the session manager object using QBFC
|
||||
QBSessionManager sessionManager = new QBSessionManager();
|
||||
@@ -4340,10 +4333,10 @@ namespace AyaNovaQBI
|
||||
dr["Account"] = "";
|
||||
|
||||
ca.Name.SetValue(sName);
|
||||
//ca.FirstName.SetValue(T(25,Primary.FirstName));
|
||||
//Case 686
|
||||
ca.Contact.SetValue(T(41, c.Contact));
|
||||
//ca.LastName.SetValue(T(25, c.Contact));
|
||||
|
||||
//AyaNova 8 doesn't have a single "contact" field so it can't be imported
|
||||
// ca.Contact.SetValue(T(41, c.Contact));
|
||||
|
||||
|
||||
if (c.Phone1 != null)
|
||||
ca.Phone.SetValue(T(21, c.Phone1));
|
||||
@@ -4351,10 +4344,10 @@ namespace AyaNovaQBI
|
||||
ca.Phone.SetValue("");
|
||||
ca.Fax.SetValue(T(21, c.Phone2));
|
||||
ca.AltPhone.SetValue(T(21, c.Phone3));
|
||||
ca.Email.SetValue(T(99, c.Email));
|
||||
ca.Email.SetValue(T(99, c.EmailAddress));
|
||||
|
||||
|
||||
|
||||
|
||||
bool bHasBillAddress = false;
|
||||
|
||||
//Mailing address
|
||||
@@ -4364,44 +4357,23 @@ namespace AyaNovaQBI
|
||||
//as that is what is documented, not sure why they were set to 21 here before
|
||||
ca.BillAddress.Addr1.SetValue(T(41, c.Name));
|
||||
|
||||
if (c.MailToAddress.DeliveryAddress != "")
|
||||
if (!string.IsNullOrWhiteSpace(c.PostAddress))
|
||||
{
|
||||
bHasBillAddress = true;
|
||||
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)
|
||||
ca.BillAddress.Addr2.SetValue(T(41, sad[0].TrimEnd()));
|
||||
if (sad.GetLength(0) > 1)
|
||||
ca.BillAddress.Addr3.SetValue(T(41, sad[1].TrimEnd()));
|
||||
//if(sad.GetLength(0)>2)
|
||||
// ca.BillAddress.Addr3.SetValue(T(21,sad[2].TrimEnd()));
|
||||
|
||||
|
||||
if (QVersion > 1.1 && sad.GetLength(0) > 3)//4th address line is 2 or newer
|
||||
ca.BillAddress.Addr4.SetValue(T(41, sad[2].TrimEnd()));
|
||||
|
||||
}
|
||||
ca.BillAddress.City.SetValue(T(31, c.MailToAddress.City));
|
||||
ca.BillAddress.Country.SetValue(T(31, c.MailToAddress.Country));
|
||||
ca.BillAddress.PostalCode.SetValue(T(13, c.MailToAddress.Postal));
|
||||
|
||||
//QBFC7 - unifies county and province to "State"
|
||||
ca.BillAddress.State.SetValue(T(21, c.MailToAddress.StateProv));
|
||||
//switch(QCountry)
|
||||
//{
|
||||
// case "CA":
|
||||
// ca.BillAddress.Province.SetValue(T(21,c.MailToAddress.StateProv));
|
||||
// break;
|
||||
// case "UK":
|
||||
// ca.BillAddress.County.SetValue(T(21,c.MailToAddress.StateProv));
|
||||
// break;
|
||||
// default:
|
||||
// ca.BillAddress.State.SetValue(T(21,c.MailToAddress.StateProv));
|
||||
// break;
|
||||
|
||||
//}
|
||||
|
||||
|
||||
|
||||
ca.BillAddress.City.SetValue(T(31, c.PostCity));
|
||||
ca.BillAddress.Country.SetValue(T(31, c.PostCountry));
|
||||
ca.BillAddress.PostalCode.SetValue(T(13, c.PostCode));
|
||||
ca.BillAddress.State.SetValue(T(21, c.PostRegion));
|
||||
|
||||
bool bHasShipAddress = false;
|
||||
//Delivery address
|
||||
@@ -4411,10 +4383,10 @@ namespace AyaNovaQBI
|
||||
//as that is what is documented, not sure why they were set to 21 here before
|
||||
ca.ShipAddress.Addr1.SetValue(T(41, c.Name));
|
||||
|
||||
if (c.GoToAddress.DeliveryAddress != "")
|
||||
if (!string.IsNullOrWhiteSpace(c.Address))
|
||||
{
|
||||
bHasShipAddress = true;
|
||||
string[] sad = c.GoToAddress.DeliveryAddress.Replace("\r\n", "\n").Split('\n');
|
||||
string[] sad = c.Address.Replace("\r\n", "\n").Split('\n');
|
||||
if (sad.GetLength(0) > 0)
|
||||
ca.ShipAddress.Addr2.SetValue(T(41, sad[0].TrimEnd()));
|
||||
if (sad.GetLength(0) > 1)
|
||||
@@ -4429,28 +4401,10 @@ namespace AyaNovaQBI
|
||||
}
|
||||
|
||||
|
||||
ca.ShipAddress.City.SetValue(T(31, c.GoToAddress.City));
|
||||
ca.ShipAddress.Country.SetValue(T(31, c.GoToAddress.Country));
|
||||
ca.ShipAddress.PostalCode.SetValue(T(13, c.GoToAddress.Postal));
|
||||
|
||||
//QBFC7 - unifies county and province to "State"
|
||||
ca.ShipAddress.State.SetValue(T(21, c.GoToAddress.StateProv));
|
||||
//switch(QCountry)
|
||||
//{
|
||||
// case "CA":
|
||||
// ca.ShipAddress.Province.SetValue(T(21,c.GoToAddress.StateProv));
|
||||
// break;
|
||||
// case "UK":
|
||||
// ca.ShipAddress.County.SetValue(T(21,c.GoToAddress.StateProv));
|
||||
// break;
|
||||
// default:
|
||||
// ca.ShipAddress.State.SetValue(T(21,c.GoToAddress.StateProv));
|
||||
// break;
|
||||
|
||||
//}
|
||||
|
||||
|
||||
|
||||
ca.ShipAddress.City.SetValue(T(31, c.City));
|
||||
ca.ShipAddress.Country.SetValue(T(31, c.Country));
|
||||
ca.ShipAddress.PostalCode.SetValue(T(13, c.PostCode));
|
||||
ca.ShipAddress.State.SetValue(T(21, c.Region));
|
||||
|
||||
//Added: 18-Nov-2006 CASE 95
|
||||
//ensure that if only one address in ayanova that both types in QB get it
|
||||
@@ -4518,13 +4472,16 @@ namespace AyaNovaQBI
|
||||
_dtQBClients.Rows.Add(dr);
|
||||
|
||||
//Link
|
||||
IntegrationMap m = QBI.Maps.Add(QBI);
|
||||
m.Name = sName;
|
||||
m.RootObjectID = c.ID;
|
||||
m.RootObjectType = RootObjectTypes.Client;
|
||||
m.LastSync = DateTime.Now;
|
||||
m.ForeignID = sNewCustID;
|
||||
QBI = (Integration)QBI.Save();
|
||||
var m = new IntegrationItem { AType = AyaType.Customer, IntegrationItemName = sName, IntegrationItemId = sNewCustID, LastSync = DateTime.Now, ObjectId = c.Id };
|
||||
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 = sNewCustID;
|
||||
//QBI = (Integration)QBI.Save();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -4582,9 +4539,9 @@ namespace AyaNovaQBI
|
||||
to.State.SetValue(from.State.GetValue());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Import the indicated Vendor
|
||||
/// to QuickBooks Vendor record
|
||||
@@ -4775,7 +4732,7 @@ namespace AyaNovaQBI
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user