FA-59561 / Subscription proration billing / Open access
Credit notes and customer balance on an invoice: excess credit note to balance · case 01
Credit notes larger than the invoice lose their excess value.
ROOT CAUSE
The unused part of the credit notes is discarded instead of added to the balance.
VERIFIED REPAIR
Restore the contract rule at the excess credit note to balance step: use `bal = x['balance'] + (cn - use_cn)`.
Unsuccessful approach: The attempt adds the full credit-note value to the balance, double counting the applied part.
Case contract
Input {total, credit_notes, balance, min_payment}. Credit notes apply first, capped at the total; any excess credit-note value joins the customer balance. The balance then applies up to the remaining due. A remaining due above 0 but below min_payment is carried to the next invoice instead of charged. Return [due, balance_after, carried].
Why this case matters
Proration credits land as credit notes and balances whose application order determines the charge.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
due = x['total']
cn = sum(x['credit_notes'])
use_cn = min(cn, due)
due -= use_cn
bal = x['balance']
use_bal = min(bal, due)
due -= use_bal
bal -= use_bal
carried = 0
if 0 < due < x['min_payment']:
carried = due
due = 0
return [due, bal, carried]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'total': 53, 'credit_notes': [2302], 'balance': 0, 'min_payment': 50}, [0, 2249, 0]), ('regression', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('partial-repair probe (boundary)', {'total': 1050, 'credit_notes': [1000], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('partial-repair probe (boundary)', {'total': 1200, 'credit_notes': [1100], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 80, 'credit_notes': [], 'balance': 10, 'min_payment': 100}, [0, 0, 70]), ('normal control', {'total': 136, 'credit_notes': [], 'balance': 13171, 'min_payment': 0}, [0, 13035, 0]), ('normal control', {'total': 294, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [294, 0, 0]), ('normal control', {'total': 36738, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [36738, 0, 0]), ('normal control', {'total': 2985, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [2985, 0, 0])], [('regression', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('partial-repair probe (boundary)', {'total': 520, 'credit_notes': [300], 'balance': 199, 'min_payment': 50}, [0, 0, 21]), ('partial-repair probe', {'total': 53, 'credit_notes': [2302], 'balance': 0, 'min_payment': 50}, [0, 2249, 0]), ('boundary control', {'total': 130, 'credit_notes': [], 'balance': 50, 'min_payment': 100}, [0, 0, 80]), ('boundary control', {'total': 40, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [0, 0, 40]), ('normal control', {'total': 18, 'credit_notes': [], 'balance': 23152, 'min_payment': 0}, [0, 23134, 0]), ('normal control', {'total': 1, 'credit_notes': [], 'balance': 25350, 'min_payment': 50}, [0, 25349, 0]), ('normal control', {'total': 79, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [79, 0, 0]), ('normal control', {'total': 192, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [192, 0, 0])], [('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('partial-repair probe', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('partial-repair probe', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('boundary control', {'total': 100, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('boundary control', {'total': 160, 'credit_notes': [], 'balance': 60, 'min_payment': 100}, [100, 0, 0]), ('normal control', {'total': 107, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [107, 0, 0]), ('normal control', {'total': 18849, 'credit_notes': [], 'balance': 21401, 'min_payment': 50}, [0, 2552, 0]), ('normal control', {'total': 123, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [123, 0, 0]), ('normal control', {'total': 228, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [228, 0, 0])], [('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('regression', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 0]), ('partial-repair probe', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('partial-repair probe', {'total': 43465, 'credit_notes': [15608, 701], 'balance': 0, 'min_payment': 100}, [27156, 0, 0]), ('boundary control', {'total': 190, 'credit_notes': [], 'balance': 100, 'min_payment': 100}, [0, 0, 90]), ('boundary control', {'total': 75, 'credit_notes': [], 'balance': 30, 'min_payment': 50}, [0, 0, 45]), ('normal control', {'total': 288, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [288, 0, 0]), ('normal control', {'total': 38150, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [38150, 0, 0]), ('normal control', {'total': 165, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [165, 0, 0]), ('normal control', {'total': 82, 'credit_notes': [], 'balance': 29441, 'min_payment': 50}, [0, 29359, 0])], [('regression', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 0]), ('regression', {'total': 46, 'credit_notes': [8883, 761], 'balance': 0, 'min_payment': 50}, [0, 9598, 0]), ('partial-repair probe', {'total': 43465, 'credit_notes': [15608, 701], 'balance': 0, 'min_payment': 100}, [27156, 0, 0]), ('partial-repair probe', {'total': 25597, 'credit_notes': [2793, 18362], 'balance': 0, 'min_payment': 0}, [4442, 0, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 80, 'credit_notes': [], 'balance': 10, 'min_payment': 100}, [0, 0, 70]), ('normal control', {'total': 83, 'credit_notes': [], 'balance': 9256, 'min_payment': 50}, [0, 9173, 0]), ('normal control', {'total': 141, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [141, 0, 0]), ('normal control', {'total': 136, 'credit_notes': [], 'balance': 3623, 'min_payment': 100}, [0, 3487, 0]), ('normal control', {'total': 42819, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [42819, 0, 0])]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
check("%s %d" % (label, i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression 0 | [0, 0, 0] | [0, 2249, 0] | Failed |
| regression 1 | [0, 0, 0] | [0, 15268, 0] | Failed |
| partial-repair probe (boundary) 2 | [50, 0, 0] | [50, 0, 0] | Passed |
| partial-repair probe (boundary) 3 | [100, 0, 0] | [100, 0, 0] | Passed |
| boundary control 4 | [50, 0, 0] | [50, 0, 0] | Passed |
| boundary control 5 | [0, 0, 70] | [0, 0, 70] | Passed |
| normal control 6 | [0, 13035, 0] | [0, 13035, 0] | Passed |
| normal control 7 | [294, 0, 0] | [294, 0, 0] | Passed |
| normal control 8 | [36738, 0, 0] | [36738, 0, 0] | Passed |
| normal control 9 | [2985, 0, 0] | [2985, 0, 0] | Passed |
SHA-256 / 80bcaf8947984ff43fa0092ebc19f8814a8ff78ddd4f7641999d23507d734f9f
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
due = x['total']
cn = sum(x['credit_notes'])
use_cn = min(cn, due)
due -= use_cn
bal = x['balance'] + cn
use_bal = min(bal, due)
due -= use_bal
bal -= use_bal
carried = 0
if 0 < due < x['min_payment']:
carried = due
due = 0
return [due, bal, carried]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'total': 53, 'credit_notes': [2302], 'balance': 0, 'min_payment': 50}, [0, 2249, 0]), ('regression', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('partial-repair probe (boundary)', {'total': 1050, 'credit_notes': [1000], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('partial-repair probe (boundary)', {'total': 1200, 'credit_notes': [1100], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 80, 'credit_notes': [], 'balance': 10, 'min_payment': 100}, [0, 0, 70]), ('normal control', {'total': 136, 'credit_notes': [], 'balance': 13171, 'min_payment': 0}, [0, 13035, 0]), ('normal control', {'total': 294, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [294, 0, 0]), ('normal control', {'total': 36738, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [36738, 0, 0]), ('normal control', {'total': 2985, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [2985, 0, 0])], [('regression', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('partial-repair probe (boundary)', {'total': 520, 'credit_notes': [300], 'balance': 199, 'min_payment': 50}, [0, 0, 21]), ('partial-repair probe', {'total': 53, 'credit_notes': [2302], 'balance': 0, 'min_payment': 50}, [0, 2249, 0]), ('boundary control', {'total': 130, 'credit_notes': [], 'balance': 50, 'min_payment': 100}, [0, 0, 80]), ('boundary control', {'total': 40, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [0, 0, 40]), ('normal control', {'total': 18, 'credit_notes': [], 'balance': 23152, 'min_payment': 0}, [0, 23134, 0]), ('normal control', {'total': 1, 'credit_notes': [], 'balance': 25350, 'min_payment': 50}, [0, 25349, 0]), ('normal control', {'total': 79, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [79, 0, 0]), ('normal control', {'total': 192, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [192, 0, 0])], [('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('partial-repair probe', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('partial-repair probe', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('boundary control', {'total': 100, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('boundary control', {'total': 160, 'credit_notes': [], 'balance': 60, 'min_payment': 100}, [100, 0, 0]), ('normal control', {'total': 107, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [107, 0, 0]), ('normal control', {'total': 18849, 'credit_notes': [], 'balance': 21401, 'min_payment': 50}, [0, 2552, 0]), ('normal control', {'total': 123, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [123, 0, 0]), ('normal control', {'total': 228, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [228, 0, 0])], [('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('regression', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 0]), ('partial-repair probe', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('partial-repair probe', {'total': 43465, 'credit_notes': [15608, 701], 'balance': 0, 'min_payment': 100}, [27156, 0, 0]), ('boundary control', {'total': 190, 'credit_notes': [], 'balance': 100, 'min_payment': 100}, [0, 0, 90]), ('boundary control', {'total': 75, 'credit_notes': [], 'balance': 30, 'min_payment': 50}, [0, 0, 45]), ('normal control', {'total': 288, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [288, 0, 0]), ('normal control', {'total': 38150, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [38150, 0, 0]), ('normal control', {'total': 165, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [165, 0, 0]), ('normal control', {'total': 82, 'credit_notes': [], 'balance': 29441, 'min_payment': 50}, [0, 29359, 0])], [('regression', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 0]), ('regression', {'total': 46, 'credit_notes': [8883, 761], 'balance': 0, 'min_payment': 50}, [0, 9598, 0]), ('partial-repair probe', {'total': 43465, 'credit_notes': [15608, 701], 'balance': 0, 'min_payment': 100}, [27156, 0, 0]), ('partial-repair probe', {'total': 25597, 'credit_notes': [2793, 18362], 'balance': 0, 'min_payment': 0}, [4442, 0, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 80, 'credit_notes': [], 'balance': 10, 'min_payment': 100}, [0, 0, 70]), ('normal control', {'total': 83, 'credit_notes': [], 'balance': 9256, 'min_payment': 50}, [0, 9173, 0]), ('normal control', {'total': 141, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [141, 0, 0]), ('normal control', {'total': 136, 'credit_notes': [], 'balance': 3623, 'min_payment': 100}, [0, 3487, 0]), ('normal control', {'total': 42819, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [42819, 0, 0])]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
check("%s %d" % (label, i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression 0 | [0, 2302, 0] | [0, 2249, 0] | Failed |
| regression 1 | [0, 15517, 0] | [0, 15268, 0] | Failed |
| partial-repair probe (boundary) 2 | [0, 950, 0] | [50, 0, 0] | Failed |
| partial-repair probe (boundary) 3 | [0, 1000, 0] | [100, 0, 0] | Failed |
| boundary control 4 | [50, 0, 0] | [50, 0, 0] | Passed |
| boundary control 5 | [0, 0, 70] | [0, 0, 70] | Passed |
| normal control 6 | [0, 13035, 0] | [0, 13035, 0] | Passed |
| normal control 7 | [294, 0, 0] | [294, 0, 0] | Passed |
| normal control 8 | [36738, 0, 0] | [36738, 0, 0] | Passed |
| normal control 9 | [2985, 0, 0] | [2985, 0, 0] | Passed |
SHA-256 / 374ec9e34ce74c3882cf9a8cfaf2c53f4d4fd7c17d96c2f521ce1a048a0187e5
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
due = x['total']
cn = sum(x['credit_notes'])
use_cn = min(cn, due)
due -= use_cn
bal = x['balance'] + (cn - use_cn)
use_bal = min(bal, due)
due -= use_bal
bal -= use_bal
carried = 0
if 0 < due < x['min_payment']:
carried = due
due = 0
return [due, bal, carried]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'total': 53, 'credit_notes': [2302], 'balance': 0, 'min_payment': 50}, [0, 2249, 0]), ('regression', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('partial-repair probe (boundary)', {'total': 1050, 'credit_notes': [1000], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('partial-repair probe (boundary)', {'total': 1200, 'credit_notes': [1100], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 80, 'credit_notes': [], 'balance': 10, 'min_payment': 100}, [0, 0, 70]), ('normal control', {'total': 136, 'credit_notes': [], 'balance': 13171, 'min_payment': 0}, [0, 13035, 0]), ('normal control', {'total': 294, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [294, 0, 0]), ('normal control', {'total': 36738, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [36738, 0, 0]), ('normal control', {'total': 2985, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [2985, 0, 0])], [('regression', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('partial-repair probe (boundary)', {'total': 520, 'credit_notes': [300], 'balance': 199, 'min_payment': 50}, [0, 0, 21]), ('partial-repair probe', {'total': 53, 'credit_notes': [2302], 'balance': 0, 'min_payment': 50}, [0, 2249, 0]), ('boundary control', {'total': 130, 'credit_notes': [], 'balance': 50, 'min_payment': 100}, [0, 0, 80]), ('boundary control', {'total': 40, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [0, 0, 40]), ('normal control', {'total': 18, 'credit_notes': [], 'balance': 23152, 'min_payment': 0}, [0, 23134, 0]), ('normal control', {'total': 1, 'credit_notes': [], 'balance': 25350, 'min_payment': 50}, [0, 25349, 0]), ('normal control', {'total': 79, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [79, 0, 0]), ('normal control', {'total': 192, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [192, 0, 0])], [('regression', {'total': 299, 'credit_notes': [19966], 'balance': 0, 'min_payment': 0}, [0, 19667, 0]), ('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('partial-repair probe', {'total': 249, 'credit_notes': [6921, 1078, 7518], 'balance': 0, 'min_payment': 100}, [0, 15268, 0]), ('partial-repair probe', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('boundary control', {'total': 100, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [100, 0, 0]), ('boundary control', {'total': 160, 'credit_notes': [], 'balance': 60, 'min_payment': 100}, [100, 0, 0]), ('normal control', {'total': 107, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [107, 0, 0]), ('normal control', {'total': 18849, 'credit_notes': [], 'balance': 21401, 'min_payment': 50}, [0, 2552, 0]), ('normal control', {'total': 123, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [123, 0, 0]), ('normal control', {'total': 228, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [228, 0, 0])], [('regression', {'total': 7761, 'credit_notes': [6395, 18359, 7009], 'balance': 11062, 'min_payment': 100}, [0, 35064, 0]), ('regression', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 0]), ('partial-repair probe', {'total': 16956, 'credit_notes': [7744], 'balance': 26482, 'min_payment': 0}, [0, 17270, 0]), ('partial-repair probe', {'total': 43465, 'credit_notes': [15608, 701], 'balance': 0, 'min_payment': 100}, [27156, 0, 0]), ('boundary control', {'total': 190, 'credit_notes': [], 'balance': 100, 'min_payment': 100}, [0, 0, 90]), ('boundary control', {'total': 75, 'credit_notes': [], 'balance': 30, 'min_payment': 50}, [0, 0, 45]), ('normal control', {'total': 288, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [288, 0, 0]), ('normal control', {'total': 38150, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [38150, 0, 0]), ('normal control', {'total': 165, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [165, 0, 0]), ('normal control', {'total': 82, 'credit_notes': [], 'balance': 29441, 'min_payment': 50}, [0, 29359, 0])], [('regression', {'total': 164, 'credit_notes': [3853, 15350, 168], 'balance': 6958, 'min_payment': 100}, [0, 26165, 0]), ('regression', {'total': 46, 'credit_notes': [8883, 761], 'balance': 0, 'min_payment': 50}, [0, 9598, 0]), ('partial-repair probe', {'total': 43465, 'credit_notes': [15608, 701], 'balance': 0, 'min_payment': 100}, [27156, 0, 0]), ('partial-repair probe', {'total': 25597, 'credit_notes': [2793, 18362], 'balance': 0, 'min_payment': 0}, [4442, 0, 0]), ('boundary control', {'total': 50, 'credit_notes': [], 'balance': 0, 'min_payment': 50}, [50, 0, 0]), ('boundary control', {'total': 80, 'credit_notes': [], 'balance': 10, 'min_payment': 100}, [0, 0, 70]), ('normal control', {'total': 83, 'credit_notes': [], 'balance': 9256, 'min_payment': 50}, [0, 9173, 0]), ('normal control', {'total': 141, 'credit_notes': [], 'balance': 0, 'min_payment': 0}, [141, 0, 0]), ('normal control', {'total': 136, 'credit_notes': [], 'balance': 3623, 'min_payment': 100}, [0, 3487, 0]), ('normal control', {'total': 42819, 'credit_notes': [], 'balance': 0, 'min_payment': 100}, [42819, 0, 0])]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
check("%s %d" % (label, i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression 0 | [0, 2249, 0] | [0, 2249, 0] | Passed |
| regression 1 | [0, 15268, 0] | [0, 15268, 0] | Passed |
| partial-repair probe (boundary) 2 | [50, 0, 0] | [50, 0, 0] | Passed |
| partial-repair probe (boundary) 3 | [100, 0, 0] | [100, 0, 0] | Passed |
| boundary control 4 | [50, 0, 0] | [50, 0, 0] | Passed |
| boundary control 5 | [0, 0, 70] | [0, 0, 70] | Passed |
| normal control 6 | [0, 13035, 0] | [0, 13035, 0] | Passed |
| normal control 7 | [294, 0, 0] | [294, 0, 0] | Passed |
| normal control 8 | [36738, 0, 0] | [36738, 0, 0] | Passed |
| normal control 9 | [2985, 0, 0] | [2985, 0, 0] | Passed |
SHA-256 / a51fd5bbe16fa3e2d360db43156ef969959d8e126e6d583b26a7c7677e59b4a0
Verification & scope
A deterministic teaching model of a stipulated billing rule. It makes no claim to reproduce any billing provider's exact behaviour and is not billing software. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:46:37.526935+00:00.
Case digest / d6a324474536e761068d68ef252513c449d846030ea17c5f41f7fe1d784c8c53