This commit is contained in:
2022-02-10 20:23:27 +00:00
parent 9906b656ed
commit 9ca0a68af6
2 changed files with 10 additions and 5 deletions

View File

@@ -565,19 +565,27 @@ namespace AyaNova.Biz
//called when there is a definite possibility of change of close by i.e. new contract, new customer, new workorder
//RESPONSE TIME / COMPLETE BY AUTO SET
//precedence: manually pre-set -> contract -> global biz
//if work order doesn't have a service date set then use utcnow otherwise use the selected date
DateTime referenceDate = DateTime.UtcNow;
if (newObj.ServiceDate != null)
{
referenceDate = (DateTime)newObj.ServiceDate;
}
if (newObj.ContractId != null)
{
await GetCurrentContractFromContractIdAsync(newObj.ContractId);
if (mContractInEffect != null && mContractInEffect.ResponseTime != TimeSpan.Zero)
{
newObj.CompleteByDate = DateTime.UtcNow.Add(mContractInEffect.ResponseTime);
newObj.CompleteByDate = referenceDate.Add(mContractInEffect.ResponseTime);
return; //our work here is done
}
}
//not set yet, maybe the global default is the way...
if (AyaNova.Util.ServerGlobalBizSettings.Cache.WorkOrderCompleteByAge != TimeSpan.Zero)
newObj.CompleteByDate = DateTime.UtcNow.Add(AyaNova.Util.ServerGlobalBizSettings.Cache.WorkOrderCompleteByAge);
newObj.CompleteByDate = referenceDate.Add(AyaNova.Util.ServerGlobalBizSettings.Cache.WorkOrderCompleteByAge);
}