This commit is contained in:
2021-06-04 15:08:21 +00:00
parent d6792262cb
commit c936ff5e3e
2 changed files with 54 additions and 44 deletions

View File

@@ -8,5 +8,5 @@ Inventory changes from v7 with new workorder system
No "Used in service", now Parts are consumed immediately from inventory when selected on workorder and saved No "Used in service", now Parts are consumed immediately from inventory when selected on workorder and saved
Work order item part records consume or return inventory immediately upon save or delete or changes Work order item part records consume or return inventory immediately upon save or delete or changes
Serial numbers are likewise immediately consumed / returned to the pool upon edits to workorder item part records Serial numbers are likewise immediately consumed / returned to the pool upon edits to workorder item part records
A zero quantity part will be considered a "placeholder" and will neither affect inventory nor serial numbers until a quantity is entered and saved

View File

@@ -3454,7 +3454,7 @@ namespace AyaNova.Biz
//CREATED, HANDLE INVENTORY / CONSUME SERIALS //CREATED, HANDLE INVENTORY / CONSUME SERIALS
if (ayaEvent == AyaEvent.Created) if (ayaEvent == AyaEvent.Created && newObj.Quantity != 0)//allow zero quantity parts on workorder as placeholder, serials will not be consumed
{ {
dtInternalPartInventory pi = dtInternalPartInventory pi =
new dtInternalPartInventory new dtInternalPartInventory
@@ -3492,10 +3492,12 @@ namespace AyaNova.Biz
//UPDATED, HANDLE INVENTORY / UPDATE SERIALS AS REQUIRED //UPDATED, HANDLE INVENTORY / UPDATE SERIALS AS REQUIRED
if (ayaEvent == AyaEvent.Modified) if (ayaEvent == AyaEvent.Modified)
{ {
//determine if any changes affecting inventory //INVENTORY
if (newObj.PartId != oldObj.PartId || newObj.Quantity != oldObj.Quantity) if (newObj.PartId != oldObj.PartId || newObj.Quantity != oldObj.Quantity)
{ {
//OUT with the old //OUT with the old
if (oldObj.Quantity != 0)//zero quantity doesn't affect inventory or serials
{
dtInternalPartInventory piOld = new dtInternalPartInventory dtInternalPartInventory piOld = new dtInternalPartInventory
{ {
PartId = oldObj.PartId, PartId = oldObj.PartId,
@@ -3515,8 +3517,12 @@ namespace AyaNova.Biz
if (!string.IsNullOrWhiteSpace(oldObj.Serials)) if (!string.IsNullOrWhiteSpace(oldObj.Serials))
await PartBiz.AppendSerialsAsync(oldObj.PartId, oldObj.Serials, ct, UserId); await PartBiz.AppendSerialsAsync(oldObj.PartId, oldObj.Serials, ct, UserId);
} }
}
//IN with the new //IN with the new
if (newObj.Quantity != 0)
{//NOTE: zero quantity is considered to be a placeholder and no serials will be consumed, nor inventory affected
dtInternalPartInventory piNew = new dtInternalPartInventory dtInternalPartInventory piNew = new dtInternalPartInventory
{ {
PartId = newObj.PartId, PartId = newObj.PartId,
@@ -3538,22 +3544,26 @@ namespace AyaNova.Biz
await PartBiz.RemoveSerialsAsync(newObj.PartId, newObj.Serials, ct, UserId); await PartBiz.RemoveSerialsAsync(newObj.PartId, newObj.Serials, ct, UserId);
} }
} }
else if (newObj.Serials != oldObj.Serials) }
//SERIALS
if (newObj.Serials != oldObj.Serials)
{ {
//Only a serial number adjustment so in and out all serials to be safe and not try to parse too closely //NOTE: zero quantity is considered to be a placeholder and no serials will be consumed (hence not returned either)
//return serial numbers to part //return serial numbers to part
if (!string.IsNullOrWhiteSpace(oldObj.Serials)) if (oldObj.Quantity != 0 && !string.IsNullOrWhiteSpace(oldObj.Serials))
await PartBiz.AppendSerialsAsync(oldObj.PartId, oldObj.Serials, ct, UserId); await PartBiz.AppendSerialsAsync(oldObj.PartId, oldObj.Serials, ct, UserId);
//Consume serial numbers from part //Consume serial numbers from part
if (!string.IsNullOrWhiteSpace(newObj.Serials)) if (newObj.Quantity != 0 && !string.IsNullOrWhiteSpace(newObj.Serials))
await PartBiz.RemoveSerialsAsync(newObj.PartId, newObj.Serials, ct, UserId); await PartBiz.RemoveSerialsAsync(newObj.PartId, newObj.Serials, ct, UserId);
} }
} }
} }