FAILURE MAP
← Case archive

FA-59781 / Subscription proration billing / Open access

Proration behavior modes and pending items: pending sweep on immediate invoice · case 01

Pending proration items vanish when a later change is invoiced immediately.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The immediate invoice includes only the new amount while pending is cleared.

THE FAILURE

The immediate invoice includes only the new amount while pending is cleared.

Unsuccessful approach: The attempt sweeps positive pending items but drops pending credits.

Case contract

Input {behavior create_prorations|none|always_invoice, amount (net new proration), pending (existing pending items)}. none: nothing is created and pending is untouched. create_prorations: amount joins pending for the next renewal invoice. always_invoice: pending plus amount are invoiced now; a negative total becomes a credit. Return [invoiced_now, pending_after, credited].

Why this case matters

Whether prorations are invoiced now, deferred, or skipped decides when the customer pays and what stays pending.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    amt = x['amount']
    b = x['behavior']
    if b == 'none':
        return [0, x['pending'], 0]
    if b == 'always_invoice':
        due = amt
        return [max(0, due), 0, max(0, -due)]
    return [0, x['pending'] + amt, 0]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'behavior': 'always_invoice', 'amount': -4898, 'pending': -2365}, [0, 0, 7263]), ('regression', {'behavior': 'always_invoice', 'amount': 603, 'pending': -721}, [0, 0, 118]), ('partial-repair probe', {'behavior': 'always_invoice', 'amount': -1436, 'pending': -1622}, [0, 0, 3058]), ('partial-repair probe', {'behavior': 'always_invoice', 'amount': -2445, 'pending': -199}, [0, 0, 2644]), ('normal control', {'behavior': 'none', 'amount': 418, 'pending': 0}, [0, 0, 0]), ('normal control', {'behavior': 'none', 'amount': 3140, 'pending': 2478}, [0, 2478, 0]), ('normal control', {'behavior': 'create_prorations', 'amount': -2033, 'pending': -1935}, [0, -3968, 0]), ('normal control', {'behavior': 'none', 'amount': -1187, 'pending': 1574}, [0, 1574, 0])], [('regression', {'behavior': 'always_invoice', 'amount': 603, 'pending': -721}, [0, 0, 118]), ('regression', {'behavior': 'always_invoice', 'amount': 5024, 'pending': 409}, [5433, 0, 0]), ('partial-repair probe', {'behavior': 'always_invoice', 'amount': -1436, 'pending': -1622}, [0, 0, 3058]), ('partial-repair probe', {'behavior': 'always_invoice', 'amount': -2445, 'pending': -199}, [0, 0, 2644]), ('normal control', {'behavior': 'always_invoice', 'amount': 3806, 'pending': 0}, [3806, 0, 0]), ('normal control', {'behavior': 'create_prorations', 'amount': -2749, 'pending': -1837}, [0, -4586, 0]), ('normal control', {'behavior': 'none', 'amount': -2844, 'pending': 0}, [0, 0, 0]), ('normal control', {'behavior': 'create_prorations', 'amount': 7165, 'pending': -991}, [0, 6174, 0])], [('regression', {'behavior': 'always_invoice', 'amount': -1436, 'pending': -1622}, [0, 0, 3058]), ('regression', {'behavior': 'always_invoice', 'amount': 5024, 'pending': 409}, [5433, 0, 0]), ('partial-repair probe', {'behavior': 'always_invoice', 'amount': -751, 'pending': -1872}, [0, 0, 2623]), ('partial-repair probe', {'behavior': 'always_invoice', 'amount': -2058, 'pending': -1659}, [0, 0, 3717]), ('normal control', {'behavior': 'always_invoice', 'amount': 883, 'pending': 0}, [883, 0, 0]), ('normal control', {'behavior': 'always_invoice', 'amount': 758, 'pending': 0}, [758, 0, 0]), ('normal control', {'behavior': 'none', 'amount': -2370, 'pending': -876}, [0, -876, 0]), ('normal control', {'behavior': 'always_invoice', 'amount': 3888, 'pending': 0}, [3888, 0, 0])], [('regression', {'behavior': 'always_invoice', 'amount': -2445, 'pending': -199}, [0, 0, 2644]), ('regression', {'behavior': 'always_invoice', 'amount': -1436, 'pending': -1622}, [0, 0, 3058]), ('partial-repair probe', {'behavior': 'always_invoice', 'amount': 5208, 'pending': -1138}, [4070, 0, 0]), ('partial-repair probe', {'behavior': 'always_invoice', 'amount': 6787, 'pending': -1826}, [4961, 0, 0]), ('normal control', {'behavior': 'create_prorations', 'amount': 5304, 'pending': -1989}, [0, 3315, 0]), ('normal control', {'behavior': 'none', 'amount': 557, 'pending': 0}, [0, 0, 0]), ('normal control', {'behavior': 'none', 'amount': -2879, 'pending': -1049}, [0, -1049, 0]), ('normal control', {'behavior': 'create_prorations', 'amount': 5860, 'pending': -2357}, [0, 3503, 0])], [('regression', {'behavior': 'always_invoice', 'amount': -751, 'pending': -1872}, [0, 0, 2623]), ('regression', {'behavior': 'always_invoice', 'amount': 6428, 'pending': 2242}, [8670, 0, 0]), ('partial-repair probe', {'behavior': 'always_invoice', 'amount': 2515, 'pending': -1623}, [892, 0, 0]), ('partial-repair probe', {'behavior': 'always_invoice', 'amount': -1535, 'pending': -2189}, [0, 0, 3724]), ('normal control', {'behavior': 'create_prorations', 'amount': -1700, 'pending': 0}, [0, -1700, 0]), ('normal control', {'behavior': 'create_prorations', 'amount': -2824, 'pending': 2220}, [0, -604, 0]), ('normal control', {'behavior': 'create_prorations', 'amount': 3999, 'pending': 3774}, [0, 7773, 0]), ('normal control', {'behavior': 'none', 'amount': -2062, 'pending': 0}, [0, 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 fixtureActualExpectedOutcome
regression 0[0, 0, 4898][0, 0, 7263]Failed
regression 1[603, 0, 0][0, 0, 118]Failed
partial-repair probe 2[0, 0, 1436][0, 0, 3058]Failed
partial-repair probe 3[0, 0, 2445][0, 0, 2644]Failed
normal control 4[0, 0, 0][0, 0, 0]Passed
normal control 5[0, 2478, 0][0, 2478, 0]Passed
normal control 6[0, -3968, 0][0, -3968, 0]Passed
normal control 7[0, 1574, 0][0, 1574, 0]Passed

SHA-256 / 8969a927d511be0ee8f1ff9635673f43dcdbccb5b7170887dc81c080fe64cb4d

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    amt = x['amount']
    b = x['behavior']
    if b == 'none':
        return [0, x['pending'], 0]
    if b == 'always_invoice':
        due = x['pending'] + amt if x['pending'] > 0 else amt
        return [max(0, due), 0, max(0, -due)]
    return [0, x['pending'] + amt, 0]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'behavior': 'always_invoice', 'amount': -4898, 'pending': -2365}, [0, 0, 7263]), ('regression', {'behavior': 'always_invoice', 'amount': 603, 'pending': -721}, [0, 0, 118]), ('partial-repair probe', {'behavior': 'always_invoice', 'amount': -1436, 'pending': -1622}, [0, 0, 3058]), ('partial-repair probe', {'behavior': 'always_invoice', 'amount': -2445, 'pending': -199}, [0, 0, 2644]), ('normal control', {'behavior': 'none', 'amount': 418, 'pending': 0}, [0, 0, 0]), ('normal control', {'behavior': 'none', 'amount': 3140, 'pending': 2478}, [0, 2478, 0]), ('normal control', {'behavior': 'create_prorations', 'amount': -2033, 'pending': -1935}, [0, -3968, 0]), ('normal control', {'behavior': 'none', 'amount': -1187, 'pending': 1574}, [0, 1574, 0])], [('regression', {'behavior': 'always_invoice', 'amount': 603, 'pending': -721}, [0, 0, 118]), ('regression', {'behavior': 'always_invoice', 'amount': 5024, 'pending': 409}, [5433, 0, 0]), ('partial-repair probe', {'behavior': 'always_invoice', 'amount': -1436, 'pending': -1622}, [0, 0, 3058]), ('partial-repair probe', {'behavior': 'always_invoice', 'amount': -2445, 'pending': -199}, [0, 0, 2644]), ('normal control', {'behavior': 'always_invoice', 'amount': 3806, 'pending': 0}, [3806, 0, 0]), ('normal control', {'behavior': 'create_prorations', 'amount': -2749, 'pending': -1837}, [0, -4586, 0]), ('normal control', {'behavior': 'none', 'amount': -2844, 'pending': 0}, [0, 0, 0]), ('normal control', {'behavior': 'create_prorations', 'amount': 7165, 'pending': -991}, [0, 6174, 0])], [('regression', {'behavior': 'always_invoice', 'amount': -1436, 'pending': -1622}, [0, 0, 3058]), ('regression', {'behavior': 'always_invoice', 'amount': 5024, 'pending': 409}, [5433, 0, 0]), ('partial-repair probe', {'behavior': 'always_invoice', 'amount': -751, 'pending': -1872}, [0, 0, 2623]), ('partial-repair probe', {'behavior': 'always_invoice', 'amount': -2058, 'pending': -1659}, [0, 0, 3717]), ('normal control', {'behavior': 'always_invoice', 'amount': 883, 'pending': 0}, [883, 0, 0]), ('normal control', {'behavior': 'always_invoice', 'amount': 758, 'pending': 0}, [758, 0, 0]), ('normal control', {'behavior': 'none', 'amount': -2370, 'pending': -876}, [0, -876, 0]), ('normal control', {'behavior': 'always_invoice', 'amount': 3888, 'pending': 0}, [3888, 0, 0])], [('regression', {'behavior': 'always_invoice', 'amount': -2445, 'pending': -199}, [0, 0, 2644]), ('regression', {'behavior': 'always_invoice', 'amount': -1436, 'pending': -1622}, [0, 0, 3058]), ('partial-repair probe', {'behavior': 'always_invoice', 'amount': 5208, 'pending': -1138}, [4070, 0, 0]), ('partial-repair probe', {'behavior': 'always_invoice', 'amount': 6787, 'pending': -1826}, [4961, 0, 0]), ('normal control', {'behavior': 'create_prorations', 'amount': 5304, 'pending': -1989}, [0, 3315, 0]), ('normal control', {'behavior': 'none', 'amount': 557, 'pending': 0}, [0, 0, 0]), ('normal control', {'behavior': 'none', 'amount': -2879, 'pending': -1049}, [0, -1049, 0]), ('normal control', {'behavior': 'create_prorations', 'amount': 5860, 'pending': -2357}, [0, 3503, 0])], [('regression', {'behavior': 'always_invoice', 'amount': -751, 'pending': -1872}, [0, 0, 2623]), ('regression', {'behavior': 'always_invoice', 'amount': 6428, 'pending': 2242}, [8670, 0, 0]), ('partial-repair probe', {'behavior': 'always_invoice', 'amount': 2515, 'pending': -1623}, [892, 0, 0]), ('partial-repair probe', {'behavior': 'always_invoice', 'amount': -1535, 'pending': -2189}, [0, 0, 3724]), ('normal control', {'behavior': 'create_prorations', 'amount': -1700, 'pending': 0}, [0, -1700, 0]), ('normal control', {'behavior': 'create_prorations', 'amount': -2824, 'pending': 2220}, [0, -604, 0]), ('normal control', {'behavior': 'create_prorations', 'amount': 3999, 'pending': 3774}, [0, 7773, 0]), ('normal control', {'behavior': 'none', 'amount': -2062, 'pending': 0}, [0, 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 fixtureActualExpectedOutcome
regression 0[0, 0, 4898][0, 0, 7263]Failed
regression 1[603, 0, 0][0, 0, 118]Failed
partial-repair probe 2[0, 0, 1436][0, 0, 3058]Failed
partial-repair probe 3[0, 0, 2445][0, 0, 2644]Failed
normal control 4[0, 0, 0][0, 0, 0]Passed
normal control 5[0, 2478, 0][0, 2478, 0]Passed
normal control 6[0, -3968, 0][0, -3968, 0]Passed
normal control 7[0, 1574, 0][0, 1574, 0]Passed

SHA-256 / 65fc915ffe23d541ecc2fb27d15f6efbb1a1c667c0d9046b078b5abddb621bf6

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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:39.482954+00:00.

Case digest / 7b31de03127ff86c95238a10e535848f406b10f4a0a1e11664684214668b91c7