This commit is contained in:
2022-07-08 23:47:02 +00:00
parent 1cd70a5be8
commit e653e42db8
4 changed files with 184 additions and 182 deletions

View File

@@ -128,7 +128,7 @@ namespace AyaNovaQBI
await util.ValidateSettings(true); await util.ValidateSettings(true);
} }
private async Task mapAndImportToolStripMenuItem_Click(object sender, EventArgs e) private async void mapAndImportToolStripMenuItem_Click(object sender, EventArgs e)
{ {
Map m = new Map(); Map m = new Map();
if (m.ShowDialog() == DialogResult.Abort) if (m.ShowDialog() == DialogResult.Abort)

View File

@@ -85,7 +85,7 @@ namespace AyaNovaQBI
public decimal? Longitude { get; set; } public decimal? Longitude { get; set; }
public List<WorkOrderItem> Items { get; set; } = new List<WorkOrderItem>(); public List<WorkOrderItem> Items { get; set; } = new List<WorkOrderItem>();
public List<WorkOrderState> States { get; set; } = new List<WorkOrderState>(); // public List<WorkOrderState> States { get; set; } = new List<WorkOrderState>();
//UTILITY FIELDS //UTILITY FIELDS

View File

@@ -50,11 +50,11 @@ namespace AyaNovaQBI
public List<WorkOrderItemLabor> Labors { get; set; } = new List<WorkOrderItemLabor>(); public List<WorkOrderItemLabor> Labors { get; set; } = new List<WorkOrderItemLabor>();
public List<WorkOrderItemLoan> Loans { get; set; } = new List<WorkOrderItemLoan>(); public List<WorkOrderItemLoan> Loans { get; set; } = new List<WorkOrderItemLoan>();
public List<WorkOrderItemPart> Parts { get; set; } = new List<WorkOrderItemPart>(); public List<WorkOrderItemPart> Parts { get; set; } = new List<WorkOrderItemPart>();
public List<WorkOrderItemPartRequest> PartRequests { get; set; } = new List<WorkOrderItemPartRequest>(); // public List<WorkOrderItemPartRequest> PartRequests { get; set; } = new List<WorkOrderItemPartRequest>();
public List<WorkOrderItemScheduledUser> ScheduledUsers { get; set; } = new List<WorkOrderItemScheduledUser>(); // public List<WorkOrderItemScheduledUser> ScheduledUsers { get; set; } = new List<WorkOrderItemScheduledUser>();
public List<WorkOrderItemTask> Tasks { get; set; } = new List<WorkOrderItemTask>(); // public List<WorkOrderItemTask> Tasks { get; set; } = new List<WorkOrderItemTask>();
public List<WorkOrderItemTravel> Travels { get; set; } = new List<WorkOrderItemTravel>(); public List<WorkOrderItemTravel> Travels { get; set; } = new List<WorkOrderItemTravel>();
public List<WorkOrderItemUnit> Units { get; set; } = new List<WorkOrderItemUnit>(); // public List<WorkOrderItemUnit> Units { get; set; } = new List<WorkOrderItemUnit>();
public List<WorkOrderItemOutsideService> OutsideServices { get; set; } = new List<WorkOrderItemOutsideService>(); public List<WorkOrderItemOutsideService> OutsideServices { get; set; } = new List<WorkOrderItemOutsideService>();
} }
} }

View File

