Fix custom formula item pricing: multiply by quantity, not divide
ManualUnitPrice holds the per-item formula result. The previous code incorrectly treated it as the batch total and divided by Quantity, causing the unit price to shrink as quantity increased. Now follows the same pattern as every other ManualUnitPrice path in this method. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -299,15 +299,14 @@ public class PricingCalculationService : IPricingCalculationService
|
||||
}
|
||||
|
||||
// Custom formula items (FixedRate mode): the wizard evaluated the NCalc formula server-side
|
||||
// and stored the result as ManualUnitPrice. The formula result IS the total price — it already
|
||||
// incorporates any quantity-like fields the user entered (e.g. numWheels, numParts). Do NOT
|
||||
// multiply by Quantity again; doing so double-counts when the formula itself accounts for qty.
|
||||
// and stored the per-item result as ManualUnitPrice. Multiply by Quantity for the total,
|
||||
// exactly like every other item type that uses ManualUnitPrice.
|
||||
// SurfaceAreaSqFt mode: ManualUnitPrice is null; the formula produced sqft which was stored
|
||||
// in SurfaceAreaSqFt, so the item falls through to the standard calculated path below.
|
||||
if (item.IsCustomFormulaItem && item.ManualUnitPrice.HasValue)
|
||||
{
|
||||
var formulaTotal = item.ManualUnitPrice.Value;
|
||||
var formulaUnitPrice = item.Quantity > 0 ? formulaTotal / item.Quantity : formulaTotal;
|
||||
var formulaUnitPrice = item.ManualUnitPrice.Value;
|
||||
var formulaTotal = formulaUnitPrice * item.Quantity;
|
||||
return new QuoteItemPricingResult
|
||||
{
|
||||
MaterialCost = 0,
|
||||
|
||||
Reference in New Issue
Block a user