FA-58130 / Double-entry ledger accounting / Member archive
Aging-based allowance adjustment: write-off allowance sign · case 05
Writing off a bad debt increases the allowance and shrinks the period adjustment.
Case contract
x = {'as_of': day, 'invoices': [[id, due_day, open cents]], 'rates': [[max_days_past_due or None, basis points]] ascending, 'allowance': existing credit balance (negative = debit balance), 'writeoffs': ids}. Written-off invoices leave receivables and reduce the allowance by their amount. Days past due = max(0, as_of - due); an invoice goes in the first bucket whose limit is None or >= days. Required allowance = sum over buckets of bucket total * bp / 10000 rounded half-up per bucket. Return {'buckets', 'required', 'adjustment': required - allowance after write-offs, 'net_ar'}.
Why this case matters
Ledger software must keep debits equal to credits and apply normal-balance, period and cutoff rules exactly; small sign or boundary slips silently misstate financial statements.
One recorded failure
Sample boundary fixtureThis sample comes from the broken implementation of a controlled reproducer.
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: write-off allowance sign | {"adjustment": -1919, "buckets": [4000, 4005, 0], "net_ar": 7424, "required": 581} | {"adjustment": 3081, "buckets": [4000, 4005, 0], "net_ar": 7424, "required": 581} | Failed |
MEMBER ARCHIVE
The complete case is available to members.
This record includes three runnable implementations, regression fixtures, execution results, and source hashes.
Member access is invitation-based. Sign in with your invited account to inspect the sources.
Sign in to the archive ↗