This commit is contained in:
2021-05-13 19:47:56 +00:00
parent af8a1b8aef
commit 5d670daaab

View File

@@ -414,17 +414,39 @@ namespace AyaNova.Biz
{
//contract has changed, update entire graph pricing and potentially response time stuff as well here now
//iterate graph calling *SetListPrice on each item
var wo = await WorkOrderGetAsync(woId, false, false);
var wo = await ct.WorkOrder
.Include(s => s.States)
.Include(w => w.Items.OrderBy(item => item.Sequence))
.ThenInclude(wi => wi.Expenses)
.Include(w => w.Items)
.ThenInclude(wi => wi.Labors)
.Include(w => w.Items)
.ThenInclude(wi => wi.Loans)
.Include(w => w.Items)
.ThenInclude(wi => wi.Parts)
.Include(w => w.Items)
.ThenInclude(wi => wi.PartRequests)
.Include(w => w.Items)
.ThenInclude(wi => wi.ScheduledUsers)
.Include(w => w.Items)
.ThenInclude(wi => wi.Tasks)
.Include(w => w.Items)
.ThenInclude(wi => wi.Travels)
.Include(w => w.Items)
.ThenInclude(wi => wi.Units)
.Include(w => w.Items)
.ThenInclude(wi => wi.OutsideServices)
.SingleOrDefaultAsync(z => z.Id == woId);
foreach (WorkOrderItem wi in wo.Items)
{
foreach (WorkOrderItemLabor o in wi.Labors)
LaborSetPrice(o, mContractInEffect);
await LaborSetPrice(o, mContractInEffect);
foreach (WorkOrderItemTravel o in wi.Travels)
TravelSetListPrice(o, mContractInEffect);
foreach (WorkOrderItemPart o in wi.Parts)
PartSetListPrice(o, mContractInEffect);
}
await ct.SaveChangesAsync();
return wo;
@@ -1833,10 +1855,10 @@ namespace AyaNova.Biz
//Pricing
if (SetPrice)
{
var Contract = await GetCurrentWorkOrderContractFromRelatedAsync(AyaType.WorkOrderItem, newObj.WorkOrderItemId);
await LaborSetPrice(newObj, Contract);
var Contract = await GetCurrentWorkOrderContractFromRelatedAsync(AyaType.WorkOrderItem, newObj.WorkOrderItemId);
await LaborSetPrice(newObj, Contract);
}
}
@@ -1846,22 +1868,22 @@ namespace AyaNova.Biz
//(called by woitemlabor save and also by header save on change of contract)
private async Task LaborSetPrice(WorkOrderItemLabor o, Contract c)
{
//default in case nothing to apply
o.Cost = 0;
o.ListPrice = 0;
o.Price = 0;
//default in case nothing to apply
o.Cost = 0;
o.ListPrice = 0;
o.Price = 0;
//in v7 it was ok to have no service rate selected
//not sure why but carried forward to v8 so..
if (o.ServiceRateId != null)
//in v7 it was ok to have no service rate selected
//not sure why but carried forward to v8 so..
if (o.ServiceRateId != null)
{
var s = await ct.ServiceRate.AsNoTracking().FirstOrDefaultAsync(z => z.Id == o.ServiceRateId);
if (s != null)
{
var s = await ct.ServiceRate.AsNoTracking().FirstOrDefaultAsync(z => z.Id == o.ServiceRateId);
if (s != null)
{
o.Cost = s.Cost;
o.ListPrice = s.Charge;
}
o.Cost = s.Cost;
o.ListPrice = s.Charge;
}
}
if (c == null || c.ServiceRatesOverridePct == 0)
{