diff --git a/AyaNovaQBI/MainForm.cs b/AyaNovaQBI/MainForm.cs index 980a51e..8b8c1af 100644 --- a/AyaNovaQBI/MainForm.cs +++ b/AyaNovaQBI/MainForm.cs @@ -128,7 +128,7 @@ namespace AyaNovaQBI 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(); if (m.ShowDialog() == DialogResult.Abort) diff --git a/AyaNovaQBI/WorkOrder.cs b/AyaNovaQBI/WorkOrder.cs index 97fcd4c..6529d31 100644 --- a/AyaNovaQBI/WorkOrder.cs +++ b/AyaNovaQBI/WorkOrder.cs @@ -85,7 +85,7 @@ namespace AyaNovaQBI public decimal? Longitude { get; set; } public List Items { get; set; } = new List(); - public List States { get; set; } = new List(); + // public List States { get; set; } = new List(); //UTILITY FIELDS diff --git a/AyaNovaQBI/WorkOrderItem.cs b/AyaNovaQBI/WorkOrderItem.cs index 23fb782..5796373 100644 --- a/AyaNovaQBI/WorkOrderItem.cs +++ b/AyaNovaQBI/WorkOrderItem.cs @@ -50,11 +50,11 @@ namespace AyaNovaQBI public List Labors { get; set; } = new List(); public List Loans { get; set; } = new List(); public List Parts { get; set; } = new List(); - public List PartRequests { get; set; } = new List(); - public List ScheduledUsers { get; set; } = new List(); - public List Tasks { get; set; } = new List(); + // public List PartRequests { get; set; } = new List(); + // public List ScheduledUsers { get; set; } = new List(); + // public List Tasks { get; set; } = new List(); public List Travels { get; set; } = new List(); - public List Units { get; set; } = new List(); + // public List Units { get; set; } = new List(); public List OutsideServices { get; set; } = new List(); } } diff --git a/AyaNovaQBI/util.cs b/AyaNovaQBI/util.cs index 3d905cd..e9ff569 100644 --- a/AyaNovaQBI/util.cs +++ b/AyaNovaQBI/util.cs @@ -5676,10 +5676,10 @@ namespace AyaNovaQBI public long ObjectId { get; set; } public AyaType ObjectType { get; set; } public string Name { get; set; } - public MisMatchReason mReason { get; set; } + public MisMatchReason Reason { get; set; } public decimal AyaPrice { get; set; } public decimal QBPrice { get; set; } - public long WorkorderItemPartId { get; set; } + public long WorkOrderItemPartId { get; set; } public string QBListID { get; set; } } @@ -5704,205 +5704,205 @@ namespace AyaNovaQBI bool bSomethingToInvoice = false; - Workorder w = Workorder.GetItem(WorkorderID); + //WorkOrder w = Workorder.GetItem(WorkorderID); - //Client ok? - if (!QBIntegration.Items.Any(z=>z.AType==AyaType.Customer && z.ObjectId==w.CustomerId)) - { - bReturn = false; - AddMisMatch(AyaClientList[w.ClientID].Name, w.ClientID, AyaType.Customer, MisMatchReason.NotLinkedToQB, MisMatches); - } + ////Client ok? + //if (!QBIntegration.Items.Any(z=>z.AType==AyaType.Customer && z.ObjectId==w.CustomerId)) + //{ + // bReturn = false; + // AddMisMatch(AyaClientList[w.ClientID].Name, w.ClientID, AyaType.Customer, MisMatchReason.NotLinkedToQB, MisMatches); + //} - //Service rates: - foreach (WorkorderItem wi in w.WorkorderItems) - { - #region Labor - foreach (WorkorderItemLabor wl in wi.Labors) - { + ////Service rates: + //foreach (WorkorderItem wi in w.WorkorderItems) + //{ + // #region Labor + // foreach (WorkorderItemLabor wl in wi.Labors) + // { - //If there's *any* labor then there is something to invoice - bSomethingToInvoice = true; + // //If there's *any* labor then there is something to invoice + // bSomethingToInvoice = true; - //Check that rate isn't actually guid.empty - //it's possible that some users have not selected a rate on the workorder - 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" + - "This is a serious problem for QBI and needs to be rectified before QBI can be used.\r\n"); + // //Check that rate isn't actually guid.empty + // //it's possible that some users have not selected a rate on the workorder + // 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" + + // "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)) - { - bReturn = false; - AddMisMatch(AyaRateList[wl.ServiceRateID].Name, wl.ServiceRateID, RootObjectTypes.Rate, MisMatchReason.NotLinkedToQB, MisMatches); + // if (!QBI.Maps.Contains(wl.ServiceRateID)) + // { + // bReturn = false; + // AddMisMatch(AyaRateList[wl.ServiceRateID].Name, wl.ServiceRateID, RootObjectTypes.Rate, MisMatchReason.NotLinkedToQB, MisMatches); - } + // } - } - #endregion + // } + // #endregion - #region Travel - foreach (WorkorderItemTravel wt in wi.Travels) - { - //If there's *any* travel then there is something to invoice - bSomethingToInvoice = true; + // #region Travel + // foreach (WorkorderItemTravel wt in wi.Travels) + // { + // //If there's *any* travel then there is something to invoice + // bSomethingToInvoice = true; - //Check that rate isn't actually guid.empty - //it's possible that some users have not selected a rate on the workorder - 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" + - "This is a serious problem for QBI and needs to be rectified before QBI can be used.\r\n"); + // //Check that rate isn't actually guid.empty + // //it's possible that some users have not selected a rate on the workorder + // 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" + + // "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)) - { - bReturn = false; - AddMisMatch(AyaRateList[wt.TravelRateID].Name, wt.TravelRateID, RootObjectTypes.Rate, MisMatchReason.NotLinkedToQB, MisMatches); + // if (!QBI.Maps.Contains(wt.TravelRateID)) + // { + // bReturn = false; + // AddMisMatch(AyaRateList[wt.TravelRateID].Name, wt.TravelRateID, RootObjectTypes.Rate, MisMatchReason.NotLinkedToQB, MisMatches); - } + // } - } - #endregion + // } + // #endregion - #region Parts - foreach (WorkorderItemPart wp in wi.Parts) - { - //If there's *any* parts then there is something to invoice - bSomethingToInvoice = true; + // #region Parts + // foreach (WorkorderItemPart wp in wi.Parts) + // { + // //If there's *any* parts then there is something to invoice + // bSomethingToInvoice = true; - //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) - { - bReturn = false; - //Changed: 21-June-2006 to use display formatted name - AddMisMatch(AyaPartList[wp.PartID].DisplayName(Util.GlobalSettings.DefaultPartDisplayFormat), wp.PartID, RootObjectTypes.Part, MisMatchReason.NotLinkedToQB, MisMatches); + // //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) + // { + // bReturn = false; + // //Changed: 21-June-2006 to use display formatted name + // AddMisMatch(AyaPartList[wp.PartID].DisplayName(Util.GlobalSettings.DefaultPartDisplayFormat), wp.PartID, RootObjectTypes.Part, MisMatchReason.NotLinkedToQB, MisMatches); - } - else - { - //check the price - if (!PriceOverrides.Contains(wp.ID)) - { + // } + // else + // { + // //check the price + // 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----------------- - string disco = ""; - //Added:20-July-2006 to incorporate discounts on parts into qb invoice - decimal charge; + // //------------DISCOUNT----------------- + // string disco = ""; + // //Added:20-July-2006 to incorporate discounts on parts into qb invoice + // decimal charge; - //Changed: 18-Nov-2006 CASE 158 - //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 - charge = decimal.Round(wp.Price, 2, MidpointRounding.AwayFromZero); - charge = charge - (decimal.Round(charge * wp.Discount, 2, MidpointRounding.AwayFromZero)); - if (wp.Discount != 0) - { - disco = " (Price " + wp.Price.ToString("c") + " discounted on workorder " + wp.Discount.ToString("p") + ") \r\n"; - } + // //Changed: 18-Nov-2006 CASE 158 + // //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 + // charge = decimal.Round(wp.Price, 2, MidpointRounding.AwayFromZero); + // charge = charge - (decimal.Round(charge * wp.Discount, 2, MidpointRounding.AwayFromZero)); + // if (wp.Discount != 0) + // { + // 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 - if (charge != qbPrice) - { - 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 - wp.PartID, RootObjectTypes.Part, MisMatchReason.PriceDifferent, MisMatches, qbPrice, charge, wp.ID, - QBI.Maps[wp.PartID].ForeignID); + // //It's a match, let's see if the price matches as well + // if (charge != qbPrice) + // { + // 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 + // wp.PartID, RootObjectTypes.Part, MisMatchReason.PriceDifferent, MisMatches, qbPrice, charge, wp.ID, + // QBI.Maps[wp.PartID].ForeignID); - } - } - } + // } + // } + // } - } - #endregion + // } + // #endregion - #region Outside service charges + // #region Outside service charges - if (wi.HasOutsideService) - { - if (wi.OutsideService.RepairPrice != 0 || wi.OutsideService.ShippingPrice != 0) - { - bSomethingToInvoice = true; - //there is something billable, just need to make sure - //that there is a QB charge defined for outside service - if (QDat.OutsideServiceChargeAs == null || - QDat.OutsideServiceChargeAs == "" || - !QBItems.Rows.Contains(QDat.OutsideServiceChargeAs)) - { - bReturn = false; - AddMisMatch("Outside service", Guid.Empty, RootObjectTypes.WorkorderItemOutsideService, MisMatchReason.NotLinkedToQB, MisMatches); + // if (wi.HasOutsideService) + // { + // if (wi.OutsideService.RepairPrice != 0 || wi.OutsideService.ShippingPrice != 0) + // { + // bSomethingToInvoice = true; + // //there is something billable, just need to make sure + // //that there is a QB charge defined for outside service + // if (QDat.OutsideServiceChargeAs == null || + // QDat.OutsideServiceChargeAs == "" || + // !QBItems.Rows.Contains(QDat.OutsideServiceChargeAs)) + // { + // bReturn = false; + // 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) - { - foreach (WorkorderItemLoan wil in wi.Loans) - { + // if (wi.HasLoans) + // { + // foreach (WorkorderItemLoan wil in wi.Loans) + // { - if (wil.Charges != 0) - { - //case 772 - bSomethingToInvoice = true; + // if (wil.Charges != 0) + // { + // //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 (QDat.WorkorderItemLoanChargeAs == null || - QDat.WorkorderItemLoanChargeAs == "" || - !QBItems.Rows.Contains(QDat.WorkorderItemLoanChargeAs)) - { - bReturn = false; - AddMisMatch("Workorder item loan", Guid.Empty, RootObjectTypes.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 (QDat.WorkorderItemLoanChargeAs == null || + // QDat.WorkorderItemLoanChargeAs == "" || + // !QBItems.Rows.Contains(QDat.WorkorderItemLoanChargeAs)) + // { + // bReturn = false; + // AddMisMatch("Workorder item loan", Guid.Empty, RootObjectTypes.WorkorderItemLoan, MisMatchReason.NotLinkedToQB, MisMatches); + // break; - } - } - } - } - #endregion + // } + // } + // } + // } + // #endregion - #region Workorder item misc expenses + // #region Workorder item misc expenses - if (wi.HasExpenses) - { - foreach (WorkorderItemMiscExpense wie in wi.Expenses) - { + // if (wi.HasExpenses) + // { + // foreach (WorkorderItemMiscExpense wie in wi.Expenses) + // { - 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 (QDat.MiscExpenseChargeAs == null || - QDat.MiscExpenseChargeAs == "" || - !QBItems.Rows.Contains(QDat.MiscExpenseChargeAs)) - { - bReturn = false; - AddMisMatch("Workorder item expense", Guid.Empty, RootObjectTypes.WorkorderItemMiscExpense, MisMatchReason.NotLinkedToQB, MisMatches); - break; + // 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 (QDat.MiscExpenseChargeAs == null || + // QDat.MiscExpenseChargeAs == "" || + // !QBItems.Rows.Contains(QDat.MiscExpenseChargeAs)) + // { + // bReturn = false; + // AddMisMatch("Workorder item expense", Guid.Empty, RootObjectTypes.WorkorderItemMiscExpense, MisMatchReason.NotLinkedToQB, MisMatches); + // break; - } - } - } - } - #endregion + // } + // } + // } + // } + // #endregion - }//workorder items loop + //}//workorder items loop - //If there are no mismatches so far, - //maybe it's because it's got nothing to invoice? - if (bReturn && !bSomethingToInvoice) - { - bReturn = false; - AddMisMatch("WO: " + w.WorkorderService.ServiceNumber.ToString() + " - Nothing chargeable on it, will not be invoiced", - Guid.Empty, RootObjectTypes.Nothing, MisMatchReason.NothingToInvoice, MisMatches); + ////If there are no mismatches so far, + ////maybe it's because it's got nothing to invoice? + //if (bReturn && !bSomethingToInvoice) + //{ + // bReturn = false; + // AddMisMatch("WO: " + w.WorkorderService.ServiceNumber.ToString() + " - Nothing chargeable on it, will not be invoiced", + // Guid.Empty, RootObjectTypes.Nothing, MisMatchReason.NothingToInvoice, MisMatches); - } + //} 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, - MisMatchReason Reason, ArrayList Mismatches, decimal QBPrice, decimal AyaPrice, Guid WorkorderItemPartID, string QBListID) + private static void AddMisMatch(string Name, long ObjectId, AyaType ObjectType, + MisMatchReason Reason, ArrayList Mismatches, decimal QBPrice, decimal AyaPrice, long WorkOrderItemPartID, string QBListID) { bool bDuplicate = false; //scan through list of existing mismatches, @@ -5934,7 +5934,7 @@ namespace AyaNovaQBI //Have to check ID and type here because for outside service //and loans and misc expenses the id is always empty so type is //the only way to differentiate - if (m.RootObjectID == RootObjectID && m.ObjectType == RootObjectType) + if (m.ObjectId == ObjectId && m.ObjectType == ObjectType) { bDuplicate = true; break; @@ -5944,15 +5944,17 @@ namespace AyaNovaQBI if (!bDuplicate) { - MisMatch m = new MisMatch(); - m.mName = Name; - m.mRootObjectID = RootObjectID; - m.mObjectType = RootObjectType; - m.mReason = Reason; - m.mAyaPrice = AyaPrice; - m.mQBPrice = QBPrice; - m.mWorkorderItemPartID = WorkorderItemPartID; - m.mQBListID = QBListID; + MisMatch m = new MisMatch + { + Name = Name, + ObjectId = ObjectId, + ObjectType = ObjectType, + Reason = Reason, + AyaPrice = AyaPrice, + QBPrice = QBPrice, + WorkOrderItemPartID = WorkOrderItemPartID, + QBListID = QBListID, + } Mismatches.Add(m); }