This commit is contained in:
@@ -2541,54 +2541,11 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
//manual price overrides anything
|
||||
o.PriceViz=o.ListPrice;
|
||||
if (o.PriceOverride != null)
|
||||
o.PriceViz = (decimal)o.PriceOverride;
|
||||
else
|
||||
{
|
||||
//not manual so could potentially have a contract adjustment
|
||||
var c = await GetCurrentWorkOrderContractFromRelatedAsync(AyaType.WorkOrderItem, o.WorkOrderItemId);
|
||||
if (c != null)
|
||||
{
|
||||
decimal pct = 0;
|
||||
ContractOverrideType cot = ContractOverrideType.PriceDiscount;
|
||||
|
||||
bool TaggedAdjustmentInEffect = false;
|
||||
|
||||
//POTENTIAL CONTRACT ADJUSTMENTS
|
||||
//First check if there is a matching tagged contract discount, that takes precedence
|
||||
if (c.ContractPartOverrideItems.Count > 0)
|
||||
{
|
||||
//Iterate all contract tagged items in order of ones with the most tags first
|
||||
foreach (var cp in c.ContractPartOverrideItems.OrderByDescending(z => z.Tags.Count))
|
||||
if (cp.Tags.All(z => part.Tags.Any(x => x == z)))
|
||||
{
|
||||
if (cp.OverridePct != 0)
|
||||
{
|
||||
pct = cp.OverridePct / 100;
|
||||
cot = cp.OverrideType;
|
||||
TaggedAdjustmentInEffect = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Generic discount?
|
||||
if (!TaggedAdjustmentInEffect && c.ServiceRatesOverridePct != 0)
|
||||
{
|
||||
pct = c.ServiceRatesOverridePct / 100;
|
||||
cot = c.ServiceRatesOverrideType;
|
||||
}
|
||||
|
||||
//apply if discount found
|
||||
if (pct != 0)
|
||||
{
|
||||
if (cot == ContractOverrideType.CostMarkup)
|
||||
o.PriceViz = o.Cost + (o.Cost * pct);
|
||||
else if (cot == ContractOverrideType.PriceDiscount)
|
||||
o.PriceViz = o.ListPrice - (o.ListPrice * pct);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Currently not contract discounted so no further calcs need apply to priceViz
|
||||
|
||||
//Calculate totals and taxes
|
||||
//NET
|
||||
o.NetViz = o.PriceViz * o.Quantity;
|
||||
@@ -2636,13 +2593,10 @@ namespace AyaNova.Biz
|
||||
if (ayaEvent == AyaEvent.Modified)
|
||||
{
|
||||
//If it wasn't a complete part change there is no need to set pricing
|
||||
if (newObj.LoanUnitId == oldObj.LoanUnitId && newObj.Rate == oldObj.Rate)
|
||||
{
|
||||
SnapshotPricing = false;
|
||||
}
|
||||
if (newObj.LoanUnitId == oldObj.LoanUnitId && newObj.Rate == oldObj.Rate)
|
||||
SnapshotPricing = false;
|
||||
}
|
||||
|
||||
|
||||
//Pricing
|
||||
if (SnapshotPricing)
|
||||
{
|
||||
@@ -2650,22 +2604,40 @@ namespace AyaNova.Biz
|
||||
newObj.Cost = 0;
|
||||
newObj.ListPrice = 0;
|
||||
|
||||
|
||||
LoanUnit loanUnit = await ct.LoanUnit.AsNoTracking().FirstOrDefaultAsync(x => x.Id == newObj.LoanUnitId);
|
||||
if (loanUnit != null)
|
||||
{
|
||||
|
||||
{
|
||||
switch (newObj.Rate)
|
||||
{
|
||||
case LoanUnitRateUnit.None:
|
||||
case LoanUnitRateUnit.None:
|
||||
break;
|
||||
case LoanUnitRateUnit.Hours:
|
||||
newObj.Cost=loanUnit.
|
||||
case LoanUnitRateUnit.Hours:
|
||||
newObj.Cost = loanUnit.RateHourCost;
|
||||
newObj.ListPrice = loanUnit.RateHour;
|
||||
break;
|
||||
|
||||
|
||||
case LoanUnitRateUnit.HalfDays:
|
||||
newObj.Cost = loanUnit.RateHalfDayCost;
|
||||
newObj.ListPrice = loanUnit.RateHalfDay;
|
||||
break;
|
||||
case LoanUnitRateUnit.Days:
|
||||
newObj.Cost = loanUnit.RateDayCost;
|
||||
newObj.ListPrice = loanUnit.RateDay;
|
||||
break;
|
||||
case LoanUnitRateUnit.Weeks:
|
||||
newObj.Cost = loanUnit.RateWeekCost;
|
||||
newObj.ListPrice = loanUnit.RateWeek;
|
||||
break;
|
||||
case LoanUnitRateUnit.Months:
|
||||
newObj.Cost = loanUnit.RateMonthCost;
|
||||
newObj.ListPrice = loanUnit.RateMonth;
|
||||
break;
|
||||
case LoanUnitRateUnit.Years:
|
||||
newObj.Cost = loanUnit.RateYearCost;
|
||||
newObj.ListPrice = loanUnit.RateYear;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user