diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index 8a46a90..ee6bee4 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -1809,7 +1809,7 @@ namespace AyaNova.PlugIn.V8 dx.retail = 0; dx.uPC = string.Empty; dx.unitOfMeasure = "each"; - dx.active = true; + dx.active = false; 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); @@ -2340,7 +2340,7 @@ namespace AyaNova.PlugIn.V8 //Event log fixup if (c.ParentID == Guid.Empty && c.ReplacedByUnitID == Guid.Empty) await util.EventLog(util.AyaType.Unit, RavenId, await Getv7v8IdMap(c.Creator, RootObjectTypes.User), await Getv7v8IdMap(c.Modifier, RootObjectTypes.User), c.Created, c.Modified); - + } //################# Now loop through the units again and set parent and replaced ID's @@ -2376,7 +2376,7 @@ namespace AyaNova.PlugIn.V8 progress.Op("Start Unit meter readings export"); progress.SubOp(""); - + //Step 2: export the objects UnitPickList pl = UnitPickList.GetListOfAll(); progress.Append("Checking " + pl.Count.ToString() + " units for exportable meter readings"); @@ -3241,11 +3241,11 @@ namespace AyaNova.PlugIn.V8 List wiutags = new List(); TagFromv7Guid(wi.WorkorderItemUnitServiceTypeID, wiutags); SetTags(dwiu, wiutags); - long v8woitemunitid= util.IdFromResponse(await util.PostAsync("workorder/items/units", dwiu.ToString())); + long v8woitemunitid = util.IdFromResponse(await util.PostAsync("workorder/items/units", dwiu.ToString())); //Map used for unit meter reading later, this is the ONLY use for this //The map required is v7woitemid to v7woitemunitid for meter reading so that's what this saves //any other use would be broken like if it needed the v8woitemid for something in future - Addv7v8IdMap(wi.ID, v8woitemunitid); + Addv7v8IdMap(wi.ID, v8woitemunitid); } @@ -4324,7 +4324,13 @@ namespace AyaNova.PlugIn.V8 d.userId = V7ToV8IdMap[c.SourceID]; d.assignedByUserId = await Getv7v8IdMap(c.Creator, RootObjectTypes.User); d.objectId = V7ToV8IdMap[c.FollowID]; - d.objectType = util.RootObjectToAyaType(c.FollowType); + if (c.FollowType == RootObjectTypes.Workorder) + { + //going to need to be way more specific here to map to v8 + Workorder.getty + } + else + d.objectType = util.RootObjectToAyaType(c.FollowType); SetTags(d, tags); progress.Op("FollowUp " + c.ID.ToString()); var rMainObject = await util.PostAsync("review", d); @@ -4627,19 +4633,28 @@ namespace AyaNova.PlugIn.V8 await util.PutAsync("part/stock-levels/" + v8PartId, ja);//ja.ToString()); } - - } - //find matching v7 item and adjust - //no v7 item then set to zeros - } - //iterate the parts - //use v7 partinventoryvalues fetcher - //use v8 part/latest-inventory/partid route to get same from v8 - //where they differ issue an adjustment to v8 for each part/warehouse combo - //also make a partstockelvel entry if required + //Clear out inventory for special unknown missing part created in v8 for potentially missing parts + { + JObject v8inv = (await util.GetAsync("part/latest-inventory/" + UnknownV7PartId)).ObjectResponse; + //iterate v8 inventory + foreach (JObject v8o in v8inv["data"]) + { + decimal dAdjust = 0; + decimal v8OnHand = (decimal)v8o["balance"]; + dAdjust = v8OnHand * -1; + { + dynamic di = new JObject(); + di.description = "v8 migrate synchronize inventory"; + di.partId = UnknownV7PartId; + di.partWarehouseId = (long)v8o["partWarehouseId"]; + di.quantity = dAdjust; + await util.PostAsync("part-inventory", di.ToString()); + } + } + } } #endregion sync inventory diff --git a/source/Plugins/AyaNova.Plugin.V8/util.cs b/source/Plugins/AyaNova.Plugin.V8/util.cs index 7d57928..a4fb361 100644 --- a/source/Plugins/AyaNova.Plugin.V8/util.cs +++ b/source/Plugins/AyaNova.Plugin.V8/util.cs @@ -646,6 +646,18 @@ namespace AyaNova.PlugIn.V8 default: throw new NotImplementedException("V8:util:RootObjectToAyaType -> type " + rot.ToString() + "," + specificWoType.ToString() + " is not coded yet"); } + case biz.RootObjectTypes.Workorder: + switch (specificWoType) + { + case biz.WorkorderTypes.PreventiveMaintenance: + return AyaType.PM; + case biz.WorkorderTypes.Quote: + return AyaType.Quote; + case biz.WorkorderTypes.Service: + return AyaType.WorkOrder; + default: + throw new NotImplementedException("V8:util:RootObjectToAyaType -> type " + rot.ToString() + ", needs specific wotype which was not provided"); + } case biz.RootObjectTypes.Memo: return AyaType.Memo; @@ -668,7 +680,7 @@ namespace AyaNova.PlugIn.V8 default: - throw new NotImplementedException("V8:util:RootObjectToAyaType -> type " + rot.ToString() + " is not coded yet"); + throw new NotImplementedException("V8:util:RootObjectToAyaType -> v7 type " + rot.ToString() + " is not coded"); } } ///