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
//Validate any existing
if (SetEverything == false && QDat.WorkOrderItemLoanChargeAs != null && QDat.WorkOrderItemLoanChargeAs != "")
if (SetEverything == false && QDat.WorkorderItemLoanChargeAs != null && QDat.WorkorderItemLoanChargeAs != "")
{
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" +
"This setting is mandatory / required.";
s2.QBItems = QBItems;
s2.SelectedQBItem = QDat.WorkOrderItemLoanChargeAs;
s2.SelectedQBItem = QDat.WorkorderItemLoanChargeAs;
if (s2.ShowDialog() == DialogResult.Cancel)
{
return pfstat.Cancel;
}
else
QDat.WorkOrderItemLoanChargeAs = s2.SelectedQBItem;
QDat.WorkorderItemLoanChargeAs = s2.SelectedQBItem;
s2.Dispose();
s2 = null;
@@ -5712,7 +5712,11 @@ namespace AyaNovaQBI
if (!QBIntegration.Items.Any(z => z.AType == AyaType.Customer && z.ObjectId == w.CustomerId))
{
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:
@@ -5733,7 +5737,11 @@ namespace AyaNovaQBI
if (!QBIntegration.Items.Any(z => z.AType == AyaType.ServiceRate && z.ObjectId == wl.ServiceRateId))
{
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))
{
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
@@ -5769,7 +5781,11 @@ namespace AyaNovaQBI
if (mappedPart == null || QBItems.Rows.Find(mappedPart.IntegrationItemId) == null)
{
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
@@ -5831,7 +5847,11 @@ namespace AyaNovaQBI
!QBItems.Rows.Contains(QDat.OutsideServiceChargeAs))
{
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,27 +5860,31 @@ namespace AyaNovaQBI
#region Workorder item loan charges
if (wi.Loans.Count>0)
if (wi.Loans.Count > 0)
{
//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)
//{
//case 772
bSomethingToInvoice = true;
//case 772
bSomethingToInvoice = true;
//there is something billable, just need to make sure
//that there is a QB charge defined for loaned item charges
if (string.IsNullOrWhiteSpace(QDat.WorkorderItemLoanChargeAs) ||
!QBItems.Rows.Contains(QDat.WorkorderItemLoanChargeAs))
{
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);
break;
//there is something billable, just need to make sure
//that there is a QB charge defined for loaned item charges
if (string.IsNullOrWhiteSpace(QDat.WorkorderItemLoanChargeAs) ||
!QBItems.Rows.Contains(QDat.WorkorderItemLoanChargeAs))
{
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);
break;
}
}
//}
}
}
@@ -5868,27 +5892,27 @@ namespace AyaNovaQBI
#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;
//there is something billable, just need to make sure
//that there is a QB charge defined for misc expense item charges
if (string.IsNullOrWhiteSpace(QDat.MiscExpenseChargeAs) ||
!QBItems.Rows.Contains(QDat.MiscExpenseChargeAs))
{
bSomethingToInvoice = true;
//there is something billable, just need to make sure
//that there is a QB charge defined for misc expense item charges
if (QDat.MiscExpenseChargeAs == null ||
QDat.MiscExpenseChargeAs == "" ||
!QBItems.Rows.Contains(QDat.MiscExpenseChargeAs))
{
bReturn = false;
AddMisMatch("Workorder item expense", Guid.Empty, AyaType.WorkOrderItemMiscExpense, MisMatchReason.NotLinkedToQB, MisMatches);
break;
bReturn = false;
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;
}
}
}
}
#endregion
@@ -5901,8 +5925,11 @@ namespace AyaNovaQBI
if (bReturn && !bSomethingToInvoice)
{
bReturn = false;
AddMisMatch("WO: " + w.WorkorderService.ServiceNumber.ToString() + " - Nothing chargeable on it, will not be invoiced",
Guid.Empty, AyaType.Nothing, MisMatchReason.NothingToInvoice, MisMatches);
AddMisMatch("WO: " + w.Serial + " - Nothing chargeable on it, will not be invoiced",
0,
AyaType.NoType,
MisMatchReason.NothingToInvoice,
MisMatches);
}
@@ -5918,8 +5945,15 @@ namespace AyaNovaQBI
AddMisMatch(Name, ObjectId, ObjectType, Reason, Mismatches, 0m, 0m, 0, "");
}
private static void AddMisMatch(string Name, long ObjectId, AyaType ObjectType,
MisMatchReason Reason, List<MisMatch> Mismatches, decimal QBPrice, decimal AyaPrice, long WorkOrderItemPartId, string QBListID)
private static void AddMisMatch(string Name,
long ObjectId,
AyaType ObjectType,
MisMatchReason Reason,
List<MisMatch> Mismatches,
decimal QBPrice,
decimal AyaPrice,
long WorkOrderItemPartId,
string QBListID)
{
bool bDuplicate = false;
//scan through list of existing mismatches,