This commit is contained in:
@@ -2300,72 +2300,54 @@ namespace AyaNova.PlugIn.V8
|
|||||||
{
|
{
|
||||||
if (!progress.KeepGoing) return;
|
if (!progress.KeepGoing) return;
|
||||||
|
|
||||||
progress.Append("Exporting inventory adjustment serial numbers");
|
progress.Append("Synchronizing serial numbers");
|
||||||
progress.Op("Start part inventory adjustment serial numbers export");
|
progress.Op("Start synch serials");
|
||||||
progress.SubOp("");
|
progress.SubOp("");
|
||||||
|
|
||||||
//Step 2: export the objects
|
//Step 2: export the objects
|
||||||
PartInventoryAdjustmentListDetailed pl = PartInventoryAdjustmentListDetailed.GetList(
|
PartInventoryList pl = PartInventoryList.GetList(
|
||||||
"<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?><GRIDCRITERIA> <COLUMNITEM CM=\"aPartInventoryAdjustment.AADJUSTMENTNUMBER\" UI=\"LT_PartInventoryAdjustment_Label_AdjustmentNumber\" PIN=\"0\" WIDTH=\"85\" SORT=\"ASC\" /> <COLUMNITEM CM=\"aPartInventoryAdjustment.aReasonForAdjustment\" UI=\"LT_PartInventoryAdjustment_Label_ReasonForAdjustment\" PIN=\"0\" WIDTH=\"106\" /> <COLUMNITEM CM=\"aPartInventoryAdjustment.aDateAdjusted\" UI=\"LT_PartInventoryAdjustment_Label_DateAdjusted\" PIN=\"0\" WIDTH=\"118\" /> <COLUMNITEM CM=\"aUser.aLastName\" UI=\"LT_Common_Label_Creator\" PIN=\"0\" WIDTH=\"141\" /> <COLUMNITEM CM=\"aPartWarehouse.aName\" UI=\"LT_O_PartWarehouse\" PIN=\"0\" WIDTH=\"127\" /> <COLUMNITEM CM=\"aPart.aName\" UI=\"LT_O_Part\" PIN=\"0\" WIDTH=\"142\" /> <COLUMNITEM CM=\"aPartInventoryAdjustmentItem.aQuantityAdjustment\" UI=\"LT_PartInventoryAdjustmentItem_Label_QuantityAdjustment\" PIN=\"0\" WIDTH=\"154\" /> <COLUMNITEM CM=\"aPartSerial.aSerialNumber\" UI=\"LT_Common_Label_SerialNumber\" PIN=\"0\" WIDTH=\"118\" /></GRIDCRITERIA>");
|
"<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?><GRIDCRITERIA> <COLUMNITEM CM=\"aPartWarehouse.aName\" UI=\"LT_O_PartWarehouse\" PIN=\"0\" WIDTH=\"144\" SORT=\"ASC\" /> <COLUMNITEM CM=\"aPart.aPartNumber\" UI=\"LT_O_Part\" PIN=\"0\" WIDTH=\"172\" /> <COLUMNITEM CM=\"aPartByWarehouseInventory.aQuantityOnHand\" UI=\"LT_PartByWarehouseInventory_Label_QuantityOnHand\" PIN=\"0\" WIDTH=\"81\" /> <COLUMNITEM CM=\"aPartByWarehouseInventory.aMinStockLevel\" UI=\"LT_PartByWarehouseInventory_Label_MinStockLevel\" PIN=\"0\" WIDTH=\"76\" /> <COLUMNITEM CM=\"AREORDERQUANTITY\" UI=\"LT_PartByWarehouseInventory_Label_ReorderQuantity\" PIN=\"0\" WIDTH=\"100\" /> <COLUMNITEM CM=\"aPartByWarehouseInventory.aQuantityOnOrder\" UI=\"LT_PartByWarehouseInventory_Label_QuantityOnOrder\" PIN=\"0\" WIDTH=\"179\" /> <COLUMNITEM CM=\"AVENDWHOLE.ANAME\" UI=\"LT_Part_Label_WholesalerID\" PIN=\"0\" WIDTH=\"104\" /> <COLUMNITEM CM=\"aPartCategory.aName\" UI=\"LT_O_PartCategory\" PIN=\"0\" WIDTH=\"139\" /> <COLUMNITEM CM=\"aPart.aActive\" UI=\"LT_Part_Label_Active\" PIN=\"0\" WIDTH=\"78\" /> <COLUMNITEM CM=\"aPart.aRetail\" UI=\"LT_Part_Label_Retail\" PIN=\"0\" WIDTH=\"79\" /> <COLUMNITEM CM=\"aPart.aCost\" UI=\"LT_Part_Label_Cost\" PIN=\"0\" WIDTH=\"79\" /></GRIDCRITERIA>");
|
||||||
|
|
||||||
foreach (PartInventoryAdjustmentListDetailed.PartInventoryAdjustmentListDetailedInfo i in pl)
|
foreach (PartInventoryList.PartInventoryListInfo i in pl)
|
||||||
{
|
{
|
||||||
if (!progress.KeepGoing) return;
|
if (!progress.KeepGoing) return;
|
||||||
|
|
||||||
//if no serial then continue to the next one until there is
|
//if no serial then continue to the next one until there is
|
||||||
if (string.IsNullOrWhiteSpace(i.LT_Common_Label_SerialNumber)) continue;
|
if (i.LT_PartSerial_Label_List.Count == 0) continue;
|
||||||
if (i.LT_PartInventoryAdjustmentItem_Label_QuantityAdjustment == 0) continue;//don't know if this can be a thing but better safe than sorry
|
|
||||||
|
|
||||||
long partNumber = await Getv7v8IdMap(i.LT_O_Part.Value, RootObjectTypes.Part, false, false);
|
long partNumber = await Getv7v8IdMap(i.LT_O_Part.Value, RootObjectTypes.Part, false, false);
|
||||||
if (partNumber == 0)
|
if (partNumber == 0)
|
||||||
{
|
{
|
||||||
//log here or skip it as old adjustments could have invalid parts or not exported
|
progress.Append("Part inventory part missing; skipping serial number synchronization: PartID " + i.LT_O_Part.Value.ToString());
|
||||||
//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());
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//get the part serial record
|
//get the part serial record
|
||||||
|
|
||||||
|
|
||||||
var a = await util.GetAsync("part/serials/" + partNumber.ToString());
|
var a = await util.GetAsync("part/serials/" + partNumber.ToString());
|
||||||
|
|
||||||
|
|
||||||
dynamic d = a.ObjectResponse["data"];
|
dynamic d = a.ObjectResponse["data"];
|
||||||
|
var v = (JArray)d;
|
||||||
//todo: if quantity adjustment is negative (ignore amount it's whack) then remove the one serial number from the collection
|
bool hasUpdate = false;
|
||||||
//and save if found
|
foreach (string s in i.LT_PartSerial_Label_List)
|
||||||
//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)
|
|
||||||
{
|
{
|
||||||
foreach (JObject j in d.Children())
|
bool notFound=true;
|
||||||
|
foreach (JValue j in v)
|
||||||
{
|
{
|
||||||
if (j.Value<string>() == i.LT_Common_Label_SerialNumber)
|
if (j.Value<string>() == s)
|
||||||
{
|
{
|
||||||
d.Remove(j);
|
notFound = false;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (notFound)
|
||||||
|
{
|
||||||
|
hasUpdate = true;
|
||||||
|
dynamic dItem = new JObject();
|
||||||
|
dItem = s;
|
||||||
|
d.Add(dItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
if (hasUpdate)
|
||||||
{
|
await util.PutAsync("part/serials/" + partNumber, d);
|
||||||
dItem = i.LT_Common_Label_SerialNumber;
|
}//end of inventory item loop
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endregion Inventory adjustment serials
|
#endregion Synchronize serials
|
||||||
|
|
||||||
|
|
||||||
#region Task groups
|
#region Task groups
|
||||||
|
|||||||
Reference in New Issue
Block a user