diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs
index 1a279f5..d138508 100644
--- a/source/Plugins/AyaNova.Plugin.V8/V8.cs
+++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs
@@ -2300,72 +2300,54 @@ namespace AyaNova.PlugIn.V8
{
if (!progress.KeepGoing) return;
- progress.Append("Exporting inventory adjustment serial numbers");
- progress.Op("Start part inventory adjustment serial numbers export");
+ progress.Append("Synchronizing serial numbers");
+ progress.Op("Start synch serials");
progress.SubOp("");
//Step 2: export the objects
- PartInventoryAdjustmentListDetailed pl = PartInventoryAdjustmentListDetailed.GetList(
- " ");
+ PartInventoryList pl = PartInventoryList.GetList(
+ " ");
- foreach (PartInventoryAdjustmentListDetailed.PartInventoryAdjustmentListDetailedInfo i in pl)
+ foreach (PartInventoryList.PartInventoryListInfo i in pl)
{
if (!progress.KeepGoing) return;
-
//if no serial then continue to the next one until there is
- if (string.IsNullOrWhiteSpace(i.LT_Common_Label_SerialNumber)) continue;
- if (i.LT_PartInventoryAdjustmentItem_Label_QuantityAdjustment == 0) continue;//don't know if this can be a thing but better safe than sorry
-
+ if (i.LT_PartSerial_Label_List.Count == 0) continue;
long partNumber = await Getv7v8IdMap(i.LT_O_Part.Value, RootObjectTypes.Part, false, false);
if (partNumber == 0)
{
- //log here or skip it as old adjustments could have invalid parts or not exported
- //maybe append just to be safe
- progress.Append("Part inventory adjustment part missing; skipping serial number '" + i.LT_Common_Label_SerialNumber + "' export: PartID " + i.LT_O_Part.Value.ToString());
+ progress.Append("Part inventory part missing; skipping serial number synchronization: PartID " + i.LT_O_Part.Value.ToString());
continue;
}
//get the part serial record
-
-
var a = await util.GetAsync("part/serials/" + partNumber.ToString());
-
-
dynamic d = a.ObjectResponse["data"];
-
- //todo: if quantity adjustment is negative (ignore amount it's whack) then remove the one serial number from the collection
- //and save if found
- //if the quantity is positive then add the one serial number to the collection and save
-
- dynamic dItem = new JObject();
-
- if (i.LT_PartInventoryAdjustmentItem_Label_QuantityAdjustment < 0)
+ var v = (JArray)d;
+ bool hasUpdate = false;
+ foreach (string s in i.LT_PartSerial_Label_List)
{
- foreach (JObject j in d.Children())
+ bool notFound=true;
+ foreach (JValue j in v)
{
- if (j.Value() == i.LT_Common_Label_SerialNumber)
+ if (j.Value() == s)
{
- d.Remove(j);
+ notFound = false;
+ continue;
}
}
+ if (notFound)
+ {
+ hasUpdate = true;
+ dynamic dItem = new JObject();
+ dItem = s;
+ d.Add(dItem);
+ }
}
- else
- {
- dItem = i.LT_Common_Label_SerialNumber;
- d.Add(dItem);
- }
- //list should only have a serial number in it if it's staying, removed ones are removed entirely from the list as well due to quirk
- //so the list should only have one serial per part per adjustment item in the list in theory and no negative removed ones
- //get new part number
- //get existing serials because the same part may be adjusted multiple times
- //PUT at route /part/serials/v8partid array of strings which are *all* serial numbers for that part (warehouse no longer relevant)
-
- await util.PutAsync("part/serials/" + partNumber, d);
-
- }//end of adjustmentitem loop
-
-
+ if (hasUpdate)
+ await util.PutAsync("part/serials/" + partNumber, d);
+ }//end of inventory item loop
}
- #endregion Inventory adjustment serials
+ #endregion Synchronize serials
#region Task groups