Calculation type
Rescales a charge's already-calculated allowed amount to Percentage% of its current value whenever a specified modifier code is present on that charge.
for i in 1..NumCharges: if !IgnoreCharge(calc,charge,ctx) && detail.Calculated && charge.HasCode(ModifierDimensionKey, Modifier): detail.Adjust(MoneyMath.Percentage(detail.Amount, Percentage), calc) // MoneyMath.Percentage(x,y) = (decimal)Math.Round((double)x * (y/100.0), 2) -- double-precision, default (banker's) rounding; Adjust() SETS Amount to the passed value and records (newAmount-oldAmount) as the adjustment delta, it does not add
| Key | Meaning |
|---|---|
| ModifierDimensionKey | Charge-code dimension to search for the modifier code; UI field defaults it to the built-in "Modifier" dimension |
| Modifier | The specific modifier code value on that dimension that triggers the adjustment when present on a charge |
| Percentage | Percent to rescale the charge's current allowed amount to (e.g. 150 = multiply by 1.5, 50 = multiply by 0.5); this is a reset of Amount, not an additive bump |
Gotchas
Skipped entirely (no adjustment, not a no-op-with-zero) if detail.Calculated is false, i.e. this must run after a base calculation has priced the charge, or if IgnoreCharge matches. The account-level pseudo-charge (index 0) is never touched -- loop starts at i=1. Percentage rescale uses MoneyMath.Percentage which routes through double arithmetic and Math.Round's default MidpointRounding.ToEven ('banker's rounding'), unlike the AwayFromZero rounding used elsewhere in the engine (e.g. ApplyMultipliers) -- a reimplementer using decimal-native rounding will get different results on exact .005 boundaries.
class · /home/cary/src/mdc/MdClarity/MDClarity/MDClarityCore/Backend/CustomerDataModel.cs:983
dispatch · CalculationEngine.cs:741-742 (case ModifierAdjustment modifierAdjustment: CalculateModifierAdjustment(...))
CONFIRMED - class declaration at CustomerDataModel.cs:983-989 (Calculation, IAdjustment; CalculationLevel hardcoded Charge), dispatch at CalculationEngine.cs:741-742, algorithm read in full at CalculationEngine.cs:1607-1619, CalculationDetail.Adjust/MoneyMath.Percentage read directly. Draft's formula and notes matched the code exactly; only added the explicit rounding-mode gotcha.