This commit is contained in:
2022-07-09 21:47:33 +00:00
parent 1b43acc6e6
commit e3d56e3432

View File

@@ -996,7 +996,7 @@ namespace AyaNovaQBI
#region Workorder item loan charge as #region Workorder item loan charge as
//Validate any existing //Validate any existing
if (SetEverything == false && QDat.WorkOrderItemLoanChargeAs != null && QDat.WorkOrderItemLoanChargeAs != "") if (SetEverything == false && QDat.WorkorderItemLoanChargeAs != null && QDat.WorkorderItemLoanChargeAs != "")
{ {
goto LOANCHARGEASOK; goto LOANCHARGEASOK;
} }
@@ -1010,14 +1010,14 @@ namespace AyaNovaQBI
"to use when invoicing the AyaNova \"Workorder item loan\" portion of a work order.\r\n\r\n" + "to use when invoicing the AyaNova \"Workorder item loan\" portion of a work order.\r\n\r\n" +
"This setting is mandatory / required."; "This setting is mandatory / required.";
s2.QBItems = QBItems; s2.QBItems = QBItems;
s2.SelectedQBItem = QDat.WorkOrderItemLoanChargeAs; s2.SelectedQBItem = QDat.WorkorderItemLoanChargeAs;
if (s2.ShowDialog() == DialogResult.Cancel) if (s2.ShowDialog() == DialogResult.Cancel)
{ {
return pfstat.Cancel; return pfstat.Cancel;
} }
else else
QDat.WorkOrderItemLoanChargeAs = s2.SelectedQBItem; QDat.WorkorderItemLoanChargeAs = s2.SelectedQBItem;
s2.Dispose(); s2.Dispose();
s2 = null; s2 = null;
@@ -5712,7 +5712,11 @@ namespace AyaNovaQBI
if (!QBIntegration.Items.Any(z => z.AType == AyaType.Customer && z.ObjectId == w.CustomerId)) if (!QBIntegration.Items.Any(z => z.AType == AyaType.Customer && z.ObjectId == w.CustomerId))
{ {
bReturn = false; bReturn = false;
AddMisMatch(AyaClientList.FirstOrDefault(z => z.Id == w.CustomerId).Name, w.CustomerId, AyaType.Customer, MisMatchReason.NotLinkedToQB, MisMatches); AddMisMatch(AyaClientList.FirstOrDefault(z => z.Id == w.CustomerId).Name,
w.CustomerId,
AyaType.Customer,
MisMatchReason.NotLinkedToQB,
MisMatches);
} }
//Service rates: //Service rates:
@@ -5733,7 +5737,11 @@ namespace AyaNovaQBI
if (!QBIntegration.Items.Any(z => z.AType == AyaType.ServiceRate && z.ObjectId == wl.ServiceRateId)) if (!QBIntegration.Items.Any(z => z.AType == AyaType.ServiceRate && z.ObjectId == wl.ServiceRateId))
{ {
bReturn = false; bReturn = false;
AddMisMatch(AyaServiceRateList.FirstOrDefault(z => z.Id == wl.ServiceRateId).Name, (long)wl.ServiceRateId, AyaType.ServiceRate, MisMatchReason.NotLinkedToQB, MisMatches); AddMisMatch(AyaServiceRateList.FirstOrDefault(z => z.Id == wl.ServiceRateId).Name,
(long)wl.ServiceRateId,
AyaType.ServiceRate,
MisMatchReason.NotLinkedToQB,
MisMatches);
} }
} }
@@ -5753,7 +5761,11 @@ namespace AyaNovaQBI
if (!QBIntegration.Items.Any(z => z.AType == AyaType.TravelRate && z.ObjectId == wt.TravelRateId)) if (!QBIntegration.Items.Any(z => z.AType == AyaType.TravelRate && z.ObjectId == wt.TravelRateId))
{ {
bReturn = false; bReturn = false;
AddMisMatch(AyaTravelRateList.FirstOrDefault(z => z.Id == wt.TravelRateId).Name, (long)wt.TravelRateId, AyaType.TravelRate, MisMatchReason.NotLinkedToQB, MisMatches); ; AddMisMatch(AyaTravelRateList.FirstOrDefault(z => z.Id == wt.TravelRateId).Name,
(long)wt.TravelRateId,
AyaType.TravelRate,
MisMatchReason.NotLinkedToQB,
MisMatches); ;
} }
} }
#endregion #endregion
@@ -5769,7 +5781,11 @@ namespace AyaNovaQBI
if (mappedPart == null || QBItems.Rows.Find(mappedPart.IntegrationItemId) == null) if (mappedPart == null || QBItems.Rows.Find(mappedPart.IntegrationItemId) == null)
{ {
bReturn = false; bReturn = false;
AddMisMatch(AyaPartList.FirstOrDefault(z => z.Id == wp.PartId).Name, wp.PartId, AyaType.Part, MisMatchReason.NotLinkedToQB, MisMatches); AddMisMatch(AyaPartList.FirstOrDefault(z => z.Id == wp.PartId).Name,
wp.PartId,
AyaType.Part,
MisMatchReason.NotLinkedToQB,
MisMatches);
} }
else else
@@ -5831,7 +5847,11 @@ namespace AyaNovaQBI
!QBItems.Rows.Contains(QDat.OutsideServiceChargeAs)) !QBItems.Rows.Contains(QDat.OutsideServiceChargeAs))
{ {
bReturn = false; bReturn = false;
AddMisMatch("Outside services - can't be billed as not yet mapped to a QB Charge item\r\nSet in Tools->Preferences", 0, AyaType.WorkOrderItemOutsideService, MisMatchReason.NotLinkedToQB, MisMatches); AddMisMatch("Outside services - can't be billed as not yet mapped to a QB Charge item\r\nSet in Tools->Preferences",
0,
AyaType.WorkOrderItemOutsideService,
MisMatchReason.NotLinkedToQB,
MisMatches);
} }
} }
@@ -5840,10 +5860,10 @@ namespace AyaNovaQBI
#region Workorder item loan charges #region Workorder item loan charges
if (wi.Loans.Count>0) if (wi.Loans.Count > 0)
{ {
//foreach (WorkOrderItemLoan wil in wi.Loans) //foreach (WorkOrderItemLoan wil in wi.Loans)
if(wi.Loans.Any(z => z.PriceViz != 0)) if (wi.Loans.Any(z => z.PriceViz != 0))
{ {
//if (wil.PriceViz != 0) //if (wil.PriceViz != 0)
@@ -5857,7 +5877,11 @@ namespace AyaNovaQBI
!QBItems.Rows.Contains(QDat.WorkorderItemLoanChargeAs)) !QBItems.Rows.Contains(QDat.WorkorderItemLoanChargeAs))
{ {
bReturn = false; bReturn = false;
AddMisMatch("Workorder item loan - can't be billed as not yet mapped to a QB Charge item\r\nSet in Tools->Preferences", 0, AyaType.WorkOrderItemLoan, MisMatchReason.NotLinkedToQB, MisMatches); AddMisMatch("Workorder item loan - can't be billed as not yet mapped to a QB Charge item\r\nSet in Tools->Preferences",
0,
AyaType.WorkOrderItemLoan,
MisMatchReason.NotLinkedToQB,
MisMatches);
break; break;
} }
@@ -5868,27 +5892,27 @@ namespace AyaNovaQBI
#region Workorder item misc expenses #region Workorder item misc expenses
if (wi.HasExpenses) if (wi.Expenses.Count > 0)
{ {
foreach (WorkOrderItemMiscExpense wie in wi.Expenses) //foreach (WorkOrderItemMiscExpense wie in wi.Expenses)
{ if (wi.Expenses.Any(z => z.ChargeToCustomer && z.ChargeAmount != 0))
if (wie.ChargeToClient)
{ {
bSomethingToInvoice = true; bSomethingToInvoice = true;
//there is something billable, just need to make sure //there is something billable, just need to make sure
//that there is a QB charge defined for misc expense item charges //that there is a QB charge defined for misc expense item charges
if (QDat.MiscExpenseChargeAs == null || if (string.IsNullOrWhiteSpace(QDat.MiscExpenseChargeAs) ||
QDat.MiscExpenseChargeAs == "" ||
!QBItems.Rows.Contains(QDat.MiscExpenseChargeAs)) !QBItems.Rows.Contains(QDat.MiscExpenseChargeAs))
{ {
bReturn = false; bReturn = false;
AddMisMatch("Workorder item expense", Guid.Empty, AyaType.WorkOrderItemMiscExpense, MisMatchReason.NotLinkedToQB, MisMatches); AddMisMatch("Workorder item expense - can't be billed as not yet mapped to a QB Charge item\r\nSet in Tools->Preferences",
0,
AyaType.WorkOrderItemExpense,
MisMatchReason.NotLinkedToQB,
MisMatches);
break; break;
} }
}
} }
} }
#endregion #endregion
@@ -5901,8 +5925,11 @@ namespace AyaNovaQBI
if (bReturn && !bSomethingToInvoice) if (bReturn && !bSomethingToInvoice)
{ {
bReturn = false; bReturn = false;
AddMisMatch("WO: " + w.WorkorderService.ServiceNumber.ToString() + " - Nothing chargeable on it, will not be invoiced", AddMisMatch("WO: " + w.Serial + " - Nothing chargeable on it, will not be invoiced",
Guid.Empty, AyaType.Nothing, MisMatchReason.NothingToInvoice, MisMatches); 0,
AyaType.NoType,
MisMatchReason.NothingToInvoice,
MisMatches);
} }
@@ -5918,8 +5945,15 @@ namespace AyaNovaQBI
AddMisMatch(Name, ObjectId, ObjectType, Reason, Mismatches, 0m, 0m, 0, ""); AddMisMatch(Name, ObjectId, ObjectType, Reason, Mismatches, 0m, 0m, 0, "");
} }
private static void AddMisMatch(string Name, long ObjectId, AyaType ObjectType, private static void AddMisMatch(string Name,
MisMatchReason Reason, List<MisMatch> Mismatches, decimal QBPrice, decimal AyaPrice, long WorkOrderItemPartId, string QBListID) long ObjectId,
AyaType ObjectType,
MisMatchReason Reason,
List<MisMatch> Mismatches,
decimal QBPrice,
decimal AyaPrice,
long WorkOrderItemPartId,
string QBListID)
{ {
bool bDuplicate = false; bool bDuplicate = false;
//scan through list of existing mismatches, //scan through list of existing mismatches,