From 41d8f0c5dd7bc07b61f8b25e6a5b518e8364ad2c Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 12 Aug 2021 17:24:20 +0000 Subject: [PATCH] --- source/Plugins/AyaNova.Plugin.V8/V8.cs | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index f35202e..aa1de00 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -265,7 +265,7 @@ namespace AyaNova.PlugIn.V8 private long ClosedWorkOrderStatus = 0; private long ServiceCompletedWorkOrderStatus = 0; - private long UntrackedV7PartId = 0;//used when there is no part id on a workorderitempart record + private long UnknownV7PartId = 0;//used when there is no part id on a workorderitempart record /// /// Dump the objects into a temporary directory as a series of JSON files @@ -1616,19 +1616,19 @@ namespace AyaNova.PlugIn.V8 //create a part just to hold untracked parts from v7 which are partid guid.empty on workorderitempart records which was allowed in v7 but not in v8 dynamic dx = new JObject(); - dx.name = "v7 untracked / missing part"; - dx.partNumber = GetUniqueName("untracked"); + dx.name = "v8 Migrate untracked / missing v7 part"; + dx.partNumber = GetUniqueName("v8 Migrate part"); progress.Op(ObjectTypeName + " " + dx.partNumber + " " + dx.name); dx.cost = 0; dx.retail = 0; dx.uPC = string.Empty; dx.unitOfMeasure = "each"; dx.active = true; - dx.notes = "This part created by v8 migrate plugin so work order item part records with no selected part can be migrated to v8\nv7 allowed work order item part entry without a corresponding Part record but v8 does not\nThis part stands in for those missing parts from v7\nThis record can be deleted after migration if no work order item parts rely on it"; + dx.notes = "This part created by v8 migrate plugin so work order item part records with no (or no valid) selected part can be migrated to v8\nv7 allowed work order item part entry without a corresponding Part record but v8 does not\nThis part stands in for those missing parts from v7\nThis record can be deleted after migration if no work order item parts rely on it"; List dxtags = new List(); AddImportTag(dxtags); SetTags(dx, dxtags); - UntrackedV7PartId = util.IdFromResponse(await util.PostAsync("part", dx.ToString())); + UnknownV7PartId = util.IdFromResponse(await util.PostAsync("part", dx.ToString())); } #endregion Parts @@ -2730,22 +2730,19 @@ namespace AyaNova.PlugIn.V8 foreach (WorkorderItemPart wip in wi.Parts) { progress.Op("WorkorderItemPart " + wip.ID.ToString()); - dynamic dwip = new JObject(); dwip.workOrderId = RavenId; dwip.workorderItemId = ravenwoitemid; dwip.quantity = wip.Quantity; - if (wip.PartID == Guid.Empty) + var tryPartId = Getv7v8IdMapNullOk(wip.PartID); + if (tryPartId==null) { - dwip.partId = UntrackedV7PartId; - if (wip.Quantity == 0 && string.IsNullOrWhiteSpace(wip.Description)) - { - //no part record, no quantity, no text at all, just skip it - continue; - } + dwip.partId = UnknownV7PartId; + if (wip.Quantity == 0 && string.IsNullOrWhiteSpace(wip.Description)) + continue; //no part record, no quantity, no text at all, just skip it } else - dwip.partId = Getv7v8IdMap(wip.PartID, "part for workorder item part"); + dwip.partId = tryPartId; dwip.partWarehouseId = Getv7v8IdMap(wip.PartWarehouseID, "warehouse"); dwip.taxPartSaleId = Getv7v8IdMapNullOk(wip.TaxPartSaleID); dwip.priceOverride = wip.Price; @@ -2754,7 +2751,6 @@ namespace AyaNova.PlugIn.V8 dwip.description = wip.Description; if (wip.PartSerialID != Guid.Empty) dwip.serials = PartSerial.GetSerialNumberFromPartSerialID(wip.PartSerialID); - await util.PostAsync("workorder/items/parts", dwip.ToString()); }