Calculation type
Zeroes out a charge line's allowed amount when that charge's code is listed, in a configured code-exclusion schedule, as excluded due to the presence of another matching charge code anywhere on the account -- including, due to a missing self-exclusion guard, the very charge being evaluated.
scheduleType = GetScheduleType(calc.ScheduleType); scheduleMap = GetScheduleMapRecord(context, scheduleType.Key); dimKey = scheduleType.ChargeCodeDimension. For i=0..NumCharges-1 (loop includes the account-level charge at i=0): if i!=0 and IgnoreCharge(calc,charge,context), skip. chargeCode = charge.FindCode(dimKey); if chargeCode != null: records = GetCodeScheduleRecordList(scheduleType, scheduleMap.ScheduleKey, chargeCode); walk the list, excluded = true if context.Charges.Exists(x => x.FindCode(dimKey) == records.Head.Code) for any record in the list; if excluded, detail.Adjust(0.0M, calc).
| Key | Meaning |
|---|---|
| ScheduleType | Key of the code-exclusion schedule (ScheduleTypeReferenceField, inherited from ScheduleTypeCalculation) whose records map a charge code to other charge code(s) that, if co-present on the account, cause exclusion. |
Gotchas
No self-exclusion guard: `context.Charges.Exists(x => x.FindCode(dimKey) == records.Head.Code)` scans ALL charges in context.Charges, including the very charge whose exclusion list is being checked -- if a code's own exclusion list contains that same code, or the same code appears on two lines, the charge zeroes itself out. A reimplementer who assumes 'excluded by presence of another charge' (the intuitive reading of the type's name) will get this wrong. The IgnoreCharge filter is applied to i=1..N-1 charges only -- the account-level pseudo-charge at i=0 is always evaluated (never filtered) and can itself be zeroed if it carries a matching excluded code. GetScheduleType/GetScheduleMapRecord/GetCodeScheduleRecordList are all defined in this same file (CalculationEngine.cs:1999, 2089, 2205 respectively), not in some separate partial/base file.
class · /home/cary/src/mdc/MdClarity/MDClarity/MDClarityCore/Backend/CustomerDataModel.cs:1024
dispatch · /home/cary/src/mdc/MdClarity/MDClarity/MDClarityCore/Backend/CalculationEngine.cs:753
CORRECTED: the draft's formula explicitly said the exclusion check looks for 'any OTHER charge' (capitalized for emphasis) on the account, which is the opposite of what the code does -- there is no self-exclusion guard and the Exists() scan includes the charge being evaluated. The draft's note that GetScheduleType/GetScheduleMapRecord/GetCodeScheduleRecordList definitions 'were not located within CalculationEngine.cs itself, likely in a partial class or base file not read' was also wrong -- all three are defined in CalculationEngine.cs itself, confirmed at lines 1999, 2089, and 2205.