This commit is contained in:
2021-05-18 18:21:14 +00:00
parent 13d6e2613a
commit 1742cdec0a

View File

@@ -328,6 +328,7 @@ namespace AyaNova.Biz
if (ayaEvent == AyaEvent.Created)
{
await AutoSetContractAsync(newObj);
await AutoSetCloseByDateAsync(newObj);
await AutoSetAddressAsync(newObj);
return;
}
@@ -341,6 +342,9 @@ namespace AyaNova.Biz
await AutoSetContractAsync(newObj);
await AutoSetAddressAsync(newObj);
}
if (newObj.ContractId != oldObj.ContractId)
await AutoSetCloseByDateAsync(newObj);
}
}
@@ -405,23 +409,23 @@ namespace AyaNova.Biz
newObj.ContractId = head.contractId;
}
}
}
private async Task AutoSetCloseByDateAsync(WorkOrder newObj)
{
//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 (newObj.CompleteByDate != null)
if (newObj.ContractId != null)
{
if (newObj.ContractId != null)
{
await GetCurrentContractFromContractIdAsync(newObj.ContractId);
if (mContractInEffect != null && mContractInEffect.ResponseTime != TimeSpan.Zero)
newObj.CompleteByDate = DateTime.UtcNow.Add(mContractInEffect.ResponseTime);
}
else
{
if (AyaNova.Util.ServerGlobalBizSettings.WorkOrderCompleteByAge != TimeSpan.Zero)
newObj.CompleteByDate = DateTime.UtcNow.Add(AyaNova.Util.ServerGlobalBizSettings.WorkOrderCompleteByAge);
}
await GetCurrentContractFromContractIdAsync(newObj.ContractId);
if (mContractInEffect != null && mContractInEffect.ResponseTime != TimeSpan.Zero)
newObj.CompleteByDate = DateTime.UtcNow.Add(mContractInEffect.ResponseTime);
}
else
{
if (AyaNova.Util.ServerGlobalBizSettings.WorkOrderCompleteByAge != TimeSpan.Zero)
newObj.CompleteByDate = DateTime.UtcNow.Add(AyaNova.Util.ServerGlobalBizSettings.WorkOrderCompleteByAge);
}
}