This commit is contained in:
2021-05-15 16:05:46 +00:00
parent 0b38c2bc90
commit e0bb59ce7a
3 changed files with 34 additions and 16 deletions

View File

@@ -99,6 +99,9 @@ namespace AyaNova.Api.Controllers
[HttpGet("client")]
public ActionResult GetClientGlobalBizSettings()
{
//## NOTE: these are settings that the Client needs to see for standard operations
//NOT the settings that the user changes in the global settings form which is fetched above
//so do not include anything here unless the client needs it
if (serverState.IsClosed)
{
//Exception for SuperUser account to handle licensing issues

View File

@@ -328,24 +328,39 @@ namespace AyaNova.Biz
if (ayaEvent == AyaEvent.Created)
{
//find and set effective contract if user didn't set it already
//CONTRACT AUTO SET
if (newObj.ContractId == null && newObj.CustomerId != 0)
{
//customer->headoffice
var cust = await ct.Customer.AsNoTracking().Where(z => z.Id == newObj.CustomerId).Select(z => new { headofficeId = z.HeadOfficeId, contractId = z.ContractId }).FirstOrDefaultAsync();
if(cust.contractId==null && cust.headofficeId!=null){
var hoContractId=await ct.HeadOffice.AsNoTracking().Where(z => z.Id == cust.headofficeId).Select(z => z.ContractId).FirstOrDefaultAsync();
if(hoContractId!=null){
newObj.ContractId=hoContractId;
}
}else{
newObj.ContractId=cust.contractId;
}
if (cust.contractId == null && cust.headofficeId != null)
{
var hoContractId = await ct.HeadOffice.AsNoTracking().Where(z => z.Id == cust.headofficeId).Select(z => z.ContractId).FirstOrDefaultAsync();
if (hoContractId != null)
newObj.ContractId = hoContractId;
}
else
newObj.ContractId = cust.contractId;
}
//set default response time
todo: check contract if applied then check global if not
//RESPONSE TIME / COMPLETE BY AUTO SET
//precedence: manuall set -> contract -> global biz setting
if (newObj.CompleteByDate != 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);
}
}
}

View File

@@ -1,3 +1,4 @@
using System;
using System.Linq;
using AyaNova.Models;
@@ -14,13 +15,11 @@ namespace AyaNova.Util
{
internal static bool SearchCaseSensitiveOnly { get; set; }
internal static bool UseInventory { get; set; }
//TAX CODE DEFAULTS
internal static bool UseInventory { get; set; }
internal static long? TaxPartPurchaseId { get; set; }
internal static long? TaxPartSaleId { get; set; }
internal static long? TaxRateSaleId { get; set; }
internal static TimeSpan WorkOrderCompleteByAge { get; set; }
/// <summary>
@@ -47,6 +46,7 @@ namespace AyaNova.Util
TaxPartPurchaseId = global.TaxPartPurchaseId;
TaxPartSaleId = global.TaxPartSaleId;
TaxRateSaleId = global.TaxRateSaleId;
WorkOrderCompleteByAge=global.WorkOrderCompleteByAge;
}