This commit is contained in:
@@ -74,45 +74,6 @@ namespace AyaNova.Biz
|
||||
}
|
||||
}
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// //DUPLICATE
|
||||
// //
|
||||
// internal async Task<PurchaseOrder> DuplicateAsync(long id)
|
||||
// {
|
||||
// //TODO: allow this but only with ZEROS set for the actual received amount and ignore woitempart requested during dupe?
|
||||
|
||||
// var dbObject = await GetAsync(id, false, false);
|
||||
// if (dbObject == null)
|
||||
// {
|
||||
// AddError(ApiErrorCode.NOT_FOUND, "id");
|
||||
// return null;
|
||||
// }
|
||||
// PurchaseOrder newObject = new PurchaseOrder();
|
||||
// CopyObject.Copy(dbObject, newObject, "Wiki,Serial");
|
||||
// newObject.Id = 0;
|
||||
// newObject.Concurrency = 0;
|
||||
// newObject.Status = PurchaseOrderStatus.OpenNotYetOrdered;
|
||||
// foreach (var item in newObject.Items)
|
||||
// {
|
||||
// item.Id = 0;
|
||||
// item.Concurrency = 0;
|
||||
// item.QuantityReceived = 0;
|
||||
// item.ReceivedCost = 0;
|
||||
// item.ReceivedDate = null;
|
||||
// item.PurchaseOrderId = 0;
|
||||
// item.WorkOrderItemPartRequestId = null;
|
||||
// item.PartRequestedById = null;
|
||||
// }
|
||||
|
||||
// await ct.PurchaseOrder.AddAsync(newObject);
|
||||
// await ct.SaveChangesAsync();
|
||||
// await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct);
|
||||
// await SearchIndexAsync(newObject, true);
|
||||
// await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
|
||||
// await HandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
||||
// await SetDisplayFields(newObject);
|
||||
// return newObject;
|
||||
// }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//GET
|
||||
@@ -217,8 +178,8 @@ namespace AyaNova.Biz
|
||||
if (item.WorkOrderItemPartRequestId != null)
|
||||
{
|
||||
po.HasPartRequest = true;
|
||||
|
||||
item.WorkOrderItemPartRequestViz=(await WorkOrderBiz.GetWorkOrderSerialFromRelativeAsync(AyaType.WorkOrderItemPartRequest, (long)item.WorkOrderItemPartRequestId, ct)).ToString();
|
||||
|
||||
item.WorkOrderItemPartRequestViz = (await WorkOrderBiz.GetWorkOrderSerialFromRelativeAsync(AyaType.WorkOrderItemPartRequest, (long)item.WorkOrderItemPartRequestId, ct)).ToString();
|
||||
if (item.PartRequestedById != null)
|
||||
item.PartRequestedByViz = await ct.User.AsNoTracking().Where(x => x.Id == item.PartRequestedById).Select(x => x.Name).FirstOrDefaultAsync();
|
||||
}
|
||||
@@ -472,8 +433,19 @@ namespace AyaNova.Biz
|
||||
AddError(ApiErrorCode.API_SERVER_ERROR, "generalerror", $"Error updating inventory ({i.Description}):{pib.GetErrorsAsString()}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//MIGRATE_OUTSTANDING - update workorderitempart here if applicable
|
||||
foreach (var poItem in oldObj.Items)
|
||||
{
|
||||
if (poItem.WorkOrderItemPartRequestId != null)
|
||||
{
|
||||
//De-request it
|
||||
var w = await ct.WorkOrderItemPartRequest.FirstOrDefaultAsync(x => x.Id == poItem.WorkOrderItemPartRequestId);
|
||||
if (w != null)
|
||||
{
|
||||
w.PurchaseOrderItemId = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;//done, nothing more to do here
|
||||
}
|
||||
@@ -506,12 +478,25 @@ namespace AyaNova.Biz
|
||||
|
||||
await PartBiz.AppendSerialsAsync(poItem.PartId, poItem.Serials, ct, UserId);
|
||||
|
||||
//MIGRATE_OUTSTANDING - update workorderitempart here if applicable
|
||||
}
|
||||
|
||||
//All new so set them all
|
||||
foreach (var poItem in newObj.Items)
|
||||
SetPoItemDefaultPartValues(poItem, PoParts, newObj.VendorId);
|
||||
|
||||
foreach (var poItem in newObj.Items)
|
||||
{
|
||||
if (poItem.WorkOrderItemPartRequestId != null)
|
||||
{
|
||||
//set it on request
|
||||
var w = await ct.WorkOrderItemPartRequest.FirstOrDefaultAsync(x => x.Id == poItem.WorkOrderItemPartRequestId);
|
||||
if (w != null)
|
||||
{
|
||||
w.PurchaseOrderItemId = poItem.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -851,7 +836,7 @@ namespace AyaNova.Biz
|
||||
public async Task HandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
||||
{
|
||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<PurchaseOrderBiz>();
|
||||
if(ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
||||
if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
||||
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{this.BizType}, AyaEvent:{ayaEvent}]");
|
||||
|
||||
bool isNew = currentObj == null;
|
||||
|
||||
Reference in New Issue
Block a user