From f9ef637daa9457de097340a17609001731017c8b Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 14 May 2021 15:56:29 +0000 Subject: [PATCH] --- server/AyaNova/biz/NotifyEventHelper.cs | 4 +-- server/AyaNova/biz/WorkOrderBiz.cs | 35 ++++++++++++++++--------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/server/AyaNova/biz/NotifyEventHelper.cs b/server/AyaNova/biz/NotifyEventHelper.cs index 4507ed00..78ee75a8 100644 --- a/server/AyaNova/biz/NotifyEventHelper.cs +++ b/server/AyaNova/biz/NotifyEventHelper.cs @@ -234,6 +234,7 @@ namespace AyaNova.Biz ////////////////////////////////// // COMPARE TAGS COLLECTION // + // A match here means *all* tags in the subscription are present in the object // public static bool TagsMatch(List objectTags, List subTags) { @@ -245,9 +246,8 @@ namespace AyaNova.Biz //not enought tags on object to match sub tags? if (subTags.Count > objectTags.Count) return false; - //ok, here it's worth checking it out + //Do ALL the tags in the subscription exist in the object? return subTags.All(z => objectTags.Any(x => x == z)); - } ///////////////////////////////////////// diff --git a/server/AyaNova/biz/WorkOrderBiz.cs b/server/AyaNova/biz/WorkOrderBiz.cs index 7fb70b27..caac99dd 100644 --- a/server/AyaNova/biz/WorkOrderBiz.cs +++ b/server/AyaNova/biz/WorkOrderBiz.cs @@ -1875,26 +1875,37 @@ namespace AyaNova.Biz //in v7 it was ok to have no service rate selected //not sure why but carried forward to v8 so.. if (o.ServiceRateId == null) + return; + + var Rate = await ct.ServiceRate.AsNoTracking().FirstOrDefaultAsync(z => z.Id == o.ServiceRateId); + if (Rate == null) { + AddError(ApiErrorCode.NOT_FOUND, "generalerror", "Service rate not found"); return; } - var s = await ct.ServiceRate.AsNoTracking().FirstOrDefaultAsync(z => z.Id == o.ServiceRateId); - if(s==null){ - AddError() + o.Cost = Rate.Cost; + o.ListPrice = Rate.Charge; + o.Price = o.ListPrice;//default is list price unless a contract overrides it + + if (c == null) + { + //No contract so bail out now, it's done return; } - if (s != null) - { - o.Cost = s.Cost; - o.ListPrice = s.Charge; - } - - - //default is list price unless a contract overrides it - o.Price = o.ListPrice; + //CONTRACT ADJUSTMENTS + //First check if there is a matching tagged service rate contract discount, that takes precedence + if(c.ContractServiceRateOverrideItems.Count>0){ + //does our contract rate have a matching tag? + + subTags.All(z => objectTags.Any(x => x == z)); + foreach(var csr in c.ContractServiceRateOverrideItems){ + csr.Tags. + } + } + //If not then check for a generic one