This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
# SVC-CONTRACTS Placeholder
|
||||
|
||||
This is a placeholder page for sections that are not written yet
|
||||
|
||||
NOTES FOR DOC
|
||||
|
||||
- Contract pricing is normally set upon the *creation* of an object that might have it's price affected by a work order (e.g. a labor item or part added to a workorder). This is done once at the time of creation of that record and done for all items on the workorder if the contract is changed manually on the work order after it was created. This means if a workorder that has already been saved has it's selected contract modified to change the discount (for example) then existing items on that workorder will not automatically be changed to the new discount but items added after the contract is modified will take the new discount. If you want to re-set all the prices on the work order to take into account the new contract terms then de-select the contract on the workorder, save it, then re-select it again to trigger a re-set of all prices.
|
||||
|
||||
- Contract change on workorder will trigger an update of all Labor, Travel and Part item's Cost, ListPrice and Price on that workorder based on their current cost and list price settings as well as any contract adjustments if applicable. This also means any manually adjusted prices on the workorder will be overwritten upon save if the contract has changed.
|
||||
@@ -410,7 +410,7 @@ namespace AyaNova.Biz
|
||||
//CONTRACT CHANGE HANDLER
|
||||
//
|
||||
//
|
||||
private async Task ProcessChangeOfContractAsync(long woId)
|
||||
private async Task<WorkOrder> ProcessChangeOfContractAsync(long woId)
|
||||
{
|
||||
//contract has changed, update entire graph pricing and potentially response time stuff as well here now
|
||||
//iterate graph calling *SetListPrice on each item
|
||||
@@ -418,14 +418,15 @@ namespace AyaNova.Biz
|
||||
foreach (WorkOrderItem wi in wo.Items)
|
||||
{
|
||||
foreach (WorkOrderItemLabor o in wi.Labors)
|
||||
LaborSetListPrice(o, mContractInEffect);
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
@@ -1794,7 +1795,7 @@ namespace AyaNova.Biz
|
||||
|
||||
//by default apply all automatic actions with further restrictions possible below
|
||||
bool ApplyTax = true;
|
||||
bool ApplyPricingUpdate = true;
|
||||
bool SetPrice = true;
|
||||
|
||||
//if modifed, see what has changed and should be re-applied
|
||||
if (ayaEvent == AyaEvent.Modified)
|
||||
@@ -1802,7 +1803,7 @@ namespace AyaNova.Biz
|
||||
//If it wasn't a service rate change there is no need to set pricing
|
||||
if (newObj.ServiceRateId == oldObj.ServiceRateId)
|
||||
{
|
||||
ApplyPricingUpdate = false;
|
||||
SetPrice = false;
|
||||
}
|
||||
//If taxes haven't change then no need to update taxes
|
||||
if (newObj.TaxCodeSaleId == oldObj.TaxCodeSaleId)
|
||||
@@ -1830,26 +1831,12 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
//Pricing
|
||||
if (ApplyPricingUpdate)
|
||||
if (SetPrice)
|
||||
{
|
||||
//default in case nothing to apply
|
||||
newObj.Cost = 0;
|
||||
newObj.ListPrice = 0;
|
||||
newObj.Price = 0;
|
||||
var Contract = await GetCurrentWorkOrderContractFromRelatedAsync(AyaType.WorkOrderItem, newObj.WorkOrderItemId);
|
||||
await LaborSetPrice(newObj, Contract);
|
||||
|
||||
//in v7 it was ok to have no service rate selected
|
||||
//not sure why but carried forward to v8 so..
|
||||
if (newObj.ServiceRateId != null)
|
||||
{
|
||||
var s = await ct.ServiceRate.AsNoTracking().FirstOrDefaultAsync(z => z.Id == newObj.ServiceRateId);
|
||||
if (s != null)
|
||||
{
|
||||
newObj.Cost = s.Cost;
|
||||
newObj.ListPrice = s.Charge;
|
||||
var Contract = await GetCurrentWorkOrderContractFromRelatedAsync(AyaType.WorkOrderItem, newObj.WorkOrderItemId);
|
||||
LaborSetListPrice(newObj, Contract);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1857,8 +1844,25 @@ namespace AyaNova.Biz
|
||||
// SET PER UNIT LIST PRICE
|
||||
//
|
||||
//(called by woitemlabor save and also by header save on change of contract)
|
||||
private static void LaborSetListPrice(WorkOrderItemLabor o, Contract c)
|
||||
private async Task LaborSetPrice(WorkOrderItemLabor o, Contract c)
|
||||
{
|
||||
//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)
|
||||
{
|
||||
var s = await ct.ServiceRate.AsNoTracking().FirstOrDefaultAsync(z => z.Id == o.ServiceRateId);
|
||||
if (s != null)
|
||||
{
|
||||
o.Cost = s.Cost;
|
||||
o.ListPrice = s.Charge;
|
||||
}
|
||||
}
|
||||
|
||||
if (c == null || c.ServiceRatesOverridePct == 0)
|
||||
{
|
||||
o.Price = o.ListPrice;//default with no contract
|
||||
|
||||
Reference in New Issue
Block a user