From ff9b45c6dc0f47ed1fb72307547da30e11476872 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 12 Jul 2022 18:28:41 +0000 Subject: [PATCH] --- AyaNovaQBI/util.cs | 72 ++++++++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 25 deletions(-) diff --git a/AyaNovaQBI/util.cs b/AyaNovaQBI/util.cs index 702dac7..a9fb8e3 100644 --- a/AyaNovaQBI/util.cs +++ b/AyaNovaQBI/util.cs @@ -2745,19 +2745,20 @@ namespace AyaNovaQBI if (clitem != null) { //add a record to the datatable - + var tempName = clitem.FullName.GetValue(); + var tempContact = ProcessQBString(clitem.Contact); DataRow dr = _dtQBClients.Rows.Add( new object[]{ clitem.ListID.GetValue(), - clitem.FullName.GetValue(), - ProcessAddress(clitem.BillAddress), - ProcessAddress(clitem.ShipAddress), + tempName, + ProcessAddress(clitem.BillAddress, tempName, tempContact), + ProcessAddress(clitem.ShipAddress, tempName, tempContact), ProcessQBString(clitem.Phone), ProcessQBString(clitem.Fax), ProcessQBString(clitem.AltPhone), ProcessQBString(clitem.Email), - ProcessQBString(clitem.Contact), + tempContact, clitem.TimeCreated.GetValue(), clitem.TimeModified.GetValue(), ProcessQBString(clitem.AccountNumber), @@ -2795,7 +2796,7 @@ namespace AyaNovaQBI /// /// /// - private static Address ProcessAddress(IAddress a) + private static Address ProcessAddress(IAddress a, string filteroutname, string filteroutcontact) { Address b = new Address(); b.City = ""; @@ -2807,13 +2808,31 @@ namespace AyaNovaQBI //Append each line of the address, add cr/lf for each line if present after //the first line //Assumption: First line always has *something* in it - b.DeliveryAddress = ProcessQBString(a.Addr1); - b.DeliveryAddress += SS("\r\n", ProcessQBString(a.Addr2), ""); - b.DeliveryAddress += SS("\r\n", ProcessQBString(a.Addr3), ""); + + //v8: QB Sample data has redundant contact and company / person name in first two address rows, not sure if this is convention or not but filtering it out if it is present + string temp = ProcessQBString(a.Addr1); + temp.Replace(filteroutname + "\r\n", ""); + temp.Replace(filteroutcontact + "\r\n", ""); + b.DeliveryAddress = temp; + + temp = ProcessQBString(a.Addr2); + temp.Replace(filteroutname + "\r\n", ""); + temp.Replace(filteroutcontact + "\r\n", ""); + b.DeliveryAddress += SS("\r\n", temp, ""); + + temp = ProcessQBString(a.Addr3); + temp.Replace(filteroutname + "\r\n", ""); + temp.Replace(filteroutcontact + "\r\n", ""); + b.DeliveryAddress += SS("\r\n", temp, ""); //Address line 4 is a qbxml 2 or higher feature if (QVersion > 1.1) - b.DeliveryAddress += SS("\r\n", ProcessQBString(a.Addr4), ""); + { + temp = ProcessQBString(a.Addr4); + temp.Replace(filteroutname + "\r\n", ""); + temp.Replace(filteroutcontact + "\r\n", ""); + b.DeliveryAddress += SS("\r\n", temp, ""); + } //Country specific: b.City = ProcessQBString(a.City); @@ -2963,24 +2982,27 @@ namespace AyaNovaQBI if (clitem != null) { //add a record to the datatable - + var tempName = clitem.Name.GetValue(); + var tempContact = ProcessQBString(clitem.Contact); DataRow dr = _dtQBVendors.Rows.Add( new object[] - { - clitem.ListID.GetValue(), - clitem.Name.GetValue(), - ProcessAddress(clitem.VendorAddress), - ProcessAddress(clitem.VendorAddress), - ProcessQBString(clitem.Phone), - ProcessQBString(clitem.Fax), - ProcessQBString(clitem.AltPhone), - ProcessQBString(clitem.Email), - ProcessQBString(clitem.Contact), - clitem.TimeCreated.GetValue(), - clitem.TimeModified.GetValue(), - ProcessQBString(clitem.AccountNumber) - }); + { + clitem.ListID.GetValue(), + tempName, + ProcessAddress(clitem.VendorAddress,tempName, tempContact), + ProcessAddress(clitem.VendorAddress, + tempName, + tempContact), + ProcessQBString(clitem.Phone), + ProcessQBString(clitem.Fax), + ProcessQBString(clitem.AltPhone), + ProcessQBString(clitem.Email), + tempContact, + clitem.TimeCreated.GetValue(), + clitem.TimeModified.GetValue(), + ProcessQBString(clitem.AccountNumber) + }); } } // for loop } // if