@@ -5676,10 +5676,10 @@ namespace AyaNovaQBI
public long ObjectId { get; set; } public long ObjectId { get; set; }
public AyaType ObjectType { get; set; } public AyaType ObjectType { get; set; }
public string Name { get; set; } public string Name { get; set; }
public MisMatchReason mReason { get; set; } public MisMatchReason Reason { get; set; }
public decimal AyaPrice { get; set; } public decimal AyaPrice { get; set; }
public decimal QBPrice { get; set; } public decimal QBPrice { get; set; }
public long WorkorderItemPartId { get; set; } public long WorkOrderItemPartId { get; set; }
public string QBListID { get; set; } public string QBListID { get; set; }
} }
@@ -5704,205 +5704,205 @@ namespace AyaNovaQBI
bool bSomethingToInvoice = false; bool bSomethingToInvoice = false;
Workorder w = Workorder.GetItem(WorkorderID); //WorkOrder w = Workorder.GetItem(WorkorderID);
//Client ok? ////Client ok?
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[w.ClientID].Name, w.ClientID, AyaType.Customer, MisMatchReason.NotLinkedToQB, MisMatches); // AddMisMatch(AyaClientList[w.ClientID].Name, w.ClientID, AyaType.Customer, MisMatchReason.NotLinkedToQB, MisMatches);
} //}
//Service rates: ////Service rates:
foreach (WorkorderItem wi in w.WorkorderItems) //foreach (WorkorderItem wi in w.WorkorderItems)
{ //{
#region Labor // #region Labor
foreach (WorkorderItemLabor wl in wi.Labors) // foreach (WorkorderItemLabor wl in wi.Labors)
{ // {
//If there's *any* labor then there is something to invoice // //If there's *any* labor then there is something to invoice
bSomethingToInvoice = true; // bSomethingToInvoice = true;
//Check that rate isn't actually guid.empty // //Check that rate isn't actually guid.empty
//it's possible that some users have not selected a rate on the workorder // //it's possible that some users have not selected a rate on the workorder
if (wl.ServiceRateID == Guid.Empty) // if (wl.ServiceRateID == Guid.Empty)
throw new System.ApplicationException("ERROR: Workorder " + w.WorkorderService.ServiceNumber.ToString() + " has a labor item with no rate selected\r\n" + // throw new System.ApplicationException("ERROR: Workorder " + w.WorkorderService.ServiceNumber.ToString() + " has a labor item with no rate selected\r\n" +
"This is a serious problem for QBI and needs to be rectified before QBI can be used.\r\n"); // "This is a serious problem for QBI and needs to be rectified before QBI can be used.\r\n");
if (!QBI.Maps.Contains(wl.ServiceRateID)) // if (!QBI.Maps.Contains(wl.ServiceRateID))
{ // {
bReturn = false; // bReturn = false;
AddMisMatch(AyaRateList[wl.ServiceRateID].Name, wl.ServiceRateID, RootObjectTypes.Rate, MisMatchReason.NotLinkedToQB, MisMatches); // AddMisMatch(AyaRateList[wl.ServiceRateID].Name, wl.ServiceRateID, RootObjectTypes.Rate, MisMatchReason.NotLinkedToQB, MisMatches);
} // }
} // }
#endregion // #endregion
#region Travel // #region Travel
foreach (WorkorderItemTravel wt in wi.Travels) // foreach (WorkorderItemTravel wt in wi.Travels)
{ // {
//If there's *any* travel then there is something to invoice // //If there's *any* travel then there is something to invoice
bSomethingToInvoice = true; // bSomethingToInvoice = true;
//Check that rate isn't actually guid.empty // //Check that rate isn't actually guid.empty
//it's possible that some users have not selected a rate on the workorder // //it's possible that some users have not selected a rate on the workorder
if (wt.TravelRateID == Guid.Empty) // if (wt.TravelRateID == Guid.Empty)
throw new System.ApplicationException("ERROR: Workorder " + w.WorkorderService.ServiceNumber.ToString() + " has a travel item with no rate selected\r\n" + // throw new System.ApplicationException("ERROR: Workorder " + w.WorkorderService.ServiceNumber.ToString() + " has a travel item with no rate selected\r\n" +
"This is a serious problem for QBI and needs to be rectified before QBI can be used.\r\n"); // "This is a serious problem for QBI and needs to be rectified before QBI can be used.\r\n");
if (!QBI.Maps.Contains(wt.TravelRateID)) // if (!QBI.Maps.Contains(wt.TravelRateID))
{ // {
bReturn = false; // bReturn = false;
AddMisMatch(AyaRateList[wt.TravelRateID].Name, wt.TravelRateID, RootObjectTypes.Rate, MisMatchReason.NotLinkedToQB, MisMatches); // AddMisMatch(AyaRateList[wt.TravelRateID].Name, wt.TravelRateID, RootObjectTypes.Rate, MisMatchReason.NotLinkedToQB, MisMatches);
} // }
} // }
#endregion // #endregion
#region Parts // #region Parts
foreach (WorkorderItemPart wp in wi.Parts) // foreach (WorkorderItemPart wp in wi.Parts)
{ // {
//If there's *any* parts then there is something to invoice // //If there's *any* parts then there is something to invoice
bSomethingToInvoice = true; // bSomethingToInvoice = true;
//Changed: 14-Nov-2006 to check that linked item id exists in qb // //Changed: 14-Nov-2006 to check that linked item id exists in qb
if (!QBI.Maps.Contains(wp.PartID) || QBItems.Rows.Find(QBI.Maps[wp.PartID].ForeignID) == null) // if (!QBI.Maps.Contains(wp.PartID) || QBItems.Rows.Find(QBI.Maps[wp.PartID].ForeignID) == null)
{ // {
bReturn = false; // bReturn = false;
//Changed: 21-June-2006 to use display formatted name // //Changed: 21-June-2006 to use display formatted name
AddMisMatch(AyaPartList[wp.PartID].DisplayName(Util.GlobalSettings.DefaultPartDisplayFormat), wp.PartID, RootObjectTypes.Part, MisMatchReason.NotLinkedToQB, MisMatches); // AddMisMatch(AyaPartList[wp.PartID].DisplayName(Util.GlobalSettings.DefaultPartDisplayFormat), wp.PartID, RootObjectTypes.Part, MisMatchReason.NotLinkedToQB, MisMatches);
} // }
else // else
{ // {
//check the price // //check the price
if (!PriceOverrides.Contains(wp.ID)) // if (!PriceOverrides.Contains(wp.ID))
{ // {
decimal qbPrice = (decimal)QBItems.Rows.Find(QBI.Maps[wp.PartID].ForeignID)["Price"]; // decimal qbPrice = (decimal)QBItems.Rows.Find(QBI.Maps[wp.PartID].ForeignID)["Price"];
//------------DISCOUNT----------------- // //------------DISCOUNT-----------------
string disco = ""; // string disco = "";
//Added:20-July-2006 to incorporate discounts on parts into qb invoice // //Added:20-July-2006 to incorporate discounts on parts into qb invoice
decimal charge; // decimal charge;
//Changed: 18-Nov-2006 CASE 158 // //Changed: 18-Nov-2006 CASE 158
//this is all wrong, it was multiplying price by quantity to calculate charge when it shouldn't // //this is all wrong, it was multiplying price by quantity to calculate charge when it shouldn't
//removed quanty * price in next line to just price // //removed quanty * price in next line to just price
charge = decimal.Round(wp.Price, 2, MidpointRounding.AwayFromZero); // charge = decimal.Round(wp.Price, 2, MidpointRounding.AwayFromZero);
charge = charge - (decimal.Round(charge * wp.Discount, 2, MidpointRounding.AwayFromZero)); // charge = charge - (decimal.Round(charge * wp.Discount, 2, MidpointRounding.AwayFromZero));
if (wp.Discount != 0) // if (wp.Discount != 0)
{ // {
disco = " (Price " + wp.Price.ToString("c") + " discounted on workorder " + wp.Discount.ToString("p") + ") \r\n"; // disco = " (Price " + wp.Price.ToString("c") + " discounted on workorder " + wp.Discount.ToString("p") + ") \r\n";
} // }
//----------------------------- // //-----------------------------
//It's a match, let's see if the price matches as well // //It's a match, let's see if the price matches as well
if (charge != qbPrice) // if (charge != qbPrice)
{ // {
bReturn = false; // bReturn = false;
AddMisMatch("WO: " + w.WorkorderService.ServiceNumber.ToString() + disco + " Part: " + AyaPartList[wp.PartID].DisplayName(Util.GlobalSettings.DefaultPartDisplayFormat),//Changed: 21-June-2006 to use display formatted name // AddMisMatch("WO: " + w.WorkorderService.ServiceNumber.ToString() + disco + " Part: " + AyaPartList[wp.PartID].DisplayName(Util.GlobalSettings.DefaultPartDisplayFormat),//Changed: 21-June-2006 to use display formatted name
wp.PartID, RootObjectTypes.Part, MisMatchReason.PriceDifferent, MisMatches, qbPrice, charge, wp.ID, // wp.PartID, RootObjectTypes.Part, MisMatchReason.PriceDifferent, MisMatches, qbPrice, charge, wp.ID,
QBI.Maps[wp.PartID].ForeignID); // QBI.Maps[wp.PartID].ForeignID);
} // }
} // }
} // }
} // }
#endregion // #endregion
#region Outside service charges // #region Outside service charges
if (wi.HasOutsideService) // if (wi.HasOutsideService)
{ // {
if (wi.OutsideService.RepairPrice != 0 || wi.OutsideService.ShippingPrice != 0) // if (wi.OutsideService.RepairPrice != 0 || wi.OutsideService.ShippingPrice != 0)
{ // {
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 outside service // //that there is a QB charge defined for outside service
if (QDat.OutsideServiceChargeAs == null || // if (QDat.OutsideServiceChargeAs == null ||
QDat.OutsideServiceChargeAs == "" || // QDat.OutsideServiceChargeAs == "" ||
!QBItems.Rows.Contains(QDat.OutsideServiceChargeAs)) // !QBItems.Rows.Contains(QDat.OutsideServiceChargeAs))
{ // {
bReturn = false; // bReturn = false;
AddMisMatch("Outside service", Guid.Empty, RootObjectTypes.WorkorderItemOutsideService, MisMatchReason.NotLinkedToQB, MisMatches); // AddMisMatch("Outside service", Guid.Empty, RootObjectTypes.WorkorderItemOutsideService, MisMatchReason.NotLinkedToQB, MisMatches);
} // }
} // }
} // }
#endregion // #endregion
#region Workorder item loan charges // #region Workorder item loan charges
if (wi.HasLoans) // if (wi.HasLoans)
{ // {
foreach (WorkorderItemLoan wil in wi.Loans) // foreach (WorkorderItemLoan wil in wi.Loans)
{ // {
if (wil.Charges != 0) // if (wil.Charges != 0)
{ // {
//case 772 // //case 772
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 loaned item charges // //that there is a QB charge defined for loaned item charges
if (QDat.WorkorderItemLoanChargeAs == null || // if (QDat.WorkorderItemLoanChargeAs == null ||
QDat.WorkorderItemLoanChargeAs == "" || // QDat.WorkorderItemLoanChargeAs == "" ||
!QBItems.Rows.Contains(QDat.WorkorderItemLoanChargeAs)) // !QBItems.Rows.Contains(QDat.WorkorderItemLoanChargeAs))
{ // {
bReturn = false; // bReturn = false;
AddMisMatch("Workorder item loan", Guid.Empty, RootObjectTypes.WorkorderItemLoan, MisMatchReason.NotLinkedToQB, MisMatches); // AddMisMatch("Workorder item loan", Guid.Empty, RootObjectTypes.WorkorderItemLoan, MisMatchReason.NotLinkedToQB, MisMatches);
break; // break;
} // }
} // }
} // }
} // }
#endregion // #endregion
#region Workorder item misc expenses // #region Workorder item misc expenses
if (wi.HasExpenses) // if (wi.HasExpenses)
{ // {
foreach (WorkorderItemMiscExpense wie in wi.Expenses) // foreach (WorkorderItemMiscExpense wie in wi.Expenses)
{ // {
if (wie.ChargeToClient) // 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 (QDat.MiscExpenseChargeAs == null ||
QDat.MiscExpenseChargeAs == "" || // QDat.MiscExpenseChargeAs == "" ||
!QBItems.Rows.Contains(QDat.MiscExpenseChargeAs)) // !QBItems.Rows.Contains(QDat.MiscExpenseChargeAs))
{ // {
bReturn = false; // bReturn = false;
AddMisMatch("Workorder item expense", Guid.Empty, RootObjectTypes.WorkorderItemMiscExpense, MisMatchReason.NotLinkedToQB, MisMatches); // AddMisMatch("Workorder item expense", Guid.Empty, RootObjectTypes.WorkorderItemMiscExpense, MisMatchReason.NotLinkedToQB, MisMatches);
break; // break;
} // }
} // }
} // }
} // }
#endregion // #endregion
}//workorder items loop //}//workorder items loop
//If there are no mismatches so far, ////If there are no mismatches so far,
//maybe it's because it's got nothing to invoice? ////maybe it's because it's got nothing to invoice?
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.WorkorderService.ServiceNumber.ToString() + " - Nothing chargeable on it, will not be invoiced",
Guid.Empty, RootObjectTypes.Nothing, MisMatchReason.NothingToInvoice, MisMatches); // Guid.Empty, RootObjectTypes.Nothing, MisMatchReason.NothingToInvoice, MisMatches);
} //}
return bReturn; return bReturn;
@@ -5911,13 +5911,13 @@ namespace AyaNovaQBI
private static void AddMisMatch(string Name, Guid RootObjectID, RootObjectTypes RootObjectType, MisMatchReason Reason, ArrayList Mismatches) private static void AddMisMatch(string Name, long ObjectId, AyaType ObjectType, MisMatchReason Reason, ArrayList Mismatches)
{ {
AddMisMatch(Name, RootObjectID, RootObjectType, Reason, Mismatches, 0m, 0m, Guid.Empty, ""); AddMisMatch(Name, ObjectId, ObjectType, Reason, Mismatches, 0m, 0m, 0, "");
} }
private static void AddMisMatch(string Name, Guid RootObjectID, RootObjectTypes RootObjectType, private static void AddMisMatch(string Name, long ObjectId, AyaType ObjectType,
MisMatchReason Reason, ArrayList Mismatches, decimal QBPrice, decimal AyaPrice, Guid WorkorderItemPartID, string QBListID) MisMatchReason Reason, ArrayList 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,
@@ -5934,7 +5934,7 @@ namespace AyaNovaQBI
//Have to check ID and type here because for outside service //Have to check ID and type here because for outside service
//and loans and misc expenses the id is always empty so type is //and loans and misc expenses the id is always empty so type is
//the only way to differentiate //the only way to differentiate
if (m.RootObjectID == RootObjectID && m.ObjectType == RootObjectType) if (m.ObjectId == ObjectId && m.ObjectType == ObjectType)
{ {
bDuplicate = true; bDuplicate = true;
break; break;
@@ -5944,15 +5944,17 @@ namespace AyaNovaQBI
if (!bDuplicate) if (!bDuplicate)
{ {
MisMatch m = new MisMatch(); MisMatch m = new MisMatch
m.mName = Name; {
m.mRootObjectID = RootObjectID; Name = Name,
m.mObjectType = RootObjectType; ObjectId = ObjectId,
m.mReason = Reason; ObjectType = ObjectType,
m.mAyaPrice = AyaPrice; Reason = Reason,
m.mQBPrice = QBPrice; AyaPrice = AyaPrice,
m.mWorkorderItemPartID = WorkorderItemPartID; QBPrice = QBPrice,
m.mQBListID = QBListID; WorkOrderItemPartID = WorkOrderItemPartID,
QBListID = QBListID,
}
Mismatches.Add(m); Mismatches.Add(m);
} }