This commit is contained in:
2021-08-16 23:27:44 +00:00
parent b8d1e82a04
commit c4cd76b5f2

View File

@@ -3685,17 +3685,28 @@ namespace AyaNova.PlugIn.V8
if (dMinStockLevel > 0)
{
JObject jsa = (await util.GetAsync("part/stock-levels/" + v8PartId)).ObjectResponse;
foreach (JObject js in jsa["data"])
bool setMinStock = false;
JArray ja=(JArray)jsa["data"];
foreach (JObject js in ja)
{
if ((long)js["partWarehouseId"] == (long)v8o["partWarehouseId"])
{
js["minimumQuantity"] = dMinStockLevel;
await util.PostAsync("part/stock-levels/" + v8PartId, jsa["data"].ToString());
setMinStock = true;
}
break;
}
if (!setMinStock)
{
//add a line for this record as there is no existing one (may be none at all but that's not a concern here)
dynamic dnew = new JObject();
dnew.partWarehouseId = (long)v8o["partWarehouseId"];
dnew.partId = v8PartId;
dnew.minimumQuantity = dMinStockLevel;
ja.Add(dnew);
}
await util.PutAsync("part/stock-levels/" + v8PartId, ja.ToString());
}