This commit is contained in:
@@ -403,11 +403,6 @@ namespace AyaNova.Biz
|
|||||||
//
|
//
|
||||||
private async Task BizActionsAsync(AyaEvent ayaEvent, PurchaseOrder newObj, PurchaseOrder oldObj, IDbContextTransaction transaction)
|
private async Task BizActionsAsync(AyaEvent ayaEvent, PurchaseOrder newObj, PurchaseOrder oldObj, IDbContextTransaction transaction)
|
||||||
{
|
{
|
||||||
//MIGRATE_OUTSTANDING - woitempart request update
|
|
||||||
//if received on woitempartrequest then need to update woitempartrequest (notification separate not a concern here)
|
|
||||||
//if workorderitempartrequest item removed, need to fixup woitempartrequest
|
|
||||||
//BUT *only* if the woitempartrequest still exists and isn't completed already
|
|
||||||
|
|
||||||
|
|
||||||
//Get inventory object for updating
|
//Get inventory object for updating
|
||||||
PartInventoryBiz pib = new PartInventoryBiz(ct, UserId, UserTranslationId, CurrentUserRoles);
|
PartInventoryBiz pib = new PartInventoryBiz(ct, UserId, UserTranslationId, CurrentUserRoles);
|
||||||
@@ -433,6 +428,9 @@ namespace AyaNova.Biz
|
|||||||
AddError(ApiErrorCode.API_SERVER_ERROR, "generalerror", $"Error updating inventory ({i.Description}):{pib.GetErrorsAsString()}");
|
AddError(ApiErrorCode.API_SERVER_ERROR, "generalerror", $"Error updating inventory ({i.Description}):{pib.GetErrorsAsString()}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//might have contributed serials so remove them here, handles empty serials so no issue calling this
|
||||||
|
await PartBiz.RemoveSerialsAsync(poItem.PartId, poItem.Serials, ct, UserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var poItem in oldObj.Items)
|
foreach (var poItem in oldObj.Items)
|
||||||
@@ -444,6 +442,7 @@ namespace AyaNova.Biz
|
|||||||
if (w != null)
|
if (w != null)
|
||||||
{
|
{
|
||||||
w.PurchaseOrderItemId = null;
|
w.PurchaseOrderItemId = null;
|
||||||
|
w.Received = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -493,6 +492,7 @@ namespace AyaNova.Biz
|
|||||||
if (w != null)
|
if (w != null)
|
||||||
{
|
{
|
||||||
w.PurchaseOrderItemId = poItem.Id;
|
w.PurchaseOrderItemId = poItem.Id;
|
||||||
|
w.Received = poItem.QuantityReceived;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -532,6 +532,18 @@ namespace AyaNova.Biz
|
|||||||
//might have serials so remove those as well
|
//might have serials so remove those as well
|
||||||
await PartBiz.RemoveSerialsAsync(oldItem.PartId, oldItem.Serials, ct, UserId);
|
await PartBiz.RemoveSerialsAsync(oldItem.PartId, oldItem.Serials, ct, UserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//fixup woitempartrequest if any
|
||||||
|
if (oldItem.WorkOrderItemPartRequestId != null)
|
||||||
|
{
|
||||||
|
//De-request it
|
||||||
|
var w = await ct.WorkOrderItemPartRequest.FirstOrDefaultAsync(x => x.Id == oldItem.WorkOrderItemPartRequestId);
|
||||||
|
if (w != null)
|
||||||
|
{
|
||||||
|
w.PurchaseOrderItemId = null;
|
||||||
|
w.Received = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -571,7 +583,16 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
SetPoItemDefaultPartValues(newItem, PoParts, newObj.VendorId);
|
SetPoItemDefaultPartValues(newItem, PoParts, newObj.VendorId);
|
||||||
|
|
||||||
//MIGRATE_OUTSTANDING - update workorderitempart here if applicable
|
if (newItem.WorkOrderItemPartRequestId != null)
|
||||||
|
{
|
||||||
|
//set it on request
|
||||||
|
var w = await ct.WorkOrderItemPartRequest.FirstOrDefaultAsync(x => x.Id == newItem.WorkOrderItemPartRequestId);
|
||||||
|
if (w != null)
|
||||||
|
{
|
||||||
|
w.PurchaseOrderItemId = newItem.Id;
|
||||||
|
w.Received = newItem.QuantityReceived;
|
||||||
|
}
|
||||||
|
}
|
||||||
continue;//on to next item no possible other changes here
|
continue;//on to next item no possible other changes here
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,6 +617,18 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
|
|
||||||
await PartBiz.RemoveSerialsAsync(oldItem.PartId, oldItem.Serials, ct, UserId);
|
await PartBiz.RemoveSerialsAsync(oldItem.PartId, oldItem.Serials, ct, UserId);
|
||||||
|
|
||||||
|
//change of serial or part invalidates the workorderitempartrequest as it has specific part and warehouse so remove it here
|
||||||
|
if (oldItem.WorkOrderItemPartRequestId != null)
|
||||||
|
{
|
||||||
|
//De-request it
|
||||||
|
var w = await ct.WorkOrderItemPartRequest.FirstOrDefaultAsync(x => x.Id == oldItem.WorkOrderItemPartRequestId);
|
||||||
|
if (w != null)
|
||||||
|
{
|
||||||
|
w.PurchaseOrderItemId = null;
|
||||||
|
w.Received = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newItem.QuantityReceived > 0)
|
if (newItem.QuantityReceived > 0)
|
||||||
@@ -615,6 +648,16 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
|
|
||||||
await PartBiz.AppendSerialsAsync(newItem.PartId, newItem.Serials, ct, UserId);
|
await PartBiz.AppendSerialsAsync(newItem.PartId, newItem.Serials, ct, UserId);
|
||||||
|
if (newItem.WorkOrderItemPartRequestId != null)
|
||||||
|
{
|
||||||
|
//set it on request
|
||||||
|
var w = await ct.WorkOrderItemPartRequest.FirstOrDefaultAsync(x => x.Id == newItem.WorkOrderItemPartRequestId);
|
||||||
|
if (w != null)
|
||||||
|
{
|
||||||
|
w.PurchaseOrderItemId = newItem.Id;
|
||||||
|
w.Received = newItem.QuantityReceived;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update part values into poitem if the part or vendor has changed
|
//Update part values into poitem if the part or vendor has changed
|
||||||
@@ -663,6 +706,17 @@ namespace AyaNova.Biz
|
|||||||
await PartBiz.RemoveSerialsAsync(oldItem.PartId, oldItem.Serials, ct, UserId);
|
await PartBiz.RemoveSerialsAsync(oldItem.PartId, oldItem.Serials, ct, UserId);
|
||||||
await PartBiz.AppendSerialsAsync(newItem.PartId, newItem.Serials, ct, UserId);
|
await PartBiz.AppendSerialsAsync(newItem.PartId, newItem.Serials, ct, UserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//update workorderitempartrequest if applicable
|
||||||
|
if (oldItem.WorkOrderItemPartRequestId != null)
|
||||||
|
{
|
||||||
|
//set it on request
|
||||||
|
var w = await ct.WorkOrderItemPartRequest.FirstOrDefaultAsync(x => x.Id == oldItem.WorkOrderItemPartRequestId);
|
||||||
|
if (w != null)
|
||||||
|
{
|
||||||
|
w.Received = newItem.QuantityReceived;
|
||||||
|
}
|
||||||
|
}
|
||||||
continue;//on to next
|
continue;//on to next
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user