From eb4d24d85099144467f76df4d9eca51c1b062e54 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 12 May 2021 16:59:09 +0000 Subject: [PATCH] --- server/AyaNova/biz/WorkOrderBiz.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/server/AyaNova/biz/WorkOrderBiz.cs b/server/AyaNova/biz/WorkOrderBiz.cs index 0f500b76..df27ddf0 100644 --- a/server/AyaNova/biz/WorkOrderBiz.cs +++ b/server/AyaNova/biz/WorkOrderBiz.cs @@ -1723,7 +1723,7 @@ namespace AyaNova.Biz { //automatic actions on record change, called AFTER validation - var Contract = GetCurrentWorkOrderContractFromRelatedAsync(AyaType.WorkOrderItem, newObj.WorkOrderItemId); + var Contract = await GetCurrentWorkOrderContractFromRelatedAsync(AyaType.WorkOrderItem, newObj.WorkOrderItemId); switch (ayaEvent) { @@ -1764,12 +1764,17 @@ namespace AyaNova.Biz } //Contract - // todo: need to have a bombproof way to get the effective contract and statically hold it here in wobiz until processing finished because other objects in tree may also need it - // figure out if there will only ever be ONE effective contract or multiple and then can determine how to handle here - //Yes precedence is Unit->Customer->headoffice. - //it's not permitted to have more than one contracted unit on a workorder - //if a unit has a contract on workorder it applies to *entire* workorder so they must use one unit under contract and it's the entirety of the work performed - //if they don't want the rest of wo to be discounted etc + if (Contract != null) + { + //update discount pricing + if (Contract.ServiceRatesOverridePct != 0) + { + if (Contract.ServiceRatesOverrideType == ContractOverrideType.CostMarkup) + newObj.Price = newObj.Cost + (newObj.Cost * Contract.ServiceRatesOverridePct); + else if (Contract.ServiceRatesOverrideType == ContractOverrideType.PriceDiscount) + newObj.Price = newObj.ListPrice - (newObj.ListPrice * Contract.ServiceRatesOverridePct); + } + } break; case AyaEvent.Modified: