Calculation type
Caps the allowed amount to a percentage of billed charges: optionally at each individual charge line (when AdjustCharges is set), and always at the account level across the whole account's total.
p = calc.Percentage / 100.0 (double). totalAllowed starts at context.Details[0].Amount. For each non-ignored charge i=1..NumCharges-1: if AdjustCharges, maxAllowed_i = MoneyMath.Multiply(charge.AmountCharged, p); if maxAllowed_i < detail.Amount, detail.Adjust(maxAllowed_i, calc). Then totalCharges += charge.AmountCharged; totalAllowed += detail.Amount (post-adjustment value). After the loop: maxAllowed = MoneyMath.Multiply(totalCharges, p); if maxAllowed < totalAllowed, Details[0].Adjust(Details[0].Amount - (totalAllowed - maxAllowed), calc).
| Key | Meaning |
|---|---|
| Percentage | double, percent-of-charges ceiling (e.g. 80 = 80% of billed charges) the allowed amount must not exceed; drives p = Percentage/100 used in both the per-charge and account-level caps. |
| AdjustCharges | bool, default false; when true the per-charge cap is enforced in the same pass in addition to the account-level cap, and CalculationLevel becomes Charge instead of Account. |
Gotchas
Percentage is a double, not decimal, so the multiply goes through MoneyMath.Multiply(decimal,double) = (decimal)Math.Round((double)x*y,2) using .NET's default MidpointRounding.ToEven (banker's rounding) on a double -- different rounding regime from the decimal/AwayFromZero path used elsewhere in the engine (e.g. ApplyMultipliers for PercentOfFees). The account-level cap always runs regardless of AdjustCharges -- AdjustCharges only adds the extra per-line cap, it does not replace the account-level one. totalAllowed accumulates per-charge Amount AFTER any per-charge adjustment was already applied in the same loop iteration, so the account-level check sees the tightened numbers when AdjustCharges is true. Uses Adjust (delta-recording), consistent with its Adjustment category.
class · /home/cary/src/mdc/MdClarity/MDClarity/MDClarityCore/Backend/CustomerDataModel.cs:864
dispatch · /home/cary/src/mdc/MdClarity/MDClarity/MDClarityCore/Backend/CalculationEngine.cs:731
CONFIRMED