This commit is contained in:
@@ -1820,7 +1820,7 @@ namespace AyaNova.Biz
|
||||
if (ayaEvent == AyaEvent.Modified)
|
||||
{
|
||||
//If it wasn't a service rate or quantity change there is no need to set pricing
|
||||
if (newObj.ServiceRateId == oldObj.ServiceRateId && newObj.ServiceRateQuantity != oldObj.ServiceRateQuantity)
|
||||
if (newObj.ServiceRateId == oldObj.ServiceRateId && newObj.ServiceRateQuantity == oldObj.ServiceRateQuantity)
|
||||
{
|
||||
SetPrice = false;
|
||||
}
|
||||
@@ -1880,7 +1880,7 @@ namespace AyaNova.Biz
|
||||
var Rate = await ct.ServiceRate.AsNoTracking().FirstOrDefaultAsync(z => z.Id == o.ServiceRateId);
|
||||
if (Rate == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND, "generalerror", "Service rate not found");
|
||||
AddError(ApiErrorCode.NOT_FOUND, "generalerror", "Service rate not found");//this should never happen, no point in localizing
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1889,40 +1889,40 @@ namespace AyaNova.Biz
|
||||
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;
|
||||
}
|
||||
return;//No contract so bail out now, it's done
|
||||
|
||||
//CONTRACT ADJUSTMENTS
|
||||
|
||||
//POTENTIAL 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?
|
||||
|
||||
//Iterate all contract tagged items in order of ones with the most tags first
|
||||
foreach (var csr in c.ContractServiceRateOverrideItems.OrderByDescending(z => z.Tags.Count))
|
||||
if (csr.Tags.All(z => Rate.Tags.Any(x => x == z)))
|
||||
{
|
||||
|
||||
break;
|
||||
if (csr.OverridePct != 0)
|
||||
{
|
||||
var pct = csr.OverridePct / 100;
|
||||
//found a match, apply the discount and return
|
||||
if (csr.OverrideType == ContractOverrideType.CostMarkup)
|
||||
o.Price = o.Cost + (o.Cost * pct);
|
||||
else if (csr.OverrideType == ContractOverrideType.PriceDiscount)
|
||||
o.Price = o.ListPrice - (o.ListPrice * pct);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//No tag discounts, so check for a generic one
|
||||
if (c.ServiceRatesOverridePct == 0)
|
||||
return;// no generic discount for all items so bail now
|
||||
|
||||
//If not then check for a generic one
|
||||
|
||||
if (c == null || c.ServiceRatesOverridePct == 0)
|
||||
{
|
||||
o.Price = o.ListPrice;//default with no contract
|
||||
return;
|
||||
}
|
||||
//Contract has a generic override so apply it
|
||||
if (c.ServiceRatesOverrideType == ContractOverrideType.CostMarkup)
|
||||
o.Price = o.Cost + (o.Cost * c.ServiceRatesOverridePct);
|
||||
else if (c.ServiceRatesOverrideType == ContractOverrideType.PriceDiscount)
|
||||
o.Price = o.ListPrice - (o.ListPrice * c.ServiceRatesOverridePct);
|
||||
/ 100
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -640,7 +640,7 @@ namespace AyaNova.Util
|
||||
c.Active = true;
|
||||
c.Notes = "These are notes providing additional information when users view the contract";
|
||||
c.AlertNotes = "These are alert notes displayed on workorders about this contract";
|
||||
c.PartsOverridePct = .1m;
|
||||
c.PartsOverridePct = 10m;
|
||||
c.PartsOverrideType = ContractOverrideType.PriceDiscount;
|
||||
c.ServiceRatesOverridePct = 0m;
|
||||
c.ServiceRatesOverrideType = ContractOverrideType.PriceDiscount;
|
||||
@@ -675,20 +675,20 @@ namespace AyaNova.Util
|
||||
c.Active = true;
|
||||
c.Notes = "These are notes providing additional information when users view the contract";
|
||||
c.AlertNotes = "These are alert notes displayed on workorders about this contract";
|
||||
c.PartsOverridePct = .2m;
|
||||
c.PartsOverridePct = 15m;
|
||||
c.PartsOverrideType = ContractOverrideType.PriceDiscount;
|
||||
c.ServiceRatesOverridePct = .2m;
|
||||
c.ServiceRatesOverridePct = 15m;
|
||||
c.ServiceRatesOverrideType = ContractOverrideType.PriceDiscount;
|
||||
c.TravelRatesOverridePct = .2m;
|
||||
c.TravelRatesOverridePct = 15m;
|
||||
c.TravelRatesOverrideType = ContractOverrideType.PriceDiscount;
|
||||
c.ResponseTime = new TimeSpan(24, 0, 0);//24 hour response time
|
||||
c.ContractServiceRatesOnly = false;
|
||||
c.ServiceRateItems.Add(new ContractServiceRate() { ServiceRateId = 3 });
|
||||
c.ContractTravelRatesOnly = false;
|
||||
c.TravelRateItems.Add(new ContractTravelRate() { TravelRateId = 3 });
|
||||
c.ContractServiceRateOverrideItems.Add(new ContractServiceRateOverride() { Tags = new string[] { "green" }.ToList(), OverridePct = 10m, OverrideType = ContractOverrideType.PriceDiscount });
|
||||
c.ContractTravelRateOverrideItems.Add(new ContractTravelRateOverride() { Tags = new string[] { "green" }.ToList(), OverridePct = 10m, OverrideType = ContractOverrideType.PriceDiscount });
|
||||
c.ContractPartOverrideItems.Add(new ContractPartOverride() { Tags = new string[] { "green" }.ToList(), OverridePct = 10m, OverrideType = ContractOverrideType.PriceDiscount });
|
||||
c.ContractServiceRateOverrideItems.Add(new ContractServiceRateOverride() { Tags = new string[] { "green" }.ToList(), OverridePct = 20m, OverrideType = ContractOverrideType.PriceDiscount });
|
||||
c.ContractTravelRateOverrideItems.Add(new ContractTravelRateOverride() { Tags = new string[] { "green" }.ToList(), OverridePct = 20m, OverrideType = ContractOverrideType.PriceDiscount });
|
||||
c.ContractPartOverrideItems.Add(new ContractPartOverride() { Tags = new string[] { "green" }.ToList(), OverridePct = 20m, OverrideType = ContractOverrideType.PriceDiscount });
|
||||
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user