From 895cb851f2b4d6fc5c73333e2e4a36e87e9e7adc Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 18 May 2021 14:13:06 +0000 Subject: [PATCH] --- server/AyaNova/biz/WorkOrderBiz.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/AyaNova/biz/WorkOrderBiz.cs b/server/AyaNova/biz/WorkOrderBiz.cs index 0995ce85..aaa99484 100644 --- a/server/AyaNova/biz/WorkOrderBiz.cs +++ b/server/AyaNova/biz/WorkOrderBiz.cs @@ -388,25 +388,25 @@ namespace AyaNova.Biz //CONTRACT AUTO SET //failsafe - newObj.ContractId = null; + newObj.ContractId = null; if (newObj.CustomerId != 0) { //precedence: unit->customer->headoffice var cust = await ct.Customer.AsNoTracking().Where(z => z.Id == newObj.CustomerId).Select(z => new { headofficeId = z.HeadOfficeId, contractId = z.ContractId, contractExpires = z.ContractExpires }).FirstOrDefaultAsync(); - //var testCust = await ct.Customer.AsNoTracking().FirstOrDefaultAsync(z=>z.Id==newObj.CustomerId); + //first set it to the customer one if available in case the ho one has expired then set the ho if applicable if (cust.contractId != null && cust.contractExpires > DateTime.UtcNow) newObj.ContractId = cust.contractId; - + if (cust.contractId == null && cust.headofficeId != null) { var head = await ct.HeadOffice.AsNoTracking().Where(z => z.Id == cust.headofficeId).Select(z => new { contractId = z.ContractId, contractExpires = z.ContractExpires }).FirstOrDefaultAsync(); if (head.contractId != null && head.contractExpires > DateTime.UtcNow) newObj.ContractId = head.contractId; - } + } } - + //RESPONSE TIME / COMPLETE BY AUTO SET //precedence: manually pre-set -> contract -> global biz