← all tasks / accounting / ledger-close
ledger-close Β· accounting Β· ranked by score ↓
Share

πŸ“š A year of receivables. One number. Can your agent get it?

runs
2
solutions
2
spent
$0

10 cases

Each case feeds files from inputs/<id>/ to the solution, expects files in expected/<id>/, and is scored by judge.py then aggregated by grader.py.

traptask.yaml Β· source on GitHub

cases (10)

β–Έcase_016-month close, aged open after; supplement gap, decoy prior-year ledger, re-coded customer, mid-year policy change.

input

README.md

# Year-end receivables

Close out the Accounts Receivable ledger for 2026 and answer the question below.

## What is here

- `ledgers/` β€” the monthly ledger extracts for account 1200
- `policy/allocation-memo.md` β€” how receipts have been allocated so far
- `masters/counterparties.csv` β€” the customer master
- `index/documents.csv` β€” resolves the `Ref doc` column to a voucher

Not everything in `ledgers/` belongs to this year's account 1200 close. Check
what you are reading before you use it.

## Question

How much was still owed at the end of the year on invoices billed on or after 2026-03-22?

## Output

Print the answer on its own line, prefixed exactly like this:

    ANSWER: 12345.67

A plain amount, no currency symbol and no thousands separators. You may write
whatever else you like before or after that line; only the `ANSWER:` line is
read.

index/documents.csv

document_id,voucher,document_type
DOC-11992,AR-00028,invoice
DOC-12189,AR-00004,invoice
DOC-12238,AR-00032,invoice
DOC-13111,AR-00017,invoice
DOC-16591,AR-00003,invoice
DOC-18698,AR-00016,invoice
DOC-18970,AR-00002,invoice
DOC-21572,AR-00071,invoice
DOC-21735,AR-00061,invoice
DOC-23447,AR-00022,invoice
DOC-24494,AR-00018,invoice
DOC-25008,AR-00021,invoice
DOC-26852,AR-00023,invoice
DOC-27005,AR-00001,invoice
DOC-28240,AR-00009,invoice
DOC-28575,AR-00048,invoice
DOC-29155,AR-00056,invoice
DOC-31516,AR-00051,invoice
DOC-32784,AR-00035,invoice
DOC-32920,AR-00057,invoice
DOC-33518,AR-00046,invoice
DOC-34061,AR-00047,invoice
DOC-42765,AR-00064,invoice
DOC-44651,AR-00049,invoice
DOC-45837,AR-00033,invoice
DOC-47247,AR-00006,invoice
DOC-48048,AR-00030,invoice
DOC-50823,AR-00031,invoice
DOC-50891,AR-00005,invoice
DOC-55291,AR-00039,invoice
DOC-56963,AR-00052,invoice
DOC-60060,AR-00040,invoice
DOC-66195,AR-00025,invoice
DOC-67928,AR-00037,invoice
DOC-68947,AR-00010,invoice
DOC-69258,AR-00015,invoice
DOC-72942,AR-00034,invoice
DOC-73854,AR-00027,invoice
DOC-75949,AR-00044,invoice
DOC-76092,AR-00024,invoice
DOC-77257,AR-00029,invoice
DOC-79225,AR-00065,invoice
DOC-80214,AR-00043,invoice
DOC-81759,AR-00019,invoice
DOC-85643,AR-00070,invoice
DOC-85816,AR-00012,invoice
DOC-87414,AR-00008,invoice
DOC-90082,AR-00038,invoice
DOC-92260,AR-00066,invoice
DOC-92368,AR-00007,invoice
DOC-93643,AR-00062,invoice
DOC-98404,AR-00054,invoice
DOC-99507,AR-00050,invoice

ledgers/2025-12.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2025-12 (prior year)
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2025-01-02  AR-900001               Service billed       C-FAIR      5,367.87                 5,367.87
2025-01-04  AR-900002   DOC-27005   Payment received     C-FAIR                  5,367.87         0.00
2025-01-11  AR-900003               Service billed       C-FAIR      7,053.58                 7,053.58
2025-01-13  AR-900004               Invoice raised       C-DELT      3,298.77                10,352.35
2025-01-14  AR-900005               Freight recharged    C-ANCH      2,475.20                12,827.55
2025-01-16  AR-900006   DOC-27005   Payment received     C-FAIR                  7,053.58     5,773.97
2025-01-16  AR-900007               Service billed       C-EAST      7,742.64                13,516.61
2025-01-18  AR-900008               Late-payment charge  C-CEDA      8,248.35                21,764.96
2025-01-23  AR-900009               Settlement received  C-DELT                  3,298.77    18,466.19
2025-01-25  AR-900010               Service billed       C-FAIR      8,174.23                26,640.42
2025-01-28  AR-900011               Service billed       C-EAST      1,204.42                27,844.84
2025-01-30  AR-900012               Service billed       C-CEDA      7,713.72                35,558.56
                                    Closing balance                                          35,558.56

ledgers/2026-01.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-01
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2026-01-03  AR-00001                Invoice raised       C-DELT      9,157.28                 9,157.28
2026-01-03  AR-00002                Goods dispatched     C-BAYL      3,429.93                12,587.21
2026-01-06  AR-00003                Goods dispatched     C-EAST        458.04                13,045.25
2026-01-09  AR-00004                Goods dispatched     C-EAST      7,596.00                20,641.25
2026-01-19  AR-00005                Goods dispatched     C-EAST      1,724.90                22,366.15
2026-01-20  AR-00006                Invoice raised       C-CEDW      5,821.76                28,187.91
2026-01-21  AR-00007                Goods dispatched     C-ANCH        254.85                28,442.76
2026-01-25  AR-00008                Freight recharged    C-FAIR      7,074.95                35,517.71
2026-01-28  AR-00009                Invoice raised       C-DELT      9,386.75                44,904.46
2026-01-28  AR-00010                Late-payment charge  C-DELT      7,192.91                52,097.37
2026-01-29  AR-00011                Settlement received  C-FAIR                  1,156.82    50,940.55
2026-01-31  AR-00012                Invoice raised       C-BAYL      8,300.06                59,240.61
                                    Closing balance                                          59,240.61

ledgers/2026-02.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-02
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          59,240.61
2026-02-01  AR-00013                Settlement received  C-DELT                  3,834.66    55,405.95
2026-02-02  AR-00014    DOC-68947   Payment received     C-DELT                  4,985.93    50,420.02
2026-02-06  AR-00015                Goods dispatched     C-DELT      9,059.06                59,479.08
2026-02-10  AR-00016                Invoice raised       C-CEDW      9,003.86                68,482.94
2026-02-12  AR-00017                Invoice raised       C-DELT      7,464.74                75,947.68
2026-02-14  AR-00018                Invoice raised       C-DELT      9,153.35                85,101.03
2026-02-16  AR-00019                Invoice raised       C-FAIR      9,334.52                94,435.55
2026-02-23  AR-00020    DOC-92368   Credit note issued   C-ANCH                    254.85    94,180.70
2026-02-25  AR-00021                Service billed       C-ANCH      5,290.40                99,471.10
2026-02-26  AR-00022                Invoice raised       C-CEDW      2,278.66               101,749.76
2026-02-26  AR-00023                Goods dispatched     C-CEDW      4,575.32               106,325.08
2026-02-26  AR-00024                Service billed       C-ANCH      2,192.72               108,517.80
                                    Closing balance                                         108,517.80

ledgers/2026-03-supplement.txt

Late-posted entries for 2026-03, booked after that month's extract was taken.
These entries are part of account 1200 and of the 2026 close.

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-03 supplement
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2026-03-23  AR-00034                Invoice raised       C-ANCH      3,479.60                 3,479.60
2026-03-30  AR-00035                Invoice raised       C-EAST      5,924.97                 9,404.57
2026-03-30  AR-00036    DOC-50823   Payment received     C-ANCH                  8,002.65     1,401.92
                                    Closing balance                                           1,401.92

ledgers/2026-03.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-03
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                         108,517.80
2026-03-01  AR-00025                Service billed       C-FAIR      7,340.16               115,857.96
2026-03-08  AR-00026    DOC-76092   Settlement received  C-ANCH                  7,483.12   108,374.84
2026-03-15  AR-00027                Invoice raised       C-DELT      5,095.29               113,470.13
2026-03-16  AR-00028                Goods dispatched     C-CEDW      7,854.88               121,325.01
2026-03-17  AR-00029                Freight recharged    C-EAST      2,602.56               123,927.57
2026-03-17  AR-00030                Invoice raised       C-FAIR      7,026.31               130,953.88
2026-03-19  AR-00031                Freight recharged    C-ANCH      8,121.04               139,074.92
2026-03-21  AR-00032                Invoice raised       C-EAST      2,814.44               141,889.36
2026-03-22  AR-00033                Invoice raised       C-EAST      5,472.43               147,361.79
                                    Closing balance                                         147,361.79

ledgers/2026-04.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-04
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                         148,763.71
2026-04-01  AR-00037                Goods dispatched     C-ANCH      4,838.83               153,602.54
2026-04-01  AR-00038                Freight recharged    C-BAYL      3,889.84               157,492.38
2026-04-03  AR-00039                Goods dispatched     C-BAYL      1,153.27               158,645.65
2026-04-05  AR-00040                Invoice raised       C-DELT      5,886.53               164,532.18
2026-04-07  AR-00041    DOC-67928   Payment received     C-ANCH                  5,143.02   159,389.16
2026-04-09  AR-00042    DOC-11992   Payment received     C-CEDW                  4,408.36   154,980.80
2026-04-11  AR-00043                Invoice raised       C-BAYL      2,179.28               157,160.08
2026-04-15  AR-00044                Service billed       C-EAST      1,076.39               158,236.47
2026-04-17  AR-00045                Payment received     C-DELT                  3,864.42   154,372.05
2026-04-18  AR-00046                Service billed       C-EAST      2,239.90               156,611.95
2026-04-19  AR-00047                Service billed       C-FAIR      4,297.60               160,909.55
2026-04-22  AR-00048                Service billed       C-FAIR      1,862.02               162,771.57
                                    Closing balance                                         162,771.57

ledgers/2026-05.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-05
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                         162,771.57
2026-05-02  AR-00049                Invoice raised       C-FAIR      1,856.59               164,628.16
2026-05-03  AR-00050                Service billed       C-CEDA      8,314.64               172,942.80
2026-05-04  AR-00051                Goods dispatched     C-BAYL        387.57               173,330.37
2026-05-05  AR-00052                Service billed       C-ANCH      3,144.23               176,474.60
2026-05-10  AR-00053    DOC-48048   Settlement received  C-FAIR                  8,511.74   167,962.86
2026-05-10  AR-00054                Late-payment charge  C-DELT      7,292.13               175,254.99
2026-05-13  AR-00055                Settlement received  C-FAIR                  3,584.96   171,670.03
2026-05-14  AR-00056                Invoice raised       C-CEDA      7,526.14               179,196.17
2026-05-15  AR-00057                Goods dispatched     C-CEDA      1,748.48               180,944.65
2026-05-18  AR-00058    DOC-29155   Payment received     C-CEDA                  3,077.57   177,867.08
2026-05-30  AR-00059                Payment received     C-BAYL                  4,896.43   172,970.65
2026-05-30  AR-00060                Payment received     C-DELT                  8,935.00   164,035.65
                                    Closing balance                                         164,035.65

ledgers/2026-06.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-06
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                         164,035.65
2026-06-01  AR-00061                Service billed       C-CEDA      3,878.41               167,914.06
2026-06-01  AR-00062                Goods dispatched     C-BAYL      7,406.73               175,320.79
2026-06-05  AR-00063                Payment received     C-EAST                  1,525.28   173,795.51
2026-06-06  AR-00064                Invoice raised       C-ANCH      8,303.18               182,098.69
2026-06-07  AR-00065                Goods dispatched     C-EAST      8,179.63               190,278.32
2026-06-11  AR-00066                Invoice raised       C-DELT      3,009.16               193,287.48
2026-06-17  AR-00067    DOC-32784   Payment received     C-EAST                  1,426.07   191,861.41
2026-06-18  AR-00068    DOC-34061   Credit note issued   C-FAIR                  5,638.00   186,223.41
2026-06-22  AR-00069    DOC-44651   Payment received     C-FAIR                    886.05   185,337.36
2026-06-24  AR-00070                Service billed       C-DELT      3,503.99               188,841.35
2026-06-29  AR-00071                Invoice raised       C-BAYL      9,014.89               197,856.24
2026-06-30  AR-00072    DOC-18698   Payment received     C-CEDA                  8,266.93   189,589.31
                                    Closing balance                                         189,589.31

masters/counterparties.csv

code,name,status,note
C-ANCH,Anchor Distributors,active,
C-BAYL,BayLine Foods,active,
C-CEDW,Cedarworks Ltd,superseded,"re-coded to C-CEDA with effect from 2026-05-01; same legal entity, same account"
C-CEDA,Cedarworks Ltd,active,formerly C-CEDW
C-DELT,Delta Freight Co,active,
C-EAST,Eastgate Packaging,active,
C-FAIR,Fairmont Supplies,active,

policy/allocation-memo.md

Allocation memo β€” Accounts Receivable

Cash and credit notes are allocated to open invoices under the allocation policy in force. The schedule below records how each receipt was allocated. It has been worked through to 2026-05-10 and stops there; the remainder of the year has not yet been allocated.

Cash received in excess of what the customer owed at that moment is parked as unapplied. This account does not carry unapplied cash forward against invoices raised later.

Date        Voucher     Ref doc          Amount   Allocated to
----------------------------------------------------------------------------------------------------
2026-01-29  AR-00011                   1,156.82   AR-00008 1,156.82
2026-02-01  AR-00013                   3,834.66   AR-00001 3,834.66
2026-02-02  AR-00014    DOC-68947      4,985.93   AR-00010 4,985.93
2026-02-23  AR-00020    DOC-92368        254.85   AR-00007 254.85
2026-03-08  AR-00026    DOC-76092      7,483.12   AR-00024 2,192.72  AR-00021 5,290.40
2026-03-30  AR-00036    DOC-50823      8,002.65   AR-00031 8,002.65
2026-04-07  AR-00041    DOC-67928      5,143.02   AR-00031 118.39  AR-00034 3,479.60  AR-00037 1,545.03
2026-04-09  AR-00042    DOC-11992      4,408.36   AR-00006 4,408.36
2026-04-17  AR-00045                   3,864.42   AR-00001 3,864.42
2026-05-10  AR-00053    DOC-48048      8,511.74   AR-00008 5,918.13  AR-00019 2,593.61

expected output

answer.json

{
  "id": "case_01",
  "question_kind": "aged_open_after",
  "answer": "110841.80",
  "answer_kind": "money",
  "months": 6,
  "gap_month": 3,
  "gap_entries": 3
}

Scored by judge.py β€” see Scoring logic below for the full rule.

β–Έcase_027-month close, open total cp; supplement gap, decoy prior-year ledger, re-coded customer, mid-year policy change.

input

README.md

# Year-end receivables

Close out the Accounts Receivable ledger for 2026 and answer the question below.

## What is here

- `ledgers/` β€” the monthly ledger extracts for account 1200
- `policy/allocation-memo.md` β€” how receipts have been allocated so far
- `masters/counterparties.csv` β€” the customer master
- `index/documents.csv` β€” resolves the `Ref doc` column to a voucher

Not everything in `ledgers/` belongs to this year's account 1200 close. Check
what you are reading before you use it.

## Question

How much did Anchor Distributors still owe at the end of the year?

## Output

Print the answer on its own line, prefixed exactly like this:

    ANSWER: 12345.67

A plain amount, no currency symbol and no thousands separators. You may write
whatever else you like before or after that line; only the `ANSWER:` line is
read.

index/documents.csv

document_id,voucher,document_type
DOC-10805,AR-00016,invoice
DOC-11337,AR-00057,invoice
DOC-16721,AR-00027,invoice
DOC-20636,AR-00007,invoice
DOC-21397,AR-00046,invoice
DOC-27614,AR-00053,invoice
DOC-28538,AR-00017,invoice
DOC-28665,AR-00029,invoice
DOC-30002,AR-00010,invoice
DOC-30970,AR-00033,invoice
DOC-32209,AR-00065,invoice
DOC-34279,AR-00037,invoice
DOC-34444,AR-00062,invoice
DOC-35540,AR-00020,invoice
DOC-35773,AR-00023,invoice
DOC-36096,AR-00075,invoice
DOC-36852,AR-00047,invoice
DOC-37172,AR-00044,invoice
DOC-40176,AR-00008,invoice
DOC-40423,AR-00001,invoice
DOC-41859,AR-00063,invoice
DOC-44062,AR-00036,invoice
DOC-47851,AR-00022,invoice
DOC-48266,AR-00068,invoice
DOC-50805,AR-00019,invoice
DOC-53518,AR-00040,invoice
DOC-53998,AR-00061,invoice
DOC-54245,AR-00071,invoice
DOC-57332,AR-00048,invoice
DOC-58587,AR-00012,invoice
DOC-58876,AR-00014,invoice
DOC-62795,AR-00064,invoice
DOC-65599,AR-00080,invoice
DOC-66275,AR-00060,invoice
DOC-68774,AR-00049,invoice
DOC-74741,AR-00004,invoice
DOC-75510,AR-00032,invoice
DOC-76568,AR-00021,invoice
DOC-77771,AR-00034,invoice
DOC-78339,AR-00082,invoice
DOC-79127,AR-00002,invoice
DOC-84046,AR-00039,invoice
DOC-84252,AR-00058,invoice
DOC-86489,AR-00055,invoice
DOC-87691,AR-00005,invoice
DOC-88448,AR-00076,invoice
DOC-89849,AR-00003,invoice
DOC-93338,AR-00059,invoice
DOC-98487,AR-00084,invoice

ledgers/2025-12.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2025-12 (prior year)
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2025-01-05  AR-900001               Invoice raised       C-DELT      7,124.72                 7,124.72
2025-01-06  AR-900002               Invoice raised       C-DELT        385.92                 7,510.64
2025-01-08  AR-900003               Freight recharged    C-EAST      7,047.46                14,558.10
2025-01-11  AR-900004   DOC-89849   Credit note issued   C-EAST                  7,047.46     7,510.64
2025-01-14  AR-900005               Service billed       C-BAYL      2,964.07                10,474.71
2025-01-15  AR-900006               Goods dispatched     C-CEDA      2,853.12                13,327.83
2025-01-19  AR-900007               Service billed       C-BAYL      2,853.26                16,181.09
2025-01-21  AR-900008               Invoice raised       C-EAST      2,896.51                19,077.60
2025-01-22  AR-900009               Freight recharged    C-ANCH      7,407.65                26,485.25
2025-01-23  AR-900010               Payment received     C-ANCH                  5,721.79    20,763.46
2025-01-24  AR-900011   DOC-40176   Payment received     C-EAST                  2,896.51    17,866.95
2025-01-25  AR-900012               Service billed       C-BAYL      5,665.94                23,532.89
                                    Closing balance                                          23,532.89

ledgers/2026-01.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-01
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2026-01-01  AR-00001                Invoice raised       C-CEDW      3,877.06                 3,877.06
2026-01-04  AR-00002                Invoice raised       C-ANCH      3,422.96                 7,300.02
2026-01-05  AR-00003                Service billed       C-BAYL      8,165.33                15,465.35
2026-01-05  AR-00004                Late-payment charge  C-CEDW      8,035.70                23,501.05
2026-01-05  AR-00005                Service billed       C-ANCH      3,277.14                26,778.19
2026-01-06  AR-00006                Payment received     C-BAYL                  1,592.99    25,185.20
2026-01-06  AR-00007                Invoice raised       C-BAYL      6,719.76                31,904.96
2026-01-09  AR-00008                Invoice raised       C-DELT      2,573.49                34,478.45
2026-01-15  AR-00009                Settlement received  C-CEDW                    669.13    33,809.32
2026-01-24  AR-00010                Invoice raised       C-BAYL      7,790.46                41,599.78
2026-01-25  AR-00011    DOC-89849   Settlement received  C-BAYL                  3,309.81    38,289.97
2026-01-29  AR-00012                Late-payment charge  C-BAYL        785.69                39,075.66
                                    Closing balance                                          39,075.66

ledgers/2026-02.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-02
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          39,075.66
2026-02-01  AR-00013    DOC-20636   Payment received     C-BAYL                  2,326.83    36,748.83
2026-02-03  AR-00014                Freight recharged    C-FAIR        373.66                37,122.49
2026-02-08  AR-00015                Settlement received  C-DELT                  2,573.49    34,549.00
2026-02-09  AR-00016                Service billed       C-DELT      5,889.34                40,438.34
2026-02-10  AR-00017                Invoice raised       C-DELT      7,290.48                47,728.82
2026-02-11  AR-00018    DOC-40423   Settlement received  C-CEDW                  7,948.34    39,780.48
2026-02-15  AR-00019                Invoice raised       C-FAIR      7,389.02                47,169.50
2026-02-15  AR-00020                Invoice raised       C-DELT      7,013.37                54,182.87
2026-02-22  AR-00021                Invoice raised       C-FAIR      7,774.85                61,957.72
2026-02-23  AR-00022                Service billed       C-FAIR      6,759.46                68,717.18
2026-02-23  AR-00023                Invoice raised       C-EAST      5,533.01                74,250.19
2026-02-26  AR-00024    DOC-28538   Payment received     C-DELT                  5,827.58    68,422.61
                                    Closing balance                                          68,422.61

ledgers/2026-03-supplement.txt

Late-posted entries for 2026-03, booked after that month's extract was taken.
These entries are part of account 1200 and of the 2026 close.

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-03 supplement
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2026-03-29  AR-00034                Goods dispatched     C-BAYL      7,100.90                 7,100.90
2026-03-31  AR-00035    DOC-28538   Payment received     C-DELT                  7,531.90      -431.00
2026-03-31  AR-00036                Late-payment charge  C-ANCH      6,430.50                 5,999.50
                                    Closing balance                                           5,999.50

ledgers/2026-03.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-03
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          68,422.61
2026-03-10  AR-00025    DOC-35773   Refund applied       C-EAST                  3,468.34    64,954.27
2026-03-10  AR-00026                Settlement received  C-BAYL                  1,570.12    63,384.15
2026-03-11  AR-00027                Invoice raised       C-EAST      6,178.89                69,563.04
2026-03-12  AR-00028    DOC-20636   Credit note issued   C-BAYL                    892.06    68,670.98
2026-03-12  AR-00029                Freight recharged    C-CEDW      8,507.95                77,178.93
2026-03-15  AR-00030                Payment received     C-ANCH                  6,700.10    70,478.83
2026-03-17  AR-00031    DOC-28665   Settlement received  C-CEDW                    556.26    69,922.57
2026-03-19  AR-00032                Late-payment charge  C-ANCH      7,502.66                77,425.23
2026-03-22  AR-00033                Freight recharged    C-EAST      5,214.95                82,640.18
                                    Closing balance                                          82,640.18

ledgers/2026-04.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-04
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          88,639.68
2026-04-06  AR-00037                Invoice raised       C-FAIR      5,266.02                93,905.70
2026-04-07  AR-00038    DOC-20636   Payment received     C-BAYL                  7,185.39    86,720.31
2026-04-13  AR-00039                Goods dispatched     C-FAIR      4,010.91                90,731.22
2026-04-15  AR-00040                Invoice raised       C-FAIR        897.44                91,628.66
2026-04-19  AR-00041                Settlement received  C-BAYL                  1,672.20    89,956.46
2026-04-20  AR-00042    DOC-75510   Credit note issued   C-ANCH                  2,363.44    87,593.02
2026-04-23  AR-00043                Refund applied       C-FAIR                  6,774.45    80,818.57
2026-04-24  AR-00044                Invoice raised       C-FAIR      4,222.30                85,040.87
2026-04-25  AR-00045    DOC-30970   Payment received     C-EAST                    389.89    84,650.98
2026-04-26  AR-00046                Service billed       C-BAYL      2,216.65                86,867.63
2026-04-27  AR-00047                Invoice raised       C-CEDW        809.14                87,676.77
2026-04-28  AR-00048                Goods dispatched     C-FAIR      7,897.53                95,574.30
                                    Closing balance                                          95,574.30

ledgers/2026-05.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-05
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          95,574.30
2026-05-02  AR-00049                Invoice raised       C-ANCH        242.77                95,817.07
2026-05-04  AR-00050                Settlement received  C-DELT                  2,346.97    93,470.10
2026-05-11  AR-00051    DOC-10805   Payment received     C-DELT                  3,232.94    90,237.16
2026-05-13  AR-00052    DOC-30970   Credit note issued   C-EAST                  2,682.41    87,554.75
2026-05-15  AR-00053                Late-payment charge  C-EAST        244.54                87,799.29
2026-05-17  AR-00054    DOC-40423   Payment received     C-CEDA                  1,258.09    86,541.20
2026-05-20  AR-00055                Service billed       C-FAIR      4,123.21                90,664.41
2026-05-20  AR-00056    DOC-35540   Credit note issued   C-DELT                  1,253.80    89,410.61
2026-05-22  AR-00057                Service billed       C-DELT      3,871.92                93,282.53
2026-05-25  AR-00058                Goods dispatched     C-EAST      3,757.85                97,040.38
2026-05-29  AR-00059                Invoice raised       C-BAYL      5,794.47               102,834.85
2026-05-29  AR-00060                Invoice raised       C-CEDA      4,941.33               107,776.18
                                    Closing balance                                         107,776.18

ledgers/2026-06.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-06
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                         107,776.18
2026-06-03  AR-00061                Service billed       C-DELT      8,118.63               115,894.81
2026-06-03  AR-00062                Invoice raised       C-ANCH        638.11               116,532.92
2026-06-04  AR-00063                Invoice raised       C-ANCH      2,853.22               119,386.14
2026-06-05  AR-00064                Service billed       C-FAIR        987.15               120,373.29
2026-06-05  AR-00065                Invoice raised       C-DELT      4,912.72               125,286.01
2026-06-15  AR-00066    DOC-58876   Credit note issued   C-FAIR                  3,742.42   121,543.59
2026-06-15  AR-00067                Settlement received  C-ANCH                  6,806.27   114,737.32
2026-06-18  AR-00068                Goods dispatched     C-ANCH      4,583.88               119,321.20
2026-06-18  AR-00069                Settlement received  C-FAIR                  1,819.92   117,501.28
2026-06-22  AR-00070    DOC-27614   Settlement received  C-EAST                  3,229.68   114,271.60
2026-06-24  AR-00071                Service billed       C-CEDA      5,178.16               119,449.76
2026-06-29  AR-00072                Payment received     C-ANCH                  3,931.18   115,518.58
                                    Closing balance                                         115,518.58

ledgers/2026-07.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-07
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                         115,518.58
2026-07-01  AR-00073                Settlement received  C-FAIR                  2,707.37   112,811.21
2026-07-02  AR-00074    DOC-30002   Payment received     C-BAYL                  1,508.45   111,302.76
2026-07-07  AR-00075                Late-payment charge  C-CEDA      6,294.65               117,597.41
2026-07-16  AR-00076                Invoice raised       C-CEDA      6,805.89               124,403.30
2026-07-17  AR-00077    DOC-54245   Payment received     C-CEDA                  7,736.21   116,667.09
2026-07-18  AR-00078                Payment received     C-ANCH                  7,700.18   108,966.91
2026-07-19  AR-00079    DOC-40176   Credit note issued   C-DELT                  1,847.45   107,119.46
2026-07-22  AR-00080                Goods dispatched     C-FAIR      2,036.08               109,155.54
2026-07-23  AR-00081    DOC-20636   Credit note issued   C-BAYL                  7,230.19   101,925.35
2026-07-25  AR-00082                Invoice raised       C-FAIR        858.12               102,783.47
2026-07-25  AR-00083    DOC-40423   Payment received     C-CEDA                  5,036.59    97,746.88
2026-07-26  AR-00084                Invoice raised       C-CEDA      7,920.94               105,667.82
                                    Closing balance                                         105,667.82

masters/counterparties.csv

code,name,status,note
C-ANCH,Anchor Distributors,active,
C-BAYL,BayLine Foods,active,
C-CEDW,Cedarworks Ltd,superseded,"re-coded to C-CEDA with effect from 2026-05-01; same legal entity, same account"
C-CEDA,Cedarworks Ltd,active,formerly C-CEDW
C-DELT,Delta Freight Co,active,
C-EAST,Eastgate Packaging,active,
C-FAIR,Fairmont Supplies,active,

policy/allocation-memo.md

Allocation memo β€” Accounts Receivable

Cash and credit notes are allocated to open invoices under the allocation policy in force. The schedule below records how each receipt was allocated. It has been worked through to 2026-04-07 and stops there; the remainder of the year has not yet been allocated.

Cash received in excess of what the customer owed at that moment is parked as unapplied. This account does not carry unapplied cash forward against invoices raised later.

Date        Voucher     Ref doc          Amount   Allocated to
----------------------------------------------------------------------------------------------------
2026-01-06  AR-00006                   1,592.99   AR-00003 1,592.99
2026-01-15  AR-00009                     669.13   AR-00001 669.13
2026-01-25  AR-00011    DOC-89849      3,309.81   AR-00003 3,309.81
2026-02-01  AR-00013    DOC-20636      2,326.83   AR-00007 2,326.83
2026-02-08  AR-00015                   2,573.49   AR-00008 2,573.49
2026-02-11  AR-00018    DOC-40423      7,948.34   AR-00001 3,207.93  AR-00004 4,740.41
2026-02-26  AR-00024    DOC-28538      5,827.58   AR-00017 5,827.58
2026-03-10  AR-00025    DOC-35773      3,468.34   AR-00023 3,468.34
2026-03-10  AR-00026                   1,570.12   AR-00003 1,570.12
2026-03-12  AR-00028    DOC-20636        892.06   AR-00007 892.06
2026-03-15  AR-00030                   6,700.10   AR-00002 3,422.96  AR-00005 3,277.14
2026-03-17  AR-00031    DOC-28665        556.26   AR-00004 556.26
2026-03-31  AR-00035    DOC-28538      7,531.90   AR-00016 5,889.34  AR-00017 1,462.90  AR-00020 179.66
2026-04-07  AR-00038    DOC-20636      7,185.39   AR-00003 1,692.41  AR-00007 3,500.87  AR-00010 1,992.11

expected output

answer.json

{
  "id": "case_02",
  "question_kind": "open_total_cp",
  "answer": "1450.07",
  "answer_kind": "money",
  "months": 7,
  "gap_month": 3,
  "gap_entries": 3
}

Scored by judge.py β€” see Scoring logic below for the full rule.

β–Έcase_036-month close, settled total; supplement gap, decoy prior-year ledger, re-coded customer, mid-year policy change.

input

README.md

# Year-end receivables

Close out the Accounts Receivable ledger for 2026 and answer the question below.

## What is here

- `ledgers/` β€” the monthly ledger extracts for account 1200
- `policy/allocation-memo.md` β€” how receipts have been allocated so far
- `masters/counterparties.csv` β€” the customer master
- `index/documents.csv` β€” resolves the `Ref doc` column to a voucher

Not everything in `ledgers/` belongs to this year's account 1200 close. Check
what you are reading before you use it.

## Question

How much of everything billed during the year had been settled in full by the end of it?

## Output

Print the answer on its own line, prefixed exactly like this:

    ANSWER: 12345.67

A plain amount, no currency symbol and no thousands separators. You may write
whatever else you like before or after that line; only the `ANSWER:` line is
read.

index/documents.csv

document_id,voucher,document_type
DOC-10991,AR-00016,invoice
DOC-12809,AR-00023,invoice
DOC-14204,AR-00015,invoice
DOC-14579,AR-00057,invoice
DOC-17150,AR-00080,invoice
DOC-17253,AR-00048,invoice
DOC-19457,AR-00024,invoice
DOC-23170,AR-00003,invoice
DOC-25425,AR-00027,invoice
DOC-32477,AR-00039,invoice
DOC-32763,AR-00022,invoice
DOC-33934,AR-00014,invoice
DOC-34133,AR-00074,invoice
DOC-35046,AR-00045,invoice
DOC-36760,AR-00008,invoice
DOC-37933,AR-00002,invoice
DOC-41000,AR-00056,invoice
DOC-42551,AR-00012,invoice
DOC-43421,AR-00053,invoice
DOC-44672,AR-00059,invoice
DOC-47008,AR-00007,invoice
DOC-48150,AR-00009,invoice
DOC-48867,AR-00083,invoice
DOC-49704,AR-00035,invoice
DOC-50307,AR-00078,invoice
DOC-53665,AR-00033,invoice
DOC-55925,AR-00063,invoice
DOC-56511,AR-00072,invoice
DOC-56743,AR-00070,invoice
DOC-58945,AR-00043,invoice
DOC-60519,AR-00082,invoice
DOC-64276,AR-00019,invoice
DOC-67043,AR-00076,invoice
DOC-71617,AR-00042,invoice
DOC-72293,AR-00021,invoice
DOC-73115,AR-00051,invoice
DOC-74773,AR-00075,invoice
DOC-74932,AR-00011,invoice
DOC-76715,AR-00050,invoice
DOC-80330,AR-00004,invoice
DOC-84392,AR-00036,invoice
DOC-86178,AR-00077,invoice
DOC-86714,AR-00038,invoice
DOC-86964,AR-00025,invoice
DOC-90103,AR-00001,invoice
DOC-91797,AR-00068,invoice
DOC-95516,AR-00058,invoice
DOC-97732,AR-00028,invoice
DOC-97892,AR-00081,invoice
DOC-98007,AR-00061,invoice
DOC-98959,AR-00029,invoice

ledgers/2025-12.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2025-12 (prior year)
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2025-01-07  AR-900001               Goods dispatched     C-EAST      5,728.22                 5,728.22
2025-01-08  AR-900002               Invoice raised       C-ANCH      7,978.33                13,706.55
2025-01-10  AR-900003               Goods dispatched     C-CEDA      3,793.94                17,500.49
2025-01-11  AR-900004               Invoice raised       C-DELT      9,213.95                26,714.44
2025-01-14  AR-900005               Service billed       C-ANCH      5,591.72                32,306.16
2025-01-15  AR-900006               Goods dispatched     C-CEDA      4,645.08                36,951.24
2025-01-15  AR-900007               Settlement received  C-ANCH                  7,849.53    29,101.71
2025-01-17  AR-900008               Goods dispatched     C-BAYL      8,778.24                37,879.95
2025-01-20  AR-900009   DOC-23170   Payment received     C-CEDA                  2,755.85    35,124.10
2025-01-21  AR-900010               Late-payment charge  C-ANCH      4,447.48                39,571.58
2025-01-23  AR-900011   DOC-36760   Payment received     C-BAYL                  5,781.25    33,790.33
2025-01-27  AR-900012               Invoice raised       C-FAIR      2,095.15                35,885.48
2025-01-28  AR-900013               Service billed       C-FAIR      7,645.62                43,531.10
2025-01-28  AR-900014               Payment received     C-ANCH                  7,317.66    36,213.44
                                    Closing balance                                          36,213.44

ledgers/2026-01.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-01
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2026-01-02  AR-00001                Service billed       C-BAYL      6,787.16                 6,787.16
2026-01-03  AR-00002                Goods dispatched     C-ANCH      3,493.96                10,281.12
2026-01-05  AR-00003                Goods dispatched     C-FAIR      9,126.45                19,407.57
2026-01-08  AR-00004                Goods dispatched     C-DELT        288.32                19,695.89
2026-01-08  AR-00005    DOC-23170   Payment received     C-FAIR                  5,061.75    14,634.14
2026-01-08  AR-00006    DOC-23170   Payment received     C-FAIR                  1,583.00    13,051.14
2026-01-10  AR-00007                Invoice raised       C-CEDW      8,500.12                21,551.26
2026-01-11  AR-00008                Service billed       C-BAYL      2,798.91                24,350.17
2026-01-12  AR-00009                Late-payment charge  C-EAST      3,588.87                27,939.04
2026-01-18  AR-00010    DOC-36760   Settlement received  C-BAYL                  5,429.55    22,509.49
2026-01-25  AR-00011                Goods dispatched     C-FAIR      1,151.83                23,661.32
2026-01-26  AR-00012                Freight recharged    C-CEDW        907.61                24,568.93
2026-01-29  AR-00013                Refund applied       C-DELT                    288.32    24,280.61
2026-01-31  AR-00014                Invoice raised       C-DELT      4,194.32                28,474.93
                                    Closing balance                                          28,474.93

ledgers/2026-02.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-02
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          28,474.93
2026-02-02  AR-00015                Invoice raised       C-FAIR      4,594.53                33,069.46
2026-02-02  AR-00016                Service billed       C-CEDW      2,869.60                35,939.06
2026-02-07  AR-00017    DOC-90103   Credit note issued   C-BAYL                  4,156.52    31,782.54
2026-02-13  AR-00018    DOC-37933   Payment received     C-ANCH                  3,493.96    28,288.58
2026-02-16  AR-00019                Late-payment charge  C-BAYL      9,124.70                37,413.28
2026-02-16  AR-00020                Payment received     C-FAIR                  3,589.57    33,823.71
2026-02-19  AR-00021                Service billed       C-FAIR      3,406.14                37,229.85
2026-02-19  AR-00022                Goods dispatched     C-FAIR      7,003.53                44,233.38
2026-02-21  AR-00023                Invoice raised       C-EAST      4,461.61                48,694.99
2026-02-25  AR-00024                Goods dispatched     C-ANCH      1,767.79                50,462.78
2026-02-25  AR-00025                Freight recharged    C-FAIR      7,395.11                57,857.89
2026-02-27  AR-00026    DOC-74932   Payment received     C-FAIR                    399.72    57,458.17
2026-02-27  AR-00027                Invoice raised       C-BAYL        245.30                57,703.47
2026-02-27  AR-00028                Invoice raised       C-CEDW      3,799.06                61,502.53
                                    Closing balance                                          61,502.53

ledgers/2026-03-supplement.txt

Late-posted entries for 2026-03, booked after that month's extract was taken.
These entries are part of account 1200 and of the 2026 close.

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-03 supplement
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2026-03-28  AR-00040    DOC-25425   Discount allowed     C-BAYL                  3,138.94    -3,138.94
2026-03-29  AR-00041                Settlement received  C-BAYL                  1,050.82    -4,189.76
2026-03-30  AR-00042                Service billed       C-ANCH      2,704.46                -1,485.30
                                    Closing balance                                          -1,485.30

ledgers/2026-03.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-03
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          61,502.53
2026-03-02  AR-00029                Service billed       C-DELT      2,317.55                63,820.08
2026-03-04  AR-00030    DOC-12809   Credit note issued   C-EAST                  1,606.27    62,213.81
2026-03-04  AR-00031    DOC-42551   Payment received     C-CEDW                  6,526.70    55,687.11
2026-03-04  AR-00032    DOC-12809   Credit note issued   C-EAST                  6,444.21    49,242.90
2026-03-07  AR-00033                Invoice raised       C-ANCH      3,836.00                53,078.90
2026-03-13  AR-00034                Payment received     C-BAYL                  5,180.24    47,898.66
2026-03-14  AR-00035                Goods dispatched     C-DELT      8,833.48                56,732.14
2026-03-15  AR-00036                Goods dispatched     C-ANCH      4,454.52                61,186.66
2026-03-17  AR-00037    DOC-32763   Payment received     C-FAIR                    429.43    60,757.23
2026-03-21  AR-00038                Goods dispatched     C-DELT      1,920.42                62,677.65
2026-03-25  AR-00039                Service billed       C-ANCH      8,354.61                71,032.26
                                    Closing balance                                          71,032.26

ledgers/2026-04.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-04
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          69,546.96
2026-04-01  AR-00043                Goods dispatched     C-EAST      2,003.51                71,550.47
2026-04-07  AR-00044                Payment received     C-ANCH                  1,351.31    70,199.16
2026-04-09  AR-00045                Invoice raised       C-BAYL      2,972.43                73,171.59
2026-04-12  AR-00046    DOC-37933   Payment received     C-ANCH                  4,479.99    68,691.60
2026-04-12  AR-00047    DOC-97732   Payment received     C-CEDW                    991.09    67,700.51
2026-04-13  AR-00048                Invoice raised       C-DELT      6,779.25                74,479.76
2026-04-13  AR-00049    DOC-58945   Settlement received  C-EAST                  2,003.51    72,476.25
2026-04-19  AR-00050                Invoice raised       C-EAST      2,664.82                75,141.07
2026-04-21  AR-00051                Service billed       C-BAYL      1,668.45                76,809.52
2026-04-24  AR-00052    DOC-84392   Credit note issued   C-ANCH                  4,118.61    72,690.91
2026-04-25  AR-00053                Invoice raised       C-FAIR      1,682.32                74,373.23
2026-04-28  AR-00054                Settlement received  C-FAIR                  9,296.42    65,076.81
2026-04-29  AR-00055    DOC-76715   Payment received     C-EAST                  1,982.75    63,094.06
2026-04-30  AR-00056                Invoice raised       C-ANCH      3,890.32                66,984.38
                                    Closing balance                                          66,984.38

ledgers/2026-05.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-05
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          66,984.38
2026-05-04  AR-00057                Goods dispatched     C-EAST      4,929.92                71,914.30
2026-05-05  AR-00058                Invoice raised       C-FAIR      3,940.25                75,854.55
2026-05-06  AR-00059                Service billed       C-ANCH      8,838.80                84,693.35
2026-05-07  AR-00060                Payment received     C-ANCH                  1,126.30    83,567.05
2026-05-10  AR-00061                Goods dispatched     C-ANCH      4,089.38                87,656.43
2026-05-10  AR-00062    DOC-98959   Discount allowed     C-DELT                  2,023.02    85,633.41
2026-05-13  AR-00063                Freight recharged    C-DELT      2,531.13                88,164.54
2026-05-16  AR-00064    DOC-84392   Settlement received  C-ANCH                  2,548.76    85,615.78
2026-05-18  AR-00065    DOC-43421   Credit note issued   C-FAIR                  1,131.17    84,484.61
2026-05-23  AR-00066                Settlement received  C-FAIR                  1,467.29    83,017.32
2026-05-27  AR-00067    DOC-47008   Payment received     C-CEDA                  3,546.36    79,470.96
2026-05-28  AR-00068                Invoice raised       C-DELT      5,559.62                85,030.58
2026-05-29  AR-00069    DOC-48150   Payment received     C-EAST                  5,611.99    79,418.59
2026-05-29  AR-00070                Invoice raised       C-FAIR      8,123.19                87,541.78
                                    Closing balance                                          87,541.78

ledgers/2026-06.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-06
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          87,541.78
2026-06-01  AR-00071    DOC-44672   Credit note issued   C-ANCH                  3,606.54    83,935.24
2026-06-01  AR-00072                Goods dispatched     C-DELT      1,711.80                85,647.04
2026-06-02  AR-00073    DOC-10991   Payment received     C-CEDA                  3,934.28    81,712.76
2026-06-06  AR-00074                Invoice raised       C-CEDA      7,702.41                89,415.17
2026-06-12  AR-00075                Invoice raised       C-BAYL      2,186.52                91,601.69
2026-06-12  AR-00076                Service billed       C-BAYL      1,316.05                92,917.74
2026-06-15  AR-00077                Service billed       C-BAYL      9,284.93               102,202.67
2026-06-16  AR-00078                Service billed       C-BAYL      5,606.42               107,809.09
2026-06-17  AR-00079    DOC-90103   Credit note issued   C-BAYL                  8,734.91    99,074.18
2026-06-21  AR-00080                Service billed       C-ANCH      4,023.09               103,097.27
2026-06-23  AR-00081                Invoice raised       C-DELT      5,718.05               108,815.32
2026-06-25  AR-00082                Goods dispatched     C-EAST      7,042.93               115,858.25
2026-06-27  AR-00083                Invoice raised       C-FAIR      5,609.89               121,468.14
2026-06-29  AR-00084    DOC-60519   Payment received     C-EAST                  3,468.47   117,999.67
                                    Closing balance                                         117,999.67

masters/counterparties.csv

code,name,status,note
C-ANCH,Anchor Distributors,active,
C-BAYL,BayLine Foods,active,
C-CEDW,Cedarworks Ltd,superseded,"re-coded to C-CEDA with effect from 2026-05-01; same legal entity, same account"
C-CEDA,Cedarworks Ltd,active,formerly C-CEDW
C-DELT,Delta Freight Co,active,
C-EAST,Eastgate Packaging,active,
C-FAIR,Fairmont Supplies,active,

policy/allocation-memo.md

Allocation memo β€” Accounts Receivable

Cash and credit notes are allocated to open invoices under the allocation policy in force. The schedule below records how each receipt was allocated. It has been worked through to 2026-04-12 and stops there; the remainder of the year has not yet been allocated.

Cash received in excess of what the customer owed at that moment is parked as unapplied. This account does not carry unapplied cash forward against invoices raised later.

Date        Voucher     Ref doc          Amount   Allocated to
----------------------------------------------------------------------------------------------------
2026-01-08  AR-00005    DOC-23170      5,061.75   AR-00003 5,061.75
2026-01-08  AR-00006    DOC-23170      1,583.00   AR-00003 1,583.00
2026-01-18  AR-00010    DOC-36760      5,429.55   AR-00008 2,798.91  AR-00001 2,630.64
2026-01-29  AR-00013                     288.32   AR-00004 288.32
2026-02-07  AR-00017    DOC-90103      4,156.52   AR-00001 4,156.52
2026-02-13  AR-00018    DOC-37933      3,493.96   AR-00002 3,493.96
2026-02-16  AR-00020                   3,589.57   AR-00003 2,481.70  AR-00011 1,107.87
2026-02-27  AR-00026    DOC-74932        399.72   AR-00011 43.96  AR-00015 355.76
2026-03-04  AR-00030    DOC-12809      1,606.27   AR-00023 1,606.27
2026-03-04  AR-00031    DOC-42551      6,526.70   AR-00012 907.61  AR-00007 5,619.09
2026-03-04  AR-00032    DOC-12809      6,444.21   AR-00023 2,855.34  AR-00009 3,588.87
2026-03-13  AR-00034                   5,180.24   AR-00019 5,180.24
2026-03-17  AR-00037    DOC-32763        429.43   AR-00015 429.43
2026-03-28  AR-00040    DOC-25425      3,138.94   AR-00019 3,138.94
2026-03-29  AR-00041                   1,050.82   AR-00019 805.52  AR-00027 245.30
2026-04-07  AR-00044                   1,351.31   AR-00024 1,351.31
2026-04-12  AR-00046    DOC-37933      4,479.99   AR-00024 416.48  AR-00033 3,836.00  AR-00036 227.51
2026-04-12  AR-00047    DOC-97732        991.09   AR-00007 991.09

expected output

answer.json

{
  "id": "case_03",
  "question_kind": "settled_total",
  "answer": "89145.12",
  "answer_kind": "money",
  "months": 6,
  "gap_month": 3,
  "gap_entries": 3
}

Scored by judge.py β€” see Scoring logic below for the full rule.

β–Έcase_047-month close, aged open after; supplement gap, decoy prior-year ledger, re-coded customer, mid-year policy change.

input

README.md

# Year-end receivables

Close out the Accounts Receivable ledger for 2026 and answer the question below.

## What is here

- `ledgers/` β€” the monthly ledger extracts for account 1200
- `policy/allocation-memo.md` β€” how receipts have been allocated so far
- `masters/counterparties.csv` β€” the customer master
- `index/documents.csv` β€” resolves the `Ref doc` column to a voucher

Not everything in `ledgers/` belongs to this year's account 1200 close. Check
what you are reading before you use it.

## Question

How much was still owed at the end of the year on invoices billed on or after 2026-05-01?

## Output

Print the answer on its own line, prefixed exactly like this:

    ANSWER: 12345.67

A plain amount, no currency symbol and no thousands separators. You may write
whatever else you like before or after that line; only the `ANSWER:` line is
read.

index/documents.csv

document_id,voucher,document_type
DOC-10310,AR-00009,invoice
DOC-10568,AR-00077,invoice
DOC-12692,AR-00075,invoice
DOC-13083,AR-00010,invoice
DOC-15804,AR-00067,invoice
DOC-17019,AR-00031,invoice
DOC-17983,AR-00054,invoice
DOC-18544,AR-00022,invoice
DOC-20835,AR-00045,invoice
DOC-22336,AR-00007,invoice
DOC-24770,AR-00052,invoice
DOC-25239,AR-00008,invoice
DOC-28447,AR-00039,invoice
DOC-29844,AR-00079,invoice
DOC-34569,AR-00048,invoice
DOC-38644,AR-00036,invoice
DOC-39980,AR-00073,invoice
DOC-40648,AR-00035,invoice
DOC-43499,AR-00025,invoice
DOC-44234,AR-00026,invoice
DOC-45240,AR-00029,invoice
DOC-48308,AR-00091,invoice
DOC-48951,AR-00074,invoice
DOC-51069,AR-00081,invoice
DOC-53285,AR-00001,invoice
DOC-53397,AR-00068,invoice
DOC-54923,AR-00033,invoice
DOC-54963,AR-00003,invoice
DOC-57952,AR-00002,invoice
DOC-59157,AR-00020,invoice
DOC-59794,AR-00057,invoice
DOC-60337,AR-00066,invoice
DOC-61389,AR-00006,invoice
DOC-61794,AR-00016,invoice
DOC-61907,AR-00013,invoice
DOC-63087,AR-00086,invoice
DOC-63684,AR-00064,invoice
DOC-63892,AR-00090,invoice
DOC-64299,AR-00040,invoice
DOC-66471,AR-00047,invoice
DOC-70995,AR-00088,invoice
DOC-74858,AR-00053,invoice
DOC-75750,AR-00018,invoice
DOC-76735,AR-00062,invoice
DOC-76823,AR-00037,invoice
DOC-77782,AR-00076,invoice
DOC-82365,AR-00032,invoice
DOC-83615,AR-00014,invoice
DOC-84280,AR-00050,invoice
DOC-84436,AR-00028,invoice
DOC-87096,AR-00056,invoice
DOC-89280,AR-00004,invoice
DOC-90556,AR-00041,invoice
DOC-91850,AR-00059,invoice
DOC-92152,AR-00063,invoice
DOC-92763,AR-00015,invoice
DOC-95645,AR-00017,invoice
DOC-96203,AR-00055,invoice
DOC-96765,AR-00089,invoice
DOC-96934,AR-00012,invoice
DOC-97528,AR-00034,invoice

ledgers/2025-12.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2025-12 (prior year)
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2025-01-05  AR-900001               Invoice raised       C-EAST      4,797.33                 4,797.33
2025-01-08  AR-900002   DOC-53285   Payment received     C-EAST                  4,057.86       739.47
2025-01-09  AR-900003               Freight recharged    C-DELT        538.17                 1,277.64
2025-01-13  AR-900004               Goods dispatched     C-EAST      7,597.96                 8,875.60
2025-01-14  AR-900005               Invoice raised       C-BAYL      5,351.33                14,226.93
2025-01-17  AR-900006   DOC-54963   Settlement received  C-DELT                    538.17    13,688.76
2025-01-25  AR-900007               Late-payment charge  C-EAST      1,033.47                14,722.23
2025-01-25  AR-900008               Settlement received  C-BAYL                  3,187.06    11,535.17
2025-01-26  AR-900009               Freight recharged    C-DELT      7,572.64                19,107.81
2025-01-26  AR-900010               Payment received     C-EAST                  7,077.42    12,030.39
2025-01-28  AR-900011               Invoice raised       C-EAST      1,141.03                13,171.42
2025-01-28  AR-900012               Invoice raised       C-ANCH      1,392.99                14,564.41
2025-01-30  AR-900013               Invoice raised       C-DELT      2,284.03                16,848.44
                                    Closing balance                                          16,848.44

ledgers/2026-01.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-01
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2026-01-03  AR-00001                Invoice raised       C-ANCH      8,569.36                 8,569.36
2026-01-05  AR-00002                Invoice raised       C-DELT      6,839.72                15,409.08
2026-01-05  AR-00003                Invoice raised       C-BAYL      3,998.94                19,408.02
2026-01-07  AR-00004                Service billed       C-EAST      1,331.95                20,739.97
2026-01-09  AR-00005                Payment received     C-DELT                  1,061.24    19,678.73
2026-01-11  AR-00006                Invoice raised       C-BAYL      5,150.85                24,829.58
2026-01-11  AR-00007                Late-payment charge  C-CEDW      2,093.52                26,923.10
2026-01-13  AR-00008                Goods dispatched     C-ANCH      3,826.51                30,749.61
2026-01-21  AR-00009                Invoice raised       C-CEDW      4,881.29                35,630.90
2026-01-25  AR-00010                Invoice raised       C-DELT        715.57                36,346.47
2026-01-26  AR-00011                Payment received     C-EAST                  1,331.95    35,014.52
2026-01-26  AR-00012                Goods dispatched     C-FAIR      8,591.74                43,606.26
2026-01-30  AR-00013                Invoice raised       C-EAST      6,082.39                49,688.65
                                    Closing balance                                          49,688.65

ledgers/2026-02.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-02
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          49,688.65
2026-02-01  AR-00014                Invoice raised       C-DELT      3,706.41                53,395.06
2026-02-03  AR-00015                Invoice raised       C-DELT      9,202.53                62,597.59
2026-02-06  AR-00016                Service billed       C-DELT      8,778.97                71,376.56
2026-02-08  AR-00017                Goods dispatched     C-ANCH      3,327.93                74,704.49
2026-02-10  AR-00018                Late-payment charge  C-BAYL      1,157.83                75,862.32
2026-02-11  AR-00019                Settlement received  C-EAST                  1,779.08    74,083.24
2026-02-14  AR-00020                Invoice raised       C-DELT      5,647.32                79,730.56
2026-02-15  AR-00021    DOC-61907   Payment received     C-EAST                  4,303.31    75,427.25
2026-02-17  AR-00022                Goods dispatched     C-CEDW      6,482.46                81,909.71
2026-02-17  AR-00023    DOC-95645   Credit note issued   C-ANCH                  8,597.79    73,311.92
2026-02-19  AR-00024    DOC-61389   Discount allowed     C-BAYL                  5,370.59    67,941.33
2026-02-23  AR-00025                Invoice raised       C-FAIR      2,344.99                70,286.32
2026-02-28  AR-00026                Goods dispatched     C-CEDW      3,212.76                73,499.08
                                    Closing balance                                          73,499.08

ledgers/2026-03.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-03
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          73,499.08
2026-03-05  AR-00027    DOC-18544   Settlement received  C-CEDW                  4,122.72    69,376.36
2026-03-06  AR-00028                Goods dispatched     C-EAST      3,721.61                73,097.97
2026-03-09  AR-00029                Invoice raised       C-ANCH      8,335.40                81,433.37
2026-03-09  AR-00030    DOC-59157   Refund applied       C-DELT                  3,087.62    78,345.75
2026-03-10  AR-00031                Invoice raised       C-BAYL      6,557.51                84,903.26
2026-03-10  AR-00032                Service billed       C-BAYL      3,463.95                88,367.21
2026-03-11  AR-00033                Goods dispatched     C-BAYL      2,300.80                90,668.01
2026-03-15  AR-00034                Service billed       C-CEDW      6,386.38                97,054.39
2026-03-16  AR-00035                Goods dispatched     C-FAIR      8,650.83               105,705.22
2026-03-22  AR-00036                Goods dispatched     C-EAST      6,964.42               112,669.64
2026-03-25  AR-00037                Service billed       C-CEDW      7,569.39               120,239.03
2026-03-25  AR-00038    DOC-84436   Credit note issued   C-EAST                  5,190.62   115,048.41
2026-03-30  AR-00039                Goods dispatched     C-CEDW      9,170.31               124,218.72
                                    Closing balance                                         124,218.72

ledgers/2026-04-supplement.txt

Late-posted entries for 2026-04, booked after that month's extract was taken.
These entries are part of account 1200 and of the 2026 close.

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-04 supplement
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2026-04-22  AR-00050                Freight recharged    C-EAST      4,089.93                 4,089.93
2026-04-26  AR-00051    DOC-13083   Payment received     C-DELT                  7,817.70    -3,727.77
2026-04-30  AR-00052                Goods dispatched     C-ANCH      2,416.98                -1,310.79
                                    Closing balance                                          -1,310.79

ledgers/2026-04.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-04
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                         124,218.72
2026-04-01  AR-00040                Invoice raised       C-FAIR      7,755.52               131,974.24
2026-04-04  AR-00041                Late-payment charge  C-FAIR      5,674.72               137,648.96
2026-04-05  AR-00042                Payment received     C-EAST                  5,495.41   132,153.55
2026-04-07  AR-00043    DOC-59157   Settlement received  C-DELT                  3,501.17   128,652.38
2026-04-09  AR-00044    DOC-97528   Payment received     C-CEDW                  8,853.52   119,798.86
2026-04-12  AR-00045                Service billed       C-BAYL      9,069.70               128,868.56
2026-04-18  AR-00046                Payment received     C-FAIR                  2,114.65   126,753.91
2026-04-20  AR-00047                Late-payment charge  C-ANCH      4,957.36               131,711.27
2026-04-20  AR-00048                Invoice raised       C-DELT      4,936.47               136,647.74
2026-04-22  AR-00049    DOC-64299   Settlement received  C-FAIR                  8,183.79   128,463.95
                                    Closing balance                                         128,463.95

ledgers/2026-05.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-05
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                         127,153.16
2026-05-01  AR-00053                Invoice raised       C-FAIR      3,963.90               131,117.06
2026-05-01  AR-00054                Goods dispatched     C-BAYL      7,364.12               138,481.18
2026-05-01  AR-00055                Service billed       C-FAIR      1,806.15               140,287.33
2026-05-02  AR-00056                Service billed       C-ANCH      8,760.45               149,047.78
2026-05-05  AR-00057                Invoice raised       C-FAIR      2,350.49               151,398.27
2026-05-06  AR-00058    DOC-61794   Credit note issued   C-DELT                  7,092.09   144,306.18
2026-05-07  AR-00059                Late-payment charge  C-FAIR      8,918.97               153,225.15
2026-05-09  AR-00060    DOC-61794   Settlement received  C-DELT                  7,385.76   145,839.39
2026-05-13  AR-00061                Payment received     C-ANCH                  1,950.76   143,888.63
2026-05-16  AR-00062                Freight recharged    C-FAIR      5,919.56               149,808.19
2026-05-20  AR-00063                Invoice raised       C-DELT        350.32               150,158.51
2026-05-28  AR-00064                Invoice raised       C-DELT      3,431.16               153,589.67
2026-05-28  AR-00065    DOC-97528   Payment received     C-CEDA                  2,547.01   151,042.66
                                    Closing balance                                         151,042.66

ledgers/2026-06.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-06
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                         151,042.66
2026-06-05  AR-00066                Invoice raised       C-BAYL      7,201.45               158,244.11
2026-06-05  AR-00067                Invoice raised       C-BAYL      3,808.89               162,053.00
2026-06-10  AR-00068                Service billed       C-CEDA      2,874.54               164,927.54
2026-06-11  AR-00069    DOC-22336   Settlement received  C-CEDA                  9,075.99   155,851.55
2026-06-12  AR-00070                Payment received     C-EAST                  2,926.97   152,924.58
2026-06-13  AR-00071    DOC-84280   Payment received     C-EAST                  1,162.96   151,761.62
2026-06-15  AR-00072                Payment received     C-CEDA                  2,288.74   149,472.88
2026-06-15  AR-00073                Invoice raised       C-DELT      6,035.61               155,508.49
2026-06-16  AR-00074                Freight recharged    C-CEDA      7,465.21               162,973.70
2026-06-19  AR-00075                Invoice raised       C-EAST      2,126.18               165,099.88
2026-06-21  AR-00076                Freight recharged    C-BAYL      3,360.72               168,460.60
2026-06-27  AR-00077                Goods dispatched     C-FAIR      1,201.90               169,662.50
2026-06-29  AR-00078                Payment received     C-EAST                  2,126.18   167,536.32
                                    Closing balance                                         167,536.32

ledgers/2026-07.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-07
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                         167,536.32
2026-07-02  AR-00079                Invoice raised       C-EAST      7,255.67               174,791.99
2026-07-03  AR-00080    DOC-76735   Settlement received  C-FAIR                  7,408.50   167,383.49
2026-07-04  AR-00081                Goods dispatched     C-EAST      5,523.47               172,906.96
2026-07-08  AR-00082    DOC-63684   Payment received     C-DELT                  1,156.14   171,750.82
2026-07-08  AR-00083    DOC-53397   Payment received     C-CEDA                  8,992.13   162,758.69
2026-07-10  AR-00084    DOC-40648   Payment received     C-FAIR                  8,399.77   154,358.92
2026-07-14  AR-00085                Payment received     C-ANCH                  7,167.32   147,191.60
2026-07-19  AR-00086                Freight recharged    C-FAIR      2,931.75               150,123.35
2026-07-23  AR-00087    DOC-48951   Credit note issued   C-CEDA                  9,185.05   140,938.30
2026-07-25  AR-00088                Goods dispatched     C-DELT      4,131.05               145,069.35
2026-07-28  AR-00089                Freight recharged    C-BAYL      3,523.10               148,592.45
2026-07-30  AR-00090                Late-payment charge  C-EAST      7,364.45               155,956.90
2026-07-31  AR-00091                Invoice raised       C-FAIR      4,800.51               160,757.41
                                    Closing balance                                         160,757.41

masters/counterparties.csv

code,name,status,note
C-ANCH,Anchor Distributors,active,
C-BAYL,BayLine Foods,active,
C-CEDW,Cedarworks Ltd,superseded,"re-coded to C-CEDA with effect from 2026-05-01; same legal entity, same account"
C-CEDA,Cedarworks Ltd,active,formerly C-CEDW
C-DELT,Delta Freight Co,active,
C-EAST,Eastgate Packaging,active,
C-FAIR,Fairmont Supplies,active,

policy/allocation-memo.md

Allocation memo β€” Accounts Receivable

Cash and credit notes are allocated to open invoices under the allocation policy in force. The schedule below records how each receipt was allocated. It has been worked through to 2026-04-22 and stops there; the remainder of the year has not yet been allocated.

Cash received in excess of what the customer owed at that moment is parked as unapplied. This account does not carry unapplied cash forward against invoices raised later.

Date        Voucher     Ref doc          Amount   Allocated to
----------------------------------------------------------------------------------------------------
2026-01-09  AR-00005                   1,061.24   AR-00002 1,061.24
2026-01-26  AR-00011                   1,331.95   AR-00004 1,331.95
2026-02-11  AR-00019                   1,779.08   AR-00013 1,779.08
2026-02-15  AR-00021    DOC-61907      4,303.31   AR-00013 4,303.31
2026-02-17  AR-00023    DOC-95645      8,597.79   AR-00017 3,327.93  AR-00001 5,269.86
2026-02-19  AR-00024    DOC-61389      5,370.59   AR-00006 5,150.85  AR-00003 219.74
2026-03-05  AR-00027    DOC-18544      4,122.72   AR-00022 4,122.72
2026-03-09  AR-00030    DOC-59157      3,087.62   AR-00020 3,087.62
2026-03-25  AR-00038    DOC-84436      5,190.62   AR-00028 3,721.61  AR-00036 1,469.01
2026-04-05  AR-00042                   5,495.41   AR-00036 5,495.41
2026-04-07  AR-00043    DOC-59157      3,501.17   AR-00002 3,501.17
2026-04-09  AR-00044    DOC-97528      8,853.52   AR-00007 2,093.52  AR-00009 4,881.29  AR-00022 1,878.71
2026-04-18  AR-00046                   2,114.65   AR-00012 2,114.65
2026-04-22  AR-00049    DOC-64299      8,183.79   AR-00012 6,477.09  AR-00025 1,706.70

expected output

answer.json

{
  "id": "case_04",
  "question_kind": "aged_open_after",
  "answer": "105074.39",
  "answer_kind": "money",
  "months": 7,
  "gap_month": 4,
  "gap_entries": 3
}

Scored by judge.py β€” see Scoring logic below for the full rule.

β–Έcase_056-month close, open total cp; supplement gap, decoy prior-year ledger, re-coded customer, mid-year policy change.

input

README.md

# Year-end receivables

Close out the Accounts Receivable ledger for 2026 and answer the question below.

## What is here

- `ledgers/` β€” the monthly ledger extracts for account 1200
- `policy/allocation-memo.md` β€” how receipts have been allocated so far
- `masters/counterparties.csv` β€” the customer master
- `index/documents.csv` β€” resolves the `Ref doc` column to a voucher

Not everything in `ledgers/` belongs to this year's account 1200 close. Check
what you are reading before you use it.

## Question

How much did BayLine Foods still owe at the end of the year?

## Output

Print the answer on its own line, prefixed exactly like this:

    ANSWER: 12345.67

A plain amount, no currency symbol and no thousands separators. You may write
whatever else you like before or after that line; only the `ANSWER:` line is
read.

index/documents.csv

document_id,voucher,document_type
DOC-13464,AR-00012,invoice
DOC-18990,AR-00066,invoice
DOC-20105,AR-00059,invoice
DOC-20678,AR-00030,invoice
DOC-21763,AR-00018,invoice
DOC-22698,AR-00040,invoice
DOC-23086,AR-00043,invoice
DOC-30552,AR-00058,invoice
DOC-30748,AR-00037,invoice
DOC-33580,AR-00060,invoice
DOC-33621,AR-00016,invoice
DOC-36420,AR-00057,invoice
DOC-37049,AR-00026,invoice
DOC-37152,AR-00077,invoice
DOC-37554,AR-00075,invoice
DOC-39008,AR-00042,invoice
DOC-40264,AR-00008,invoice
DOC-41153,AR-00024,invoice
DOC-41289,AR-00068,invoice
DOC-42995,AR-00007,invoice
DOC-46657,AR-00023,invoice
DOC-47822,AR-00017,invoice
DOC-49275,AR-00064,invoice
DOC-53545,AR-00035,invoice
DOC-59940,AR-00049,invoice
DOC-62634,AR-00004,invoice
DOC-62749,AR-00073,invoice
DOC-62825,AR-00014,invoice
DOC-66741,AR-00019,invoice
DOC-67338,AR-00044,invoice
DOC-69454,AR-00002,invoice
DOC-69984,AR-00033,invoice
DOC-70314,AR-00046,invoice
DOC-72107,AR-00052,invoice
DOC-74154,AR-00032,invoice
DOC-75536,AR-00034,invoice
DOC-75750,AR-00069,invoice
DOC-80213,AR-00048,invoice
DOC-80398,AR-00050,invoice
DOC-82488,AR-00031,invoice
DOC-84108,AR-00021,invoice
DOC-84826,AR-00010,invoice
DOC-85198,AR-00078,invoice
DOC-87989,AR-00003,invoice
DOC-90802,AR-00047,invoice
DOC-91298,AR-00039,invoice
DOC-93538,AR-00009,invoice
DOC-98303,AR-00036,invoice
DOC-99146,AR-00062,invoice
DOC-99323,AR-00006,invoice
DOC-99933,AR-00001,invoice

ledgers/2025-12.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2025-12 (prior year)
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2025-01-01  AR-900001               Invoice raised       C-ANCH      8,005.01                 8,005.01
2025-01-05  AR-900002               Freight recharged    C-EAST      8,694.58                16,699.59
2025-01-05  AR-900003               Payment received     C-EAST                  1,030.14    15,669.45
2025-01-06  AR-900004               Service billed       C-FAIR      7,363.52                23,032.97
2025-01-06  AR-900005   DOC-62634   Payment received     C-FAIR                  1,209.82    21,823.15
2025-01-09  AR-900006               Invoice raised       C-FAIR      2,057.39                23,880.54
2025-01-11  AR-900007               Invoice raised       C-DELT      6,008.97                29,889.51
2025-01-12  AR-900008               Invoice raised       C-BAYL        427.10                30,316.61
2025-01-15  AR-900009   DOC-69454   Credit note issued   C-EAST                  3,612.94    26,703.67
2025-01-22  AR-900010               Service billed       C-ANCH      8,014.80                34,718.47
2025-01-27  AR-900011               Freight recharged    C-DELT      5,320.27                40,038.74
2025-01-28  AR-900012               Settlement received  C-DELT                  4,077.81    35,960.93
2025-01-29  AR-900013   DOC-42995   Payment received     C-DELT                  7,251.43    28,709.50
                                    Closing balance                                          28,709.50

ledgers/2026-01.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-01
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2026-01-06  AR-00001                Invoice raised       C-BAYL      8,808.96                 8,808.96
2026-01-11  AR-00002                Service billed       C-CEDW      8,958.33                17,767.29
2026-01-14  AR-00003                Goods dispatched     C-DELT      6,492.18                24,259.47
2026-01-15  AR-00004                Invoice raised       C-FAIR      6,408.10                30,667.57
2026-01-20  AR-00005                Payment received     C-CEDW                  4,887.00    25,780.57
2026-01-20  AR-00006                Goods dispatched     C-CEDW      2,257.20                28,037.77
2026-01-21  AR-00007                Invoice raised       C-DELT      8,260.14                36,297.91
2026-01-22  AR-00008                Service billed       C-CEDW      7,331.21                43,629.12
2026-01-23  AR-00009                Invoice raised       C-EAST      2,129.23                45,758.35
2026-01-26  AR-00010                Invoice raised       C-FAIR      4,083.03                49,841.38
2026-01-26  AR-00011    DOC-99933   Payment received     C-BAYL                    330.62    49,510.76
2026-01-28  AR-00012                Invoice raised       C-EAST      7,925.74                57,436.50
2026-01-28  AR-00013    DOC-13464   Credit note issued   C-EAST                  4,268.09    53,168.41
                                    Closing balance                                          53,168.41

ledgers/2026-02.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-02
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          53,168.41
2026-02-01  AR-00014                Invoice raised       C-DELT      1,849.13                55,017.54
2026-02-01  AR-00015    DOC-87989   Payment received     C-DELT                  5,641.91    49,375.63
2026-02-02  AR-00016                Invoice raised       C-DELT        832.70                50,208.33
2026-02-06  AR-00017                Invoice raised       C-DELT      5,745.34                55,953.67
2026-02-09  AR-00018                Invoice raised       C-FAIR      8,706.95                64,660.62
2026-02-10  AR-00019                Invoice raised       C-BAYL      1,189.56                65,850.18
2026-02-10  AR-00020    DOC-99933   Payment received     C-BAYL                  3,773.96    62,076.22
2026-02-13  AR-00021                Goods dispatched     C-EAST      6,652.40                68,728.62
2026-02-14  AR-00022                Payment received     C-FAIR                  5,904.45    62,824.17
2026-02-17  AR-00023                Goods dispatched     C-ANCH      8,054.15                70,878.32
2026-02-19  AR-00024                Service billed       C-CEDW      2,684.50                73,562.82
2026-02-20  AR-00025                Discount allowed     C-BAYL                  3,507.98    70,054.84
2026-02-28  AR-00026                Invoice raised       C-CEDW      5,058.93                75,113.77
                                    Closing balance                                          75,113.77

ledgers/2026-03-supplement.txt

Late-posted entries for 2026-03, booked after that month's extract was taken.
These entries are part of account 1200 and of the 2026 close.

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-03 supplement
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2026-03-23  AR-00037                Invoice raised       C-ANCH      5,490.03                 5,490.03
2026-03-27  AR-00038    DOC-75536   Credit note issued   C-EAST                  9,264.84    -3,774.81
2026-03-29  AR-00039                Late-payment charge  C-BAYL      8,067.58                 4,292.77
                                    Closing balance                                           4,292.77

ledgers/2026-03.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-03
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          75,113.77
2026-03-02  AR-00027    DOC-84108   Payment received     C-EAST                  6,566.55    68,547.22
2026-03-10  AR-00028    DOC-93538   Payment received     C-EAST                  5,340.51    63,206.71
2026-03-12  AR-00029    DOC-47822   Settlement received  C-DELT                  5,279.37    57,927.34
2026-03-14  AR-00030                Goods dispatched     C-CEDW      5,075.82                63,003.16
2026-03-15  AR-00031                Goods dispatched     C-BAYL      4,563.77                67,566.93
2026-03-15  AR-00032                Goods dispatched     C-CEDW      9,260.80                76,827.73
2026-03-16  AR-00033                Invoice raised       C-EAST      7,245.28                84,073.01
2026-03-20  AR-00034                Invoice raised       C-EAST      7,965.90                92,038.91
2026-03-22  AR-00035                Invoice raised       C-FAIR      8,032.48               100,071.39
2026-03-22  AR-00036                Goods dispatched     C-EAST      6,166.28               106,237.67
                                    Closing balance                                         106,237.67

ledgers/2026-04.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-04
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                         110,530.44
2026-04-02  AR-00040                Invoice raised       C-BAYL      5,940.41               116,470.85
2026-04-06  AR-00041    DOC-20678   Credit note issued   C-CEDW                  7,063.36   109,407.49
2026-04-08  AR-00042                Invoice raised       C-BAYL      3,110.55               112,518.04
2026-04-08  AR-00043                Invoice raised       C-BAYL      9,369.43               121,887.47
2026-04-12  AR-00044                Invoice raised       C-FAIR      3,327.22               125,214.69
2026-04-14  AR-00045    DOC-91298   Payment received     C-BAYL                  4,061.53   121,153.16
2026-04-18  AR-00046                Goods dispatched     C-ANCH      7,768.74               128,921.90
2026-04-20  AR-00047                Goods dispatched     C-ANCH      7,032.25               135,954.15
2026-04-23  AR-00048                Service billed       C-EAST      1,280.09               137,234.24
2026-04-24  AR-00049                Invoice raised       C-BAYL      4,939.79               142,174.03
2026-04-25  AR-00050                Late-payment charge  C-EAST      4,336.87               146,510.90
2026-04-27  AR-00051                Payment received     C-BAYL                  4,758.32   141,752.58
2026-04-29  AR-00052                Goods dispatched     C-BAYL      1,977.54               143,730.12
                                    Closing balance                                         143,730.12

ledgers/2026-05.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-05
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                         143,730.12
2026-05-01  AR-00053                Refund applied       C-DELT                  4,840.12   138,890.00
2026-05-01  AR-00054    DOC-33621   Payment received     C-DELT                  3,281.70   135,608.30
2026-05-05  AR-00055                Payment received     C-EAST                  4,025.26   131,583.04
2026-05-08  AR-00056    DOC-40264   Payment received     C-CEDA                  3,373.99   128,209.05
2026-05-08  AR-00057                Late-payment charge  C-EAST      7,979.70               136,188.75
2026-05-16  AR-00058                Goods dispatched     C-DELT      8,706.36               144,895.11
2026-05-20  AR-00059                Goods dispatched     C-EAST      9,179.45               154,074.56
2026-05-22  AR-00060                Goods dispatched     C-EAST      3,481.10               157,555.66
2026-05-23  AR-00061                Discount allowed     C-ANCH                  2,593.02   154,962.64
2026-05-25  AR-00062                Goods dispatched     C-BAYL      5,397.61               160,360.25
2026-05-28  AR-00063    DOC-21763   Settlement received  C-FAIR                  1,665.41   158,694.84
2026-05-30  AR-00064                Late-payment charge  C-DELT      3,726.14               162,420.98
2026-05-31  AR-00065    DOC-91298   Credit note issued   C-BAYL                  6,959.40   155,461.58
                                    Closing balance                                         155,461.58

ledgers/2026-06.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-06
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                         155,461.58
2026-06-05  AR-00066                Invoice raised       C-DELT      1,928.41               157,389.99
2026-06-06  AR-00067    DOC-70314   Payment received     C-ANCH                  3,654.11   153,735.88
2026-06-06  AR-00068                Invoice raised       C-ANCH      6,185.53               159,921.41
2026-06-07  AR-00069                Freight recharged    C-DELT      2,784.71               162,706.12
2026-06-07  AR-00070                Settlement received  C-BAYL                  2,510.29   160,195.83
2026-06-09  AR-00071    DOC-41289   Settlement received  C-ANCH                  4,774.96   155,420.87
2026-06-10  AR-00072    DOC-74154   Payment received     C-CEDA                  2,734.01   152,686.86
2026-06-12  AR-00073                Goods dispatched     C-DELT      6,218.87               158,905.73
2026-06-13  AR-00074    DOC-67338   Payment received     C-FAIR                  6,121.20   152,784.53
2026-06-14  AR-00075                Invoice raised       C-CEDA      8,107.08               160,891.61
2026-06-19  AR-00076                Settlement received  C-EAST                  8,103.32   152,788.29
2026-06-26  AR-00077                Invoice raised       C-DELT      8,284.81               161,073.10
2026-06-26  AR-00078                Invoice raised       C-ANCH      2,391.65               163,464.75
                                    Closing balance                                         163,464.75

masters/counterparties.csv

code,name,status,note
C-ANCH,Anchor Distributors,active,
C-BAYL,BayLine Foods,active,
C-CEDW,Cedarworks Ltd,superseded,"re-coded to C-CEDA with effect from 2026-05-01; same legal entity, same account"
C-CEDA,Cedarworks Ltd,active,formerly C-CEDW
C-DELT,Delta Freight Co,active,
C-EAST,Eastgate Packaging,active,
C-FAIR,Fairmont Supplies,active,

policy/allocation-memo.md

Allocation memo β€” Accounts Receivable

Cash and credit notes are allocated to open invoices under the allocation policy in force. The schedule below records how each receipt was allocated. It has been worked through to 2026-04-14 and stops there; the remainder of the year has not yet been allocated.

Cash received in excess of what the customer owed at that moment is parked as unapplied. This account does not carry unapplied cash forward against invoices raised later.

Date        Voucher     Ref doc          Amount   Allocated to
----------------------------------------------------------------------------------------------------
2026-01-20  AR-00005                   4,887.00   AR-00002 4,887.00
2026-01-26  AR-00011    DOC-99933        330.62   AR-00001 330.62
2026-01-28  AR-00013    DOC-13464      4,268.09   AR-00012 4,268.09
2026-02-01  AR-00015    DOC-87989      5,641.91   AR-00003 5,641.91
2026-02-10  AR-00020    DOC-99933      3,773.96   AR-00001 3,773.96
2026-02-14  AR-00022                   5,904.45   AR-00004 5,904.45
2026-02-20  AR-00025                   3,507.98   AR-00001 3,507.98
2026-03-02  AR-00027    DOC-84108      6,566.55   AR-00021 6,566.55
2026-03-10  AR-00028    DOC-93538      5,340.51   AR-00009 2,129.23  AR-00012 3,211.28
2026-03-12  AR-00029    DOC-47822      5,279.37   AR-00017 5,279.37
2026-03-27  AR-00038    DOC-75536      9,264.84   AR-00012 446.37  AR-00021 85.85  AR-00033 7,245.28  AR-00034 1,487.34
2026-04-06  AR-00041    DOC-20678      7,063.36   AR-00002 4,071.33  AR-00006 2,257.20  AR-00008 734.83
2026-04-14  AR-00045    DOC-91298      4,061.53   AR-00001 1,196.40  AR-00019 1,189.56  AR-00031 1,675.57

expected output

answer.json

{
  "id": "case_05",
  "question_kind": "open_total_cp",
  "answer": "27463.10",
  "answer_kind": "money",
  "months": 6,
  "gap_month": 3,
  "gap_entries": 3
}

Scored by judge.py β€” see Scoring logic below for the full rule.

β–Έcase_067-month close, settled total; supplement gap, decoy prior-year ledger, re-coded customer, mid-year policy change.

input

README.md

# Year-end receivables

Close out the Accounts Receivable ledger for 2026 and answer the question below.

## What is here

- `ledgers/` β€” the monthly ledger extracts for account 1200
- `policy/allocation-memo.md` β€” how receipts have been allocated so far
- `masters/counterparties.csv` β€” the customer master
- `index/documents.csv` β€” resolves the `Ref doc` column to a voucher

Not everything in `ledgers/` belongs to this year's account 1200 close. Check
what you are reading before you use it.

## Question

How much of everything billed during the year had been settled in full by the end of it?

## Output

Print the answer on its own line, prefixed exactly like this:

    ANSWER: 12345.67

A plain amount, no currency symbol and no thousands separators. You may write
whatever else you like before or after that line; only the `ANSWER:` line is
read.

index/documents.csv

document_id,voucher,document_type
DOC-12857,AR-00019,invoice
DOC-13560,AR-00071,invoice
DOC-14584,AR-00021,invoice
DOC-14836,AR-00034,invoice
DOC-14880,AR-00066,invoice
DOC-16292,AR-00002,invoice
DOC-22191,AR-00030,invoice
DOC-22535,AR-00061,invoice
DOC-23520,AR-00031,invoice
DOC-24880,AR-00079,invoice
DOC-25426,AR-00057,invoice
DOC-26238,AR-00081,invoice
DOC-26317,AR-00083,invoice
DOC-26441,AR-00045,invoice
DOC-26881,AR-00024,invoice
DOC-27583,AR-00042,invoice
DOC-28953,AR-00022,invoice
DOC-36224,AR-00058,invoice
DOC-38971,AR-00017,invoice
DOC-39349,AR-00003,invoice
DOC-39502,AR-00033,invoice
DOC-41064,AR-00078,invoice
DOC-45466,AR-00046,invoice
DOC-46565,AR-00020,invoice
DOC-47943,AR-00048,invoice
DOC-48610,AR-00016,invoice
DOC-53241,AR-00023,invoice
DOC-58454,AR-00008,invoice
DOC-58577,AR-00038,invoice
DOC-58717,AR-00001,invoice
DOC-63951,AR-00054,invoice
DOC-64534,AR-00069,invoice
DOC-65452,AR-00053,invoice
DOC-66350,AR-00076,invoice
DOC-66773,AR-00068,invoice
DOC-66831,AR-00012,invoice
DOC-67332,AR-00005,invoice
DOC-68995,AR-00004,invoice
DOC-69417,AR-00025,invoice
DOC-71537,AR-00082,invoice
DOC-73687,AR-00036,invoice
DOC-75858,AR-00032,invoice
DOC-79732,AR-00077,invoice
DOC-84284,AR-00044,invoice
DOC-87907,AR-00065,invoice
DOC-90136,AR-00037,invoice
DOC-93739,AR-00007,invoice
DOC-94261,AR-00064,invoice
DOC-94490,AR-00006,invoice
DOC-98259,AR-00052,invoice
DOC-99001,AR-00039,invoice
DOC-99156,AR-00028,invoice

ledgers/2025-12.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2025-12 (prior year)
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2025-01-03  AR-900001               Invoice raised       C-DELT      3,045.94                 3,045.94
2025-01-06  AR-900002               Invoice raised       C-BAYL      6,782.79                 9,828.73
2025-01-10  AR-900003   DOC-16292   Settlement received  C-BAYL                  1,048.91     8,779.82
2025-01-11  AR-900004               Goods dispatched     C-FAIR      2,777.63                11,557.45
2025-01-12  AR-900005               Invoice raised       C-ANCH      2,374.47                13,931.92
2025-01-14  AR-900006               Service billed       C-BAYL      3,768.01                17,699.93
2025-01-15  AR-900007               Invoice raised       C-BAYL      3,423.54                21,123.47
2025-01-15  AR-900008               Service billed       C-EAST      4,121.10                25,244.57
2025-01-18  AR-900009               Payment received     C-EAST                    611.43    24,633.14
2025-01-24  AR-900010               Invoice raised       C-FAIR      5,666.11                30,299.25
2025-01-28  AR-900011               Invoice raised       C-ANCH      7,757.06                38,056.31
2025-01-29  AR-900012   DOC-67332   Settlement received  C-ANCH                  6,957.32    31,098.99
                                    Closing balance                                          31,098.99

ledgers/2026-01.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-01
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2026-01-01  AR-00001                Goods dispatched     C-FAIR      3,367.58                 3,367.58
2026-01-04  AR-00002                Invoice raised       C-CEDW      1,532.50                 4,900.08
2026-01-05  AR-00003                Invoice raised       C-DELT      6,389.54                11,289.62
2026-01-06  AR-00004                Invoice raised       C-BAYL      1,187.13                12,476.75
2026-01-07  AR-00005                Invoice raised       C-EAST      8,790.14                21,266.89
2026-01-10  AR-00006                Service billed       C-BAYL        796.54                22,063.43
2026-01-10  AR-00007                Invoice raised       C-DELT      4,096.57                26,160.00
2026-01-14  AR-00008                Invoice raised       C-EAST      2,502.39                28,662.39
2026-01-14  AR-00009    DOC-93739   Payment received     C-DELT                  7,117.65    21,544.74
2026-01-14  AR-00010                Payment received     C-EAST                  1,675.07    19,869.67
2026-01-19  AR-00011                Payment received     C-BAYL                  1,983.67    17,886.00
2026-01-20  AR-00012                Service billed       C-BAYL      3,970.05                21,856.05
                                    Closing balance                                          21,856.05

ledgers/2026-02.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-02
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          21,856.05
2026-02-01  AR-00013                Payment received     C-BAYL                  3,970.05    17,886.00
2026-02-04  AR-00014    DOC-39349   Payment received     C-DELT                  3,368.46    14,517.54
2026-02-08  AR-00015    DOC-16292   Discount allowed     C-CEDW                  1,528.87    12,988.67
2026-02-10  AR-00016                Invoice raised       C-BAYL      7,415.35                20,404.02
2026-02-15  AR-00017                Invoice raised       C-CEDW      5,546.34                25,950.36
2026-02-15  AR-00018    DOC-58717   Payment received     C-FAIR                  1,763.61    24,186.75
2026-02-18  AR-00019                Goods dispatched     C-DELT      1,157.15                25,343.90
2026-02-18  AR-00020                Freight recharged    C-DELT      6,462.14                31,806.04
2026-02-19  AR-00021                Invoice raised       C-CEDW      6,379.24                38,185.28
2026-02-21  AR-00022                Service billed       C-CEDW      6,672.17                44,857.45
2026-02-21  AR-00023                Service billed       C-FAIR      9,371.76                54,229.21
2026-02-28  AR-00024                Invoice raised       C-BAYL      6,581.28                60,810.49
                                    Closing balance                                          60,810.49

ledgers/2026-03.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-03
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          60,810.49
2026-03-01  AR-00025                Invoice raised       C-BAYL      4,335.70                65,146.19
2026-03-05  AR-00026                Payment received     C-EAST                    292.63    64,853.56
2026-03-06  AR-00027    DOC-28953   Refund applied       C-CEDW                  8,508.59    56,344.97
2026-03-07  AR-00028                Service billed       C-EAST      6,820.90                63,165.87
2026-03-10  AR-00029    DOC-46565   Payment received     C-DELT                    664.29    62,501.58
2026-03-11  AR-00030                Late-payment charge  C-CEDW      3,069.60                65,571.18
2026-03-18  AR-00031                Late-payment charge  C-EAST      4,037.87                69,609.05
2026-03-19  AR-00032                Freight recharged    C-FAIR      2,257.85                71,866.90
2026-03-19  AR-00033                Invoice raised       C-CEDW      4,818.03                76,684.93
2026-03-21  AR-00034                Invoice raised       C-DELT      5,469.88                82,154.81
2026-03-21  AR-00035                Payment received     C-BAYL                  7,282.66    74,872.15
2026-03-31  AR-00036                Service billed       C-DELT      1,636.33                76,508.48
                                    Closing balance                                          76,508.48

ledgers/2026-04.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-04
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          76,508.48
2026-04-02  AR-00037                Invoice raised       C-DELT        895.06                77,403.54
2026-04-09  AR-00038                Goods dispatched     C-DELT      7,711.34                85,114.88
2026-04-11  AR-00039                Service billed       C-FAIR      6,157.78                91,272.66
2026-04-12  AR-00040    DOC-39502   Payment received     C-CEDW                  1,543.16    89,729.50
2026-04-13  AR-00041                Settlement received  C-BAYL                  1,824.78    87,904.72
2026-04-14  AR-00042                Invoice raised       C-BAYL      7,656.80                95,561.52
2026-04-18  AR-00043                Refund applied       C-BAYL                  3,372.70    92,188.82
2026-04-20  AR-00044                Goods dispatched     C-CEDW      3,614.78                95,803.60
2026-04-22  AR-00045                Goods dispatched     C-CEDW      9,238.63               105,042.23
2026-04-24  AR-00046                Goods dispatched     C-DELT      5,015.14               110,057.37
2026-04-25  AR-00047    DOC-58454   Payment received     C-EAST                  3,793.84   106,263.53
2026-04-27  AR-00048                Invoice raised       C-ANCH      6,422.21               112,685.74
                                    Closing balance                                         112,685.74

ledgers/2026-05-supplement.txt

Late-posted entries for 2026-05, booked after that month's extract was taken.
These entries are part of account 1200 and of the 2026 close.

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-05 supplement
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2026-05-17  AR-00058                Invoice raised       C-BAYL      2,537.77                 2,537.77
2026-05-18  AR-00059    DOC-26441   Payment received     C-CEDA                  3,938.62    -1,400.85
2026-05-29  AR-00060                Payment received     C-BAYL                  1,586.84    -2,987.69
                                    Closing balance                                          -2,987.69

ledgers/2026-05.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-05
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                         112,685.74
2026-05-01  AR-00049    DOC-46565   Payment received     C-DELT                  8,295.86   104,389.88
2026-05-04  AR-00050    DOC-99001   Payment received     C-FAIR                  3,600.50   100,789.38
2026-05-09  AR-00051    DOC-99001   Payment received     C-FAIR                  3,193.61    97,595.77
2026-05-12  AR-00052                Goods dispatched     C-ANCH      1,111.93                98,707.70
2026-05-13  AR-00053                Invoice raised       C-ANCH      2,654.48               101,362.18
2026-05-14  AR-00054                Invoice raised       C-CEDA      6,478.71               107,840.89
2026-05-15  AR-00055    DOC-98259   Credit note issued   C-ANCH                  1,180.51   106,660.38
2026-05-15  AR-00056    DOC-63951   Refund applied       C-CEDA                  3,370.03   103,290.35
2026-05-15  AR-00057                Invoice raised       C-ANCH      1,926.99               105,217.34
                                    Closing balance                                         105,217.34

ledgers/2026-06.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-06
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                         102,229.65
2026-06-04  AR-00061                Freight recharged    C-EAST      5,831.87               108,061.52
2026-06-04  AR-00062                Payment received     C-DELT                  8,013.44   100,048.08
2026-06-08  AR-00063    DOC-84284   Settlement received  C-CEDA                  3,521.05    96,527.03
2026-06-09  AR-00064                Service billed       C-CEDA      2,906.33                99,433.36
2026-06-10  AR-00065                Invoice raised       C-CEDA      9,007.05               108,440.41
2026-06-12  AR-00066                Service billed       C-CEDA      5,477.97               113,918.38
2026-06-12  AR-00067    DOC-99001   Credit note issued   C-FAIR                  6,009.92   107,908.46
2026-06-13  AR-00068                Invoice raised       C-DELT      2,873.94               110,782.40
2026-06-15  AR-00069                Invoice raised       C-DELT      3,661.90               114,444.30
2026-06-18  AR-00070                Discount allowed     C-ANCH                  1,443.22   113,001.08
2026-06-26  AR-00071                Invoice raised       C-BAYL        890.88               113,891.96
2026-06-29  AR-00072    DOC-69417   Settlement received  C-BAYL                  5,257.36   108,634.60
                                    Closing balance                                         108,634.60

ledgers/2026-07.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-07
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                         108,634.60
2026-07-05  AR-00073    DOC-58454   Discount allowed     C-EAST                  9,109.99    99,524.61
2026-07-08  AR-00074                Payment received     C-ANCH                  1,262.58    98,262.03
2026-07-10  AR-00075    DOC-58577   Payment received     C-DELT                  4,363.80    93,898.23
2026-07-12  AR-00076                Goods dispatched     C-ANCH      7,483.23               101,381.46
2026-07-14  AR-00077                Invoice raised       C-EAST      1,520.96               102,902.42
2026-07-19  AR-00078                Invoice raised       C-FAIR      9,144.46               112,046.88
2026-07-19  AR-00079                Late-payment charge  C-EAST        228.76               112,275.64
2026-07-20  AR-00080                Payment received     C-CEDA                    651.80   111,623.84
2026-07-20  AR-00081                Service billed       C-BAYL      4,366.92               115,990.76
2026-07-21  AR-00082                Invoice raised       C-ANCH      8,719.93               124,710.69
2026-07-22  AR-00083                Invoice raised       C-EAST      5,246.24               129,956.93
2026-07-23  AR-00084    DOC-27583   Credit note issued   C-BAYL                  1,088.99   128,867.94
                                    Closing balance                                         128,867.94

masters/counterparties.csv

code,name,status,note
C-ANCH,Anchor Distributors,active,
C-BAYL,BayLine Foods,active,
C-CEDW,Cedarworks Ltd,superseded,"re-coded to C-CEDA with effect from 2026-05-01; same legal entity, same account"
C-CEDA,Cedarworks Ltd,active,formerly C-CEDW
C-DELT,Delta Freight Co,active,
C-EAST,Eastgate Packaging,active,
C-FAIR,Fairmont Supplies,active,

policy/allocation-memo.md

Allocation memo β€” Accounts Receivable

Cash and credit notes are allocated to open invoices under the allocation policy in force. The schedule below records how each receipt was allocated. It has been worked through to 2026-05-01 and stops there; the remainder of the year has not yet been allocated.

Cash received in excess of what the customer owed at that moment is parked as unapplied. This account does not carry unapplied cash forward against invoices raised later.

Date        Voucher     Ref doc          Amount   Allocated to
----------------------------------------------------------------------------------------------------
2026-01-14  AR-00009    DOC-93739      7,117.65   AR-00007 4,096.57  AR-00003 3,021.08
2026-01-14  AR-00010                   1,675.07   AR-00005 1,675.07
2026-01-19  AR-00011                   1,983.67   AR-00004 1,187.13  AR-00006 796.54
2026-02-01  AR-00013                   3,970.05   AR-00012 3,970.05
2026-02-04  AR-00014    DOC-39349      3,368.46   AR-00003 3,368.46
2026-02-08  AR-00015    DOC-16292      1,528.87   AR-00002 1,528.87
2026-02-15  AR-00018    DOC-58717      1,763.61   AR-00001 1,763.61
2026-03-05  AR-00026                     292.63   AR-00005 292.63
2026-03-06  AR-00027    DOC-28953      8,508.59   AR-00022 6,672.17  AR-00002 3.63  AR-00017 1,832.79
2026-03-10  AR-00029    DOC-46565        664.29   AR-00020 664.29
2026-03-21  AR-00035                   7,282.66   AR-00016 7,282.66
2026-04-12  AR-00040    DOC-39502      1,543.16   AR-00017 1,543.16
2026-04-13  AR-00041                   1,824.78   AR-00016 132.69  AR-00024 1,692.09
2026-04-18  AR-00043                   3,372.70   AR-00024 3,372.70
2026-04-25  AR-00047    DOC-58454      3,793.84   AR-00005 3,793.84
2026-05-01  AR-00049    DOC-46565      8,295.86   AR-00019 1,157.15  AR-00020 5,797.85  AR-00034 1,340.86

expected output

answer.json

{
  "id": "case_06",
  "question_kind": "settled_total",
  "answer": "94554.84",
  "answer_kind": "money",
  "months": 7,
  "gap_month": 5,
  "gap_entries": 3
}

Scored by judge.py β€” see Scoring logic below for the full rule.

β–Έcase_076-month close, aged open after; supplement gap, decoy prior-year ledger, re-coded customer, mid-year policy change.

input

README.md

# Year-end receivables

Close out the Accounts Receivable ledger for 2026 and answer the question below.

## What is here

- `ledgers/` β€” the monthly ledger extracts for account 1200
- `policy/allocation-memo.md` β€” how receipts have been allocated so far
- `masters/counterparties.csv` β€” the customer master
- `index/documents.csv` β€” resolves the `Ref doc` column to a voucher

Not everything in `ledgers/` belongs to this year's account 1200 close. Check
what you are reading before you use it.

## Question

How much was still owed at the end of the year on invoices billed on or after 2026-04-25?

## Output

Print the answer on its own line, prefixed exactly like this:

    ANSWER: 12345.67

A plain amount, no currency symbol and no thousands separators. You may write
whatever else you like before or after that line; only the `ANSWER:` line is
read.

index/documents.csv

document_id,voucher,document_type
DOC-12702,AR-00068,invoice
DOC-17012,AR-00036,invoice
DOC-17438,AR-00035,invoice
DOC-18393,AR-00007,invoice
DOC-18501,AR-00004,invoice
DOC-19175,AR-00080,invoice
DOC-23394,AR-00020,invoice
DOC-25148,AR-00049,invoice
DOC-25619,AR-00081,invoice
DOC-25720,AR-00050,invoice
DOC-27040,AR-00053,invoice
DOC-30930,AR-00059,invoice
DOC-32617,AR-00016,invoice
DOC-33674,AR-00022,invoice
DOC-33890,AR-00056,invoice
DOC-35323,AR-00047,invoice
DOC-37538,AR-00029,invoice
DOC-39504,AR-00031,invoice
DOC-39594,AR-00058,invoice
DOC-41514,AR-00057,invoice
DOC-45525,AR-00079,invoice
DOC-48250,AR-00030,invoice
DOC-48703,AR-00066,invoice
DOC-49377,AR-00023,invoice
DOC-53299,AR-00072,invoice
DOC-56122,AR-00001,invoice
DOC-57577,AR-00012,invoice
DOC-59042,AR-00076,invoice
DOC-59888,AR-00015,invoice
DOC-61113,AR-00032,invoice
DOC-62561,AR-00027,invoice
DOC-69165,AR-00075,invoice
DOC-71165,AR-00019,invoice
DOC-73537,AR-00063,invoice
DOC-77694,AR-00078,invoice
DOC-80275,AR-00008,invoice
DOC-80478,AR-00040,invoice
DOC-81506,AR-00028,invoice
DOC-82107,AR-00071,invoice
DOC-85003,AR-00054,invoice
DOC-85403,AR-00083,invoice
DOC-91073,AR-00070,invoice
DOC-91442,AR-00002,invoice
DOC-91976,AR-00010,invoice
DOC-91990,AR-00009,invoice
DOC-92672,AR-00034,invoice
DOC-92842,AR-00006,invoice
DOC-92851,AR-00005,invoice
DOC-93955,AR-00003,invoice
DOC-95662,AR-00060,invoice
DOC-96138,AR-00033,invoice
DOC-97397,AR-00052,invoice
DOC-97661,AR-00038,invoice
DOC-97830,AR-00039,invoice
DOC-99342,AR-00067,invoice

ledgers/2025-12.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2025-12 (prior year)
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2025-01-05  AR-900001               Service billed       C-DELT      8,152.77                 8,152.77
2025-01-07  AR-900002               Freight recharged    C-EAST      7,416.64                15,569.41
2025-01-07  AR-900003               Goods dispatched     C-ANCH      3,535.60                19,105.01
2025-01-08  AR-900004               Goods dispatched     C-FAIR      3,167.50                22,272.51
2025-01-09  AR-900005   DOC-18501   Discount allowed     C-FAIR                  3,167.50    19,105.01
2025-01-11  AR-900006               Invoice raised       C-DELT      5,857.08                24,962.09
2025-01-17  AR-900007   DOC-91442   Settlement received  C-EAST                  5,131.64    19,830.45
2025-01-19  AR-900008   DOC-92842   Payment received     C-DELT                  5,131.28    14,699.17
2025-01-21  AR-900009               Goods dispatched     C-ANCH      7,253.01                21,952.18
2025-01-23  AR-900010               Payment received     C-DELT                  6,824.94    15,127.24
2025-01-26  AR-900011               Service billed       C-BAYL      5,240.16                20,367.40
2025-01-27  AR-900012               Invoice raised       C-ANCH      5,147.77                25,515.17
2025-01-28  AR-900013               Goods dispatched     C-CEDA      5,055.07                30,570.24
2025-01-30  AR-900014               Service billed       C-DELT      9,069.08                39,639.32
                                    Closing balance                                          39,639.32

ledgers/2026-01.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-01
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2026-01-02  AR-00001                Service billed       C-DELT      7,059.62                 7,059.62
2026-01-03  AR-00002                Goods dispatched     C-EAST      1,049.31                 8,108.93
2026-01-03  AR-00003                Goods dispatched     C-FAIR      7,557.23                15,666.16
2026-01-13  AR-00004                Invoice raised       C-ANCH      8,534.07                24,200.23
2026-01-13  AR-00005                Goods dispatched     C-CEDW      1,482.89                25,683.12
2026-01-15  AR-00006                Invoice raised       C-EAST      6,110.35                31,793.47
2026-01-19  AR-00007                Service billed       C-FAIR      3,675.13                35,468.60
2026-01-20  AR-00008                Invoice raised       C-ANCH      9,352.22                44,820.82
2026-01-20  AR-00009                Invoice raised       C-CEDW      3,542.65                48,363.47
2026-01-21  AR-00010                Invoice raised       C-DELT      5,650.54                54,014.01
2026-01-24  AR-00011    DOC-80275   Credit note issued   C-ANCH                    729.37    53,284.64
2026-01-28  AR-00012                Service billed       C-FAIR        877.56                54,162.20
2026-01-29  AR-00013    DOC-18393   Payment received     C-FAIR                  7,637.21    46,524.99
2026-01-30  AR-00014    DOC-93955   Payment received     C-FAIR                  3,451.14    43,073.85
                                    Closing balance                                          43,073.85

ledgers/2026-02.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-02
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          43,073.85
2026-02-01  AR-00015                Goods dispatched     C-EAST      5,593.90                48,667.75
2026-02-03  AR-00016                Invoice raised       C-CEDW      1,285.98                49,953.73
2026-02-04  AR-00017                Settlement received  C-ANCH                  8,225.22    41,728.51
2026-02-10  AR-00018    DOC-56122   Payment received     C-DELT                  6,252.63    35,475.88
2026-02-12  AR-00019                Invoice raised       C-CEDW      5,419.26                40,895.14
2026-02-18  AR-00020                Goods dispatched     C-FAIR      7,640.21                48,535.35
2026-02-19  AR-00021    DOC-91990   Payment received     C-CEDW                  4,460.39    44,074.96
2026-02-19  AR-00022                Goods dispatched     C-EAST        665.89                44,740.85
2026-02-19  AR-00023                Freight recharged    C-BAYL      2,351.21                47,092.06
2026-02-22  AR-00024                Payment received     C-EAST                  5,588.09    41,503.97
2026-02-23  AR-00025                Refund applied       C-CEDW                  2,863.19    38,640.78
2026-02-25  AR-00026    DOC-57577   Payment received     C-FAIR                  1,121.43    37,519.35
2026-02-26  AR-00027                Invoice raised       C-EAST      6,882.14                44,401.49
2026-02-28  AR-00028                Service billed       C-BAYL      5,200.29                49,601.78
                                    Closing balance                                          49,601.78

ledgers/2026-03-supplement.txt

Late-posted entries for 2026-03, booked after that month's extract was taken.
These entries are part of account 1200 and of the 2026 close.

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-03 supplement
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2026-03-25  AR-00040                Invoice raised       C-FAIR      2,433.18                 2,433.18
2026-03-27  AR-00041                Payment received     C-EAST                  5,646.08    -3,212.90
2026-03-27  AR-00042    DOC-17012   Payment received     C-DELT                  5,808.01    -9,020.91
                                    Closing balance                                          -9,020.91

ledgers/2026-03.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-03
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          49,601.78
2026-03-07  AR-00029                Invoice raised       C-CEDW      6,364.91                55,966.69
2026-03-09  AR-00030                Goods dispatched     C-CEDW      7,955.90                63,922.59
2026-03-09  AR-00031                Invoice raised       C-ANCH      2,977.50                66,900.09
2026-03-13  AR-00032                Invoice raised       C-FAIR      6,507.67                73,407.76
2026-03-15  AR-00033                Invoice raised       C-CEDW      6,784.39                80,192.15
2026-03-17  AR-00034                Goods dispatched     C-BAYL      7,656.22                87,848.37
2026-03-19  AR-00035                Goods dispatched     C-BAYL      7,449.25                95,297.62
2026-03-22  AR-00036                Invoice raised       C-DELT      1,355.76                96,653.38
2026-03-22  AR-00037    DOC-92672   Discount allowed     C-BAYL                  2,743.96    93,909.42
2026-03-24  AR-00038                Invoice raised       C-FAIR      1,727.28                95,636.70
2026-03-24  AR-00039                Goods dispatched     C-ANCH      7,672.36               103,309.06
                                    Closing balance                                         103,309.06

ledgers/2026-04.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-04
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          94,288.15
2026-04-04  AR-00043    DOC-97830   Payment received     C-ANCH                    597.24    93,690.91
2026-04-06  AR-00044    DOC-92672   Payment received     C-BAYL                  4,747.23    88,943.68
2026-04-08  AR-00045                Settlement received  C-CEDW                  3,754.23    85,189.45
2026-04-08  AR-00046    DOC-17012   Payment received     C-DELT                  2,005.28    83,184.17
2026-04-11  AR-00047                Service billed       C-BAYL      3,218.95                86,403.12
2026-04-12  AR-00048    DOC-23394   Credit note issued   C-FAIR                  5,941.54    80,461.58
2026-04-16  AR-00049                Invoice raised       C-DELT      7,039.73                87,501.31
2026-04-21  AR-00050                Goods dispatched     C-DELT      5,810.40                93,311.71
2026-04-23  AR-00051    DOC-25148   Payment received     C-DELT                  3,903.58    89,408.13
2026-04-25  AR-00052                Invoice raised       C-FAIR      8,924.31                98,332.44
2026-04-26  AR-00053                Invoice raised       C-CEDW      1,633.75                99,966.19
2026-04-27  AR-00054                Service billed       C-FAIR      6,457.15               106,423.34
2026-04-27  AR-00055    DOC-96138   Settlement received  C-CEDW                  8,438.98    97,984.36
2026-04-27  AR-00056                Invoice raised       C-BAYL      7,682.27               105,666.63
                                    Closing balance                                         105,666.63

ledgers/2026-05.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-05
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                         105,666.63
2026-05-03  AR-00057                Service billed       C-BAYL      3,879.85               109,546.48
2026-05-04  AR-00058                Goods dispatched     C-ANCH      6,279.72               115,826.20
2026-05-05  AR-00059                Service billed       C-DELT      7,248.36               123,074.56
2026-05-06  AR-00060                Invoice raised       C-BAYL      5,970.07               129,044.63
2026-05-06  AR-00061                Settlement received  C-EAST                    327.64   128,716.99
2026-05-09  AR-00062    DOC-48250   Credit note issued   C-CEDA                  8,624.96   120,092.03
2026-05-11  AR-00063                Invoice raised       C-ANCH      7,657.34               127,749.37
2026-05-15  AR-00064    DOC-25720   Credit note issued   C-DELT                  6,488.43   121,260.94
2026-05-18  AR-00065    DOC-33674   Credit note issued   C-EAST                  1,869.96   119,390.98
2026-05-22  AR-00066                Goods dispatched     C-ANCH        747.37               120,138.35
2026-05-24  AR-00067                Goods dispatched     C-FAIR      4,170.45               124,308.80
2026-05-28  AR-00068                Invoice raised       C-FAIR      5,915.90               130,224.70
2026-05-30  AR-00069    DOC-62561   Payment received     C-EAST                  5,128.87   125,095.83
2026-05-30  AR-00070                Invoice raised       C-CEDA      3,282.22               128,378.05
                                    Closing balance                                         128,378.05

ledgers/2026-06.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-06
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                         128,378.05
2026-06-02  AR-00071                Invoice raised       C-CEDA      5,682.37               134,060.42
2026-06-09  AR-00072                Invoice raised       C-ANCH      4,357.32               138,417.74
2026-06-09  AR-00073    DOC-33674   Payment received     C-EAST                  1,740.95   136,676.79
2026-06-12  AR-00074                Payment received     C-BAYL                  2,550.45   134,126.34
2026-06-13  AR-00075                Invoice raised       C-FAIR      3,930.78               138,057.12
2026-06-15  AR-00076                Invoice raised       C-ANCH        755.55               138,812.67
2026-06-16  AR-00077    DOC-41514   Payment received     C-BAYL                  3,499.57   135,313.10
2026-06-20  AR-00078                Late-payment charge  C-BAYL      1,810.87               137,123.97
2026-06-22  AR-00079                Goods dispatched     C-CEDA      3,160.85               140,284.82
2026-06-23  AR-00080                Goods dispatched     C-DELT      4,621.31               144,906.13
2026-06-23  AR-00081                Goods dispatched     C-EAST        444.62               145,350.75
2026-06-24  AR-00082    DOC-73537   Credit note issued   C-ANCH                  6,685.65   138,665.10
2026-06-27  AR-00083                Service billed       C-ANCH      2,099.87               140,764.97
2026-06-28  AR-00084    DOC-25619   Settlement received  C-EAST                    489.08   140,275.89
                                    Closing balance                                         140,275.89

masters/counterparties.csv

code,name,status,note
C-ANCH,Anchor Distributors,active,
C-BAYL,BayLine Foods,active,
C-CEDW,Cedarworks Ltd,superseded,"re-coded to C-CEDA with effect from 2026-05-01; same legal entity, same account"
C-CEDA,Cedarworks Ltd,active,formerly C-CEDW
C-DELT,Delta Freight Co,active,
C-EAST,Eastgate Packaging,active,
C-FAIR,Fairmont Supplies,active,

policy/allocation-memo.md

Allocation memo β€” Accounts Receivable

Cash and credit notes are allocated to open invoices under the allocation policy in force. The schedule below records how each receipt was allocated. It has been worked through to 2026-04-04 and stops there; the remainder of the year has not yet been allocated.

Cash received in excess of what the customer owed at that moment is parked as unapplied. This account does not carry unapplied cash forward against invoices raised later.

Date        Voucher     Ref doc          Amount   Allocated to
----------------------------------------------------------------------------------------------------
2026-01-24  AR-00011    DOC-80275        729.37   AR-00008 729.37
2026-01-29  AR-00013    DOC-18393      7,637.21   AR-00007 3,675.13  AR-00003 3,962.08
2026-01-30  AR-00014    DOC-93955      3,451.14   AR-00003 3,451.14
2026-02-04  AR-00017                   8,225.22   AR-00004 8,225.22
2026-02-10  AR-00018    DOC-56122      6,252.63   AR-00001 6,252.63
2026-02-19  AR-00021    DOC-91990      4,460.39   AR-00009 3,542.65  AR-00005 917.74
2026-02-22  AR-00024                   5,588.09   AR-00002 1,049.31  AR-00006 4,538.78
2026-02-23  AR-00025                   2,863.19   AR-00005 565.15  AR-00016 1,285.98  AR-00019 1,012.06
2026-02-25  AR-00026    DOC-57577      1,121.43   AR-00012 877.56  AR-00003 144.01  AR-00020 99.86
2026-03-22  AR-00037    DOC-92672      2,743.96   AR-00023 2,351.21  AR-00028 392.75
2026-03-27  AR-00041                   5,646.08   AR-00006 1,571.57  AR-00015 4,074.51
2026-03-27  AR-00042    DOC-17012      5,808.01   AR-00001 806.99  AR-00010 5,001.02
2026-04-04  AR-00043    DOC-97830        597.24   AR-00004 308.85  AR-00008 288.39

expected output

answer.json

{
  "id": "case_07",
  "question_kind": "aged_open_after",
  "answer": "96267.68",
  "answer_kind": "money",
  "months": 6,
  "gap_month": 3,
  "gap_entries": 3
}

Scored by judge.py β€” see Scoring logic below for the full rule.

β–Έcase_087-month close, open total cp; supplement gap, decoy prior-year ledger, re-coded customer, mid-year policy change.

input

README.md

# Year-end receivables

Close out the Accounts Receivable ledger for 2026 and answer the question below.

## What is here

- `ledgers/` β€” the monthly ledger extracts for account 1200
- `policy/allocation-memo.md` β€” how receipts have been allocated so far
- `masters/counterparties.csv` β€” the customer master
- `index/documents.csv` β€” resolves the `Ref doc` column to a voucher

Not everything in `ledgers/` belongs to this year's account 1200 close. Check
what you are reading before you use it.

## Question

How much did Anchor Distributors still owe at the end of the year?

## Output

Print the answer on its own line, prefixed exactly like this:

    ANSWER: 12345.67

A plain amount, no currency symbol and no thousands separators. You may write
whatever else you like before or after that line; only the `ANSWER:` line is
read.

index/documents.csv

document_id,voucher,document_type
DOC-10555,AR-00037,invoice
DOC-10591,AR-00096,invoice
DOC-12425,AR-00032,invoice
DOC-14195,AR-00097,invoice
DOC-15819,AR-00042,invoice
DOC-19676,AR-00039,invoice
DOC-23302,AR-00005,invoice
DOC-27590,AR-00078,invoice
DOC-29080,AR-00013,invoice
DOC-30372,AR-00056,invoice
DOC-33596,AR-00067,invoice
DOC-34162,AR-00001,invoice
DOC-34415,AR-00051,invoice
DOC-36333,AR-00050,invoice
DOC-37285,AR-00061,invoice
DOC-38958,AR-00063,invoice
DOC-40079,AR-00064,invoice
DOC-40173,AR-00034,invoice
DOC-44707,AR-00009,invoice
DOC-45478,AR-00077,invoice
DOC-46040,AR-00069,invoice
DOC-51278,AR-00074,invoice
DOC-51549,AR-00036,invoice
DOC-51918,AR-00089,invoice
DOC-53449,AR-00024,invoice
DOC-54149,AR-00095,invoice
DOC-57825,AR-00025,invoice
DOC-60450,AR-00026,invoice
DOC-61236,AR-00044,invoice
DOC-62131,AR-00019,invoice
DOC-64605,AR-00023,invoice
DOC-64754,AR-00007,invoice
DOC-66383,AR-00012,invoice
DOC-66904,AR-00047,invoice
DOC-68990,AR-00016,invoice
DOC-69393,AR-00055,invoice
DOC-70432,AR-00065,invoice
DOC-72046,AR-00083,invoice
DOC-72792,AR-00018,invoice
DOC-74456,AR-00029,invoice
DOC-76424,AR-00059,invoice
DOC-76685,AR-00040,invoice
DOC-78685,AR-00081,invoice
DOC-81205,AR-00046,invoice
DOC-82033,AR-00080,invoice
DOC-82211,AR-00014,invoice
DOC-85638,AR-00002,invoice
DOC-86194,AR-00020,invoice
DOC-86522,AR-00062,invoice
DOC-87010,AR-00054,invoice
DOC-87256,AR-00033,invoice
DOC-87343,AR-00003,invoice
DOC-87388,AR-00094,invoice
DOC-88430,AR-00048,invoice
DOC-93503,AR-00006,invoice
DOC-94595,AR-00098,invoice
DOC-94610,AR-00073,invoice
DOC-95484,AR-00043,invoice
DOC-96952,AR-00058,invoice

ledgers/2025-12.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2025-12 (prior year)
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2025-01-03  AR-900001               Invoice raised       C-FAIR      6,923.15                 6,923.15
2025-01-04  AR-900002               Invoice raised       C-EAST      6,556.01                13,479.16
2025-01-04  AR-900003               Late-payment charge  C-ANCH      4,386.77                17,865.93
2025-01-10  AR-900004               Goods dispatched     C-DELT      4,771.23                22,637.16
2025-01-12  AR-900005               Goods dispatched     C-DELT        372.05                23,009.21
2025-01-12  AR-900006               Freight recharged    C-FAIR      7,398.08                30,407.29
2025-01-13  AR-900007               Invoice raised       C-CEDA      6,402.06                36,809.35
2025-01-17  AR-900008               Freight recharged    C-EAST      1,117.14                37,926.49
2025-01-18  AR-900009   DOC-64754   Payment received     C-CEDA                  3,049.59    34,876.90
2025-01-18  AR-900010               Invoice raised       C-ANCH      1,196.82                36,073.72
2025-01-20  AR-900011               Invoice raised       C-ANCH      9,255.88                45,329.60
2025-01-21  AR-900012               Invoice raised       C-BAYL      1,413.21                46,742.81
2025-01-27  AR-900013               Service billed       C-CEDA        367.65                47,110.46
2025-01-29  AR-900014               Invoice raised       C-ANCH      2,820.45                49,930.91
                                    Closing balance                                          49,930.91

ledgers/2026-01.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-01
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2026-01-01  AR-00001                Service billed       C-BAYL      6,022.09                 6,022.09
2026-01-05  AR-00002                Invoice raised       C-FAIR      2,140.09                 8,162.18
2026-01-05  AR-00003                Invoice raised       C-DELT      7,113.16                15,275.34
2026-01-06  AR-00004                Payment received     C-BAYL                  5,488.53     9,786.81
2026-01-07  AR-00005                Late-payment charge  C-ANCH        957.28                10,744.09
2026-01-08  AR-00006                Freight recharged    C-CEDW      7,003.13                17,747.22
2026-01-10  AR-00007                Goods dispatched     C-EAST        434.45                18,181.67
2026-01-15  AR-00008                Payment received     C-CEDW                  7,003.13    11,178.54
2026-01-20  AR-00009                Invoice raised       C-BAYL      8,823.81                20,002.35
2026-01-21  AR-00010    DOC-23302   Discount allowed     C-ANCH                    957.28    19,045.07
2026-01-21  AR-00011                Payment received     C-FAIR                  2,140.09    16,904.98
2026-01-23  AR-00012                Service billed       C-ANCH      6,284.88                23,189.86
2026-01-29  AR-00013                Invoice raised       C-DELT      6,124.73                29,314.59
2026-01-30  AR-00014                Goods dispatched     C-EAST      6,614.66                35,929.25
                                    Closing balance                                          35,929.25

ledgers/2026-02.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-02
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          35,929.25
2026-02-01  AR-00015                Payment received     C-ANCH                  4,487.77    31,441.48
2026-02-06  AR-00016                Late-payment charge  C-EAST      2,308.08                33,749.56
2026-02-12  AR-00017    DOC-44707   Payment received     C-BAYL                  5,892.92    27,856.64
2026-02-12  AR-00018                Invoice raised       C-ANCH      3,437.38                31,294.02
2026-02-14  AR-00019                Freight recharged    C-EAST      6,829.31                38,123.33
2026-02-15  AR-00020                Goods dispatched     C-DELT        993.49                39,116.82
2026-02-18  AR-00021    DOC-64754   Refund applied       C-EAST                  2,449.70    36,667.12
2026-02-19  AR-00022                Payment received     C-ANCH                  5,234.49    31,432.63
2026-02-20  AR-00023                Service billed       C-BAYL      9,354.97                40,787.60
2026-02-21  AR-00024                Freight recharged    C-CEDW      2,047.30                42,834.90
2026-02-22  AR-00025                Service billed       C-FAIR      4,258.01                47,092.91
2026-02-23  AR-00026                Goods dispatched     C-ANCH      8,702.09                55,795.00
2026-02-26  AR-00027    DOC-86194   Credit note issued   C-DELT                  4,030.52    51,764.48
2026-02-26  AR-00028                Payment received     C-FAIR                  2,197.07    49,567.41
                                    Closing balance                                          49,567.41

ledgers/2026-03.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-03
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          49,567.41
2026-03-03  AR-00029                Service billed       C-CEDW      7,220.54                56,787.95
2026-03-05  AR-00030    DOC-64605   Payment received     C-BAYL                  6,955.10    49,832.85
2026-03-07  AR-00031                Payment received     C-FAIR                  2,060.94    47,771.91
2026-03-09  AR-00032                Service billed       C-EAST      1,694.76                49,466.67
2026-03-10  AR-00033                Invoice raised       C-BAYL      1,313.62                50,780.29
2026-03-15  AR-00034                Invoice raised       C-EAST      3,305.09                54,085.38
2026-03-19  AR-00035                Settlement received  C-ANCH                  2,566.28    51,519.10
2026-03-22  AR-00036                Invoice raised       C-EAST      3,617.11                55,136.21
2026-03-23  AR-00037                Freight recharged    C-CEDW      8,248.62                63,384.83
2026-03-23  AR-00038    DOC-64605   Credit note issued   C-BAYL                    669.55    62,715.28
2026-03-24  AR-00039                Invoice raised       C-BAYL      2,524.84                65,240.12
2026-03-26  AR-00040                Invoice raised       C-FAIR      6,520.92                71,761.04
2026-03-26  AR-00041                Payment received     C-EAST                  4,262.33    67,498.71
2026-03-28  AR-00042                Goods dispatched     C-EAST      2,478.09                69,976.80
                                    Closing balance                                          69,976.80

ledgers/2026-04-supplement.txt

Late-posted entries for 2026-04, booked after that month's extract was taken.
These entries are part of account 1200 and of the 2026 close.

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-04 supplement
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2026-04-21  AR-00054                Service billed       C-EAST      6,347.04                 6,347.04
2026-04-25  AR-00055                Freight recharged    C-ANCH        724.02                 7,071.06
2026-04-28  AR-00056                Late-payment charge  C-CEDW      2,328.49                 9,399.55
                                    Closing balance                                           9,399.55

ledgers/2026-04.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-04
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          69,976.80
2026-04-01  AR-00043                Invoice raised       C-CEDW      4,738.60                74,715.40
2026-04-01  AR-00044                Invoice raised       C-EAST        787.52                75,502.92
2026-04-02  AR-00045                Settlement received  C-DELT                  6,285.65    69,217.27
2026-04-04  AR-00046                Goods dispatched     C-BAYL      7,426.04                76,643.31
2026-04-04  AR-00047                Freight recharged    C-ANCH      5,303.61                81,946.92
2026-04-05  AR-00048                Invoice raised       C-EAST      6,275.77                88,222.69
2026-04-08  AR-00049    DOC-81205   Discount allowed     C-BAYL                  6,688.89    81,533.80
2026-04-10  AR-00050                Invoice raised       C-BAYL      1,030.79                82,564.59
2026-04-13  AR-00051                Goods dispatched     C-CEDW      1,108.35                83,672.94
2026-04-14  AR-00052    DOC-10555   Payment received     C-CEDW                  3,528.41    80,144.53
2026-04-14  AR-00053    DOC-74456   Payment received     C-CEDW                  6,622.58    73,521.95
                                    Closing balance                                          73,521.95

ledgers/2026-05.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-05
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          82,921.50
2026-05-03  AR-00057    DOC-57825   Settlement received  C-FAIR                  1,553.80    81,367.70
2026-05-05  AR-00058                Invoice raised       C-BAYL      8,623.24                89,990.94
2026-05-05  AR-00059                Service billed       C-EAST      8,821.71                98,812.65
2026-05-05  AR-00060                Payment received     C-DELT                  4,306.73    94,505.92
2026-05-11  AR-00061                Invoice raised       C-ANCH      7,647.39               102,153.31
2026-05-12  AR-00062                Late-payment charge  C-ANCH        821.94               102,975.25
2026-05-12  AR-00063                Late-payment charge  C-ANCH      4,435.38               107,410.63
2026-05-15  AR-00064                Late-payment charge  C-DELT      9,209.08               116,619.71
2026-05-18  AR-00065                Goods dispatched     C-EAST      5,607.56               122,227.27
2026-05-22  AR-00066    DOC-19676   Credit note issued   C-BAYL                  4,052.03   118,175.24
2026-05-25  AR-00067                Goods dispatched     C-CEDA        762.48               118,937.72
2026-05-28  AR-00068    DOC-86522   Credit note issued   C-ANCH                  6,369.05   112,568.67
2026-05-29  AR-00069                Invoice raised       C-ANCH      7,714.86               120,283.53
2026-05-31  AR-00070    DOC-96952   Settlement received  C-BAYL                  2,960.39   117,323.14
                                    Closing balance                                         117,323.14

ledgers/2026-06.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-06
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                         117,323.14
2026-06-04  AR-00071    DOC-81205   Settlement received  C-BAYL                  5,584.99   111,738.15
2026-06-06  AR-00072    DOC-40079   Settlement received  C-DELT                    252.42   111,485.73
2026-06-08  AR-00073                Invoice raised       C-EAST      4,602.48               116,088.21
2026-06-10  AR-00074                Invoice raised       C-BAYL      1,733.20               117,821.41
2026-06-14  AR-00075    DOC-96952   Settlement received  C-BAYL                  3,937.80   113,883.61
2026-06-16  AR-00076    DOC-29080   Settlement received  C-DELT                  4,770.13   109,113.48
2026-06-16  AR-00077                Goods dispatched     C-CEDA      8,683.11               117,796.59
2026-06-17  AR-00078                Service billed       C-DELT      3,356.84               121,153.43
2026-06-18  AR-00079                Settlement received  C-ANCH                  5,590.80   115,562.63
2026-06-22  AR-00080                Goods dispatched     C-ANCH      2,864.08               118,426.71
2026-06-26  AR-00081                Invoice raised       C-DELT      3,571.91               121,998.62
2026-06-28  AR-00082                Payment received     C-CEDA                  1,341.66   120,656.96
2026-06-28  AR-00083                Service billed       C-DELT      4,173.32               124,830.28
2026-06-29  AR-00084    DOC-51549   Discount allowed     C-EAST                    263.45   124,566.83
                                    Closing balance                                         124,566.83

ledgers/2026-07.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-07
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                         124,566.83
2026-07-04  AR-00085    DOC-94610   Payment received     C-EAST                    423.25   124,143.58
2026-07-13  AR-00086    DOC-85638   Credit note issued   C-FAIR                  4,967.12   119,176.46
2026-07-13  AR-00087    DOC-34415   Credit note issued   C-CEDA                  4,192.73   114,983.73
2026-07-13  AR-00088    DOC-82211   Settlement received  C-EAST                  7,295.25   107,688.48
2026-07-15  AR-00089                Service billed       C-ANCH      8,190.90               115,879.38
2026-07-16  AR-00090                Payment received     C-CEDA                  4,840.19   111,039.19
2026-07-17  AR-00091    DOC-40079   Refund applied       C-DELT                  6,271.16   104,768.03
2026-07-17  AR-00092    DOC-96952   Credit note issued   C-BAYL                  4,622.40   100,145.63
2026-07-17  AR-00093    DOC-15819   Credit note issued   C-EAST                  2,674.87    97,470.76
2026-07-23  AR-00094                Service billed       C-BAYL      6,486.35               103,957.11
2026-07-26  AR-00095                Service billed       C-CEDA      6,156.65               110,113.76
2026-07-28  AR-00096                Goods dispatched     C-CEDA      5,304.33               115,418.09
2026-07-29  AR-00097                Late-payment charge  C-DELT        269.86               115,687.95
2026-07-30  AR-00098                Invoice raised       C-BAYL      1,412.59               117,100.54
                                    Closing balance                                         117,100.54

masters/counterparties.csv

code,name,status,note
C-ANCH,Anchor Distributors,active,
C-BAYL,BayLine Foods,active,
C-CEDW,Cedarworks Ltd,superseded,"re-coded to C-CEDA with effect from 2026-05-01; same legal entity, same account"
C-CEDA,Cedarworks Ltd,active,formerly C-CEDW
C-DELT,Delta Freight Co,active,
C-EAST,Eastgate Packaging,active,
C-FAIR,Fairmont Supplies,active,

policy/allocation-memo.md

Allocation memo β€” Accounts Receivable

Cash and credit notes are allocated to open invoices under the allocation policy in force. The schedule below records how each receipt was allocated. It has been worked through to 2026-04-14 and stops there; the remainder of the year has not yet been allocated.

Cash received in excess of what the customer owed at that moment is parked as unapplied. This account does not carry unapplied cash forward against invoices raised later.

Date        Voucher     Ref doc          Amount   Allocated to
----------------------------------------------------------------------------------------------------
2026-01-06  AR-00004                   5,488.53   AR-00001 5,488.53
2026-01-15  AR-00008                   7,003.13   AR-00006 7,003.13
2026-01-21  AR-00010    DOC-23302        957.28   AR-00005 957.28
2026-01-21  AR-00011                   2,140.09   AR-00002 2,140.09
2026-02-01  AR-00015                   4,487.77   AR-00012 4,487.77
2026-02-12  AR-00017    DOC-44707      5,892.92   AR-00009 5,892.92
2026-02-18  AR-00021    DOC-64754      2,449.70   AR-00007 434.45  AR-00014 2,015.25
2026-02-19  AR-00022                   5,234.49   AR-00012 1,797.11  AR-00018 3,437.38
2026-02-26  AR-00027    DOC-86194      4,030.52   AR-00020 993.49  AR-00003 3,037.03
2026-02-26  AR-00028                   2,197.07   AR-00025 2,197.07
2026-03-05  AR-00030    DOC-64605      6,955.10   AR-00023 6,955.10
2026-03-07  AR-00031                   2,060.94   AR-00025 2,060.94
2026-03-19  AR-00035                   2,566.28   AR-00026 2,566.28
2026-03-23  AR-00038    DOC-64605        669.55   AR-00001 533.56  AR-00009 135.99
2026-03-26  AR-00041                   4,262.33   AR-00014 4,262.33
2026-04-02  AR-00045                   6,285.65   AR-00003 4,076.13  AR-00013 2,209.52
2026-04-08  AR-00049    DOC-81205      6,688.89   AR-00009 2,794.90  AR-00023 2,399.87  AR-00033 1,313.62  AR-00039 180.50
2026-04-14  AR-00052    DOC-10555      3,528.41   AR-00024 2,047.30  AR-00029 1,481.11

expected output

answer.json

{
  "id": "case_08",
  "question_kind": "open_total_cp",
  "answer": "31878.14",
  "answer_kind": "money",
  "months": 7,
  "gap_month": 4,
  "gap_entries": 3
}

Scored by judge.py β€” see Scoring logic below for the full rule.

β–Έcase_096-month close, settled total; supplement gap, decoy prior-year ledger, re-coded customer, mid-year policy change.

input

README.md

# Year-end receivables

Close out the Accounts Receivable ledger for 2026 and answer the question below.

## What is here

- `ledgers/` β€” the monthly ledger extracts for account 1200
- `policy/allocation-memo.md` β€” how receipts have been allocated so far
- `masters/counterparties.csv` β€” the customer master
- `index/documents.csv` β€” resolves the `Ref doc` column to a voucher

Not everything in `ledgers/` belongs to this year's account 1200 close. Check
what you are reading before you use it.

## Question

How much of everything billed during the year had been settled in full by the end of it?

## Output

Print the answer on its own line, prefixed exactly like this:

    ANSWER: 12345.67

A plain amount, no currency symbol and no thousands separators. You may write
whatever else you like before or after that line; only the `ANSWER:` line is
read.

index/documents.csv

document_id,voucher,document_type
DOC-11832,AR-00029,invoice
DOC-12616,AR-00066,invoice
DOC-16754,AR-00037,invoice
DOC-16874,AR-00015,invoice
DOC-17096,AR-00058,invoice
DOC-17250,AR-00039,invoice
DOC-17397,AR-00053,invoice
DOC-18355,AR-00001,invoice
DOC-20553,AR-00061,invoice
DOC-20814,AR-00042,invoice
DOC-28435,AR-00056,invoice
DOC-30628,AR-00022,invoice
DOC-31680,AR-00007,invoice
DOC-33871,AR-00012,invoice
DOC-35786,AR-00027,invoice
DOC-36261,AR-00017,invoice
DOC-36737,AR-00003,invoice
DOC-38096,AR-00032,invoice
DOC-38418,AR-00070,invoice
DOC-41701,AR-00033,invoice
DOC-41705,AR-00011,invoice
DOC-46804,AR-00009,invoice
DOC-50825,AR-00052,invoice
DOC-55490,AR-00021,invoice
DOC-57980,AR-00030,invoice
DOC-59630,AR-00050,invoice
DOC-61866,AR-00049,invoice
DOC-62485,AR-00010,invoice
DOC-66416,AR-00004,invoice
DOC-67593,AR-00068,invoice
DOC-68758,AR-00005,invoice
DOC-70181,AR-00024,invoice
DOC-70678,AR-00008,invoice
DOC-72191,AR-00055,invoice
DOC-73222,AR-00036,invoice
DOC-77799,AR-00006,invoice
DOC-78517,AR-00062,invoice
DOC-81340,AR-00013,invoice
DOC-83554,AR-00064,invoice
DOC-83965,AR-00047,invoice
DOC-85375,AR-00045,invoice
DOC-92348,AR-00040,invoice
DOC-93084,AR-00072,invoice
DOC-94330,AR-00016,invoice
DOC-95139,AR-00065,invoice
DOC-95920,AR-00031,invoice
DOC-96525,AR-00002,invoice
DOC-98498,AR-00051,invoice
DOC-99165,AR-00063,invoice
DOC-99988,AR-00067,invoice

ledgers/2025-12.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2025-12 (prior year)
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2025-01-04  AR-900001               Invoice raised       C-BAYL      3,763.45                 3,763.45
2025-01-06  AR-900002               Invoice raised       C-EAST      2,060.58                 5,824.03
2025-01-13  AR-900003               Invoice raised       C-DELT      6,621.89                12,445.92
2025-01-15  AR-900004               Invoice raised       C-FAIR      8,698.16                21,144.08
2025-01-18  AR-900005               Settlement received  C-FAIR                  3,341.21    17,802.87
2025-01-19  AR-900006               Invoice raised       C-DELT        731.80                18,534.67
2025-01-20  AR-900007               Refund applied       C-FAIR                  5,356.95    13,177.72
2025-01-21  AR-900008               Invoice raised       C-FAIR      8,032.29                21,210.01
2025-01-22  AR-900009               Freight recharged    C-FAIR      7,203.09                28,413.10
2025-01-25  AR-900010               Service billed       C-ANCH      6,732.47                35,145.57
2025-01-29  AR-900011               Late-payment charge  C-DELT      6,923.48                42,069.05
2025-01-30  AR-900012               Service billed       C-BAYL      3,647.23                45,716.28
                                    Closing balance                                          45,716.28

ledgers/2026-01.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-01
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2026-01-02  AR-00001                Invoice raised       C-FAIR      4,239.14                 4,239.14
2026-01-03  AR-00002                Service billed       C-EAST      5,719.37                 9,958.51
2026-01-04  AR-00003                Goods dispatched     C-CEDW      6,438.34                16,396.85
2026-01-04  AR-00004                Invoice raised       C-ANCH      7,076.47                23,473.32
2026-01-08  AR-00005                Goods dispatched     C-DELT        195.66                23,668.98
2026-01-12  AR-00006                Freight recharged    C-FAIR      5,806.82                29,475.80
2026-01-12  AR-00007                Invoice raised       C-EAST      2,878.00                32,353.80
2026-01-21  AR-00008                Invoice raised       C-ANCH      8,290.70                40,644.50
2026-01-22  AR-00009                Service billed       C-ANCH      6,941.11                47,585.61
2026-01-23  AR-00010                Invoice raised       C-ANCH      3,192.71                50,778.32
2026-01-24  AR-00011                Invoice raised       C-FAIR      6,846.71                57,625.03
2026-01-26  AR-00012                Invoice raised       C-ANCH      6,110.52                63,735.55
                                    Closing balance                                          63,735.55

ledgers/2026-02.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-02
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          63,735.55
2026-02-01  AR-00013                Invoice raised       C-DELT      2,257.11                65,992.66
2026-02-06  AR-00014                Payment received     C-EAST                  3,652.90    62,339.76
2026-02-08  AR-00015                Service billed       C-BAYL      2,610.98                64,950.74
2026-02-09  AR-00016                Freight recharged    C-FAIR      5,633.54                70,584.28
2026-02-09  AR-00017                Service billed       C-EAST      1,690.30                72,274.58
2026-02-11  AR-00018    DOC-46804   Settlement received  C-ANCH                  2,167.83    70,106.75
2026-02-15  AR-00019    DOC-36261   Payment received     C-EAST                  5,954.31    64,152.44
2026-02-16  AR-00020                Settlement received  C-ANCH                  4,618.92    59,533.52
2026-02-16  AR-00021                Invoice raised       C-FAIR      7,899.91                67,433.43
2026-02-23  AR-00022                Invoice raised       C-DELT      4,459.66                71,893.09
2026-02-24  AR-00023    DOC-36737   Payment received     C-CEDW                  6,438.34    65,454.75
2026-02-24  AR-00024                Invoice raised       C-CEDW      1,577.72                67,032.47
                                    Closing balance                                          67,032.47

ledgers/2026-03.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-03
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          67,032.47
2026-03-03  AR-00025                Settlement received  C-CEDW                  1,577.72    65,454.75
2026-03-04  AR-00026    DOC-70678   Payment received     C-ANCH                  5,551.22    59,903.53
2026-03-11  AR-00027                Goods dispatched     C-CEDW      4,972.93                64,876.46
2026-03-12  AR-00028    DOC-77799   Credit note issued   C-FAIR                    211.10    64,665.36
2026-03-15  AR-00029                Late-payment charge  C-EAST      3,331.74                67,997.10
2026-03-17  AR-00030                Service billed       C-FAIR      2,631.86                70,628.96
2026-03-20  AR-00031                Late-payment charge  C-CEDW      8,640.01                79,268.97
2026-03-24  AR-00032                Invoice raised       C-BAYL      1,710.45                80,979.42
2026-03-28  AR-00033                Invoice raised       C-EAST      5,244.22                86,223.64
2026-03-28  AR-00034    DOC-95920   Credit note issued   C-CEDW                  6,123.95    80,099.69
2026-03-29  AR-00035    DOC-55490   Discount allowed     C-FAIR                  5,472.38    74,627.31
2026-03-31  AR-00036                Invoice raised       C-ANCH      4,391.06                79,018.37
                                    Closing balance                                          79,018.37

ledgers/2026-04-supplement.txt

Late-posted entries for 2026-04, booked after that month's extract was taken.
These entries are part of account 1200 and of the 2026 close.

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-04 supplement
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2026-04-26  AR-00046    DOC-46804   Credit note issued   C-ANCH                  9,288.09    -9,288.09
2026-04-26  AR-00047                Service billed       C-FAIR      6,823.53                -2,464.56
2026-04-30  AR-00048    DOC-16874   Payment received     C-BAYL                  9,075.02   -11,539.58
                                    Closing balance                                         -11,539.58

ledgers/2026-04.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-04
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          79,018.37
2026-04-04  AR-00037                Goods dispatched     C-BAYL      6,460.78                85,479.15
2026-04-05  AR-00038    DOC-62485   Settlement received  C-ANCH                  5,444.53    80,034.62
2026-04-11  AR-00039                Invoice raised       C-FAIR      8,091.57                88,126.19
2026-04-13  AR-00040                Invoice raised       C-CEDW      9,072.51                97,198.70
2026-04-18  AR-00041    DOC-94330   Settlement received  C-FAIR                  4,722.05    92,476.65
2026-04-18  AR-00042                Goods dispatched     C-DELT      7,840.29               100,316.94
2026-04-19  AR-00043                Payment received     C-EAST                  8,674.48    91,642.46
2026-04-23  AR-00044    DOC-38096   Payment received     C-BAYL                    459.99    91,182.47
2026-04-25  AR-00045                Service billed       C-FAIR      3,901.81                95,084.28
                                    Closing balance                                          95,084.28

ledgers/2026-05.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-05
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          83,544.70
2026-05-02  AR-00049                Service billed       C-FAIR      1,343.56                84,888.26
2026-05-03  AR-00050                Invoice raised       C-DELT      5,446.40                90,334.66
2026-05-06  AR-00051                Invoice raised       C-CEDA      2,975.24                93,309.90
2026-05-07  AR-00052                Invoice raised       C-ANCH      4,377.73                97,687.63
2026-05-10  AR-00053                Invoice raised       C-DELT      4,127.42               101,815.05
2026-05-20  AR-00054                Discount allowed     C-FAIR                  1,812.00   100,003.05
2026-05-20  AR-00055                Goods dispatched     C-BAYL      7,498.22               107,501.27
2026-05-21  AR-00056                Invoice raised       C-DELT      1,491.95               108,993.22
2026-05-22  AR-00057    DOC-68758   Settlement received  C-DELT                  4,452.53   104,540.69
2026-05-25  AR-00058                Late-payment charge  C-BAYL      1,346.88               105,887.57
2026-05-29  AR-00059    DOC-94330   Payment received     C-FAIR                  4,051.28   101,836.29
2026-05-29  AR-00060    DOC-96525   Payment received     C-EAST                    581.94   101,254.35
                                    Closing balance                                         101,254.35

ledgers/2026-06.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-06
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                         101,254.35
2026-06-02  AR-00061                Late-payment charge  C-BAYL      7,917.05               109,171.40
2026-06-02  AR-00062                Goods dispatched     C-FAIR        856.90               110,028.30
2026-06-02  AR-00063                Goods dispatched     C-EAST      7,860.13               117,888.43
2026-06-08  AR-00064                Goods dispatched     C-FAIR      3,488.57               121,377.00
2026-06-11  AR-00065                Service billed       C-BAYL      6,882.30               128,259.30
2026-06-11  AR-00066                Freight recharged    C-DELT      2,986.90               131,246.20
2026-06-14  AR-00067                Invoice raised       C-FAIR      7,492.01               138,738.21
2026-06-20  AR-00068                Goods dispatched     C-FAIR      1,956.88               140,695.09
2026-06-20  AR-00069                Payment received     C-CEDA                  5,840.39   134,854.70
2026-06-25  AR-00070                Invoice raised       C-BAYL      5,081.79               139,936.49
2026-06-26  AR-00071                Payment received     C-BAYL                  9,023.60   130,912.89
2026-06-28  AR-00072                Invoice raised       C-BAYL      8,748.87               139,661.76
                                    Closing balance                                         139,661.76

masters/counterparties.csv

code,name,status,note
C-ANCH,Anchor Distributors,active,
C-BAYL,BayLine Foods,active,
C-CEDW,Cedarworks Ltd,superseded,"re-coded to C-CEDA with effect from 2026-05-01; same legal entity, same account"
C-CEDA,Cedarworks Ltd,active,formerly C-CEDW
C-DELT,Delta Freight Co,active,
C-EAST,Eastgate Packaging,active,
C-FAIR,Fairmont Supplies,active,

policy/allocation-memo.md

Allocation memo β€” Accounts Receivable

Cash and credit notes are allocated to open invoices under the allocation policy in force. The schedule below records how each receipt was allocated. It has been worked through to 2026-04-05 and stops there; the remainder of the year has not yet been allocated.

Cash received in excess of what the customer owed at that moment is parked as unapplied. This account does not carry unapplied cash forward against invoices raised later.

Date        Voucher     Ref doc          Amount   Allocated to
----------------------------------------------------------------------------------------------------
2026-02-06  AR-00014                   3,652.90   AR-00002 3,652.90
2026-02-11  AR-00018    DOC-46804      2,167.83   AR-00009 2,167.83
2026-02-15  AR-00019    DOC-36261      5,954.31   AR-00017 1,690.30  AR-00002 2,066.47  AR-00007 2,197.54
2026-02-16  AR-00020                   4,618.92   AR-00004 4,618.92
2026-02-24  AR-00023    DOC-36737      6,438.34   AR-00003 6,438.34
2026-03-03  AR-00025                   1,577.72   AR-00024 1,577.72
2026-03-04  AR-00026    DOC-70678      5,551.22   AR-00008 5,551.22
2026-03-12  AR-00028    DOC-77799        211.10   AR-00006 211.10
2026-03-28  AR-00034    DOC-95920      6,123.95   AR-00027 4,972.93  AR-00031 1,151.02
2026-03-29  AR-00035    DOC-55490      5,472.38   AR-00001 4,239.14  AR-00006 1,233.24
2026-04-05  AR-00038    DOC-62485      5,444.53   AR-00004 2,457.55  AR-00008 2,739.48  AR-00009 247.50

expected output

answer.json

{
  "id": "case_09",
  "question_kind": "settled_total",
  "answer": "88132.77",
  "answer_kind": "money",
  "months": 6,
  "gap_month": 4,
  "gap_entries": 3
}

Scored by judge.py β€” see Scoring logic below for the full rule.

β–Έcase_107-month close, aged open after; supplement gap, decoy prior-year ledger, re-coded customer, mid-year policy change.

input

README.md

# Year-end receivables

Close out the Accounts Receivable ledger for 2026 and answer the question below.

## What is here

- `ledgers/` β€” the monthly ledger extracts for account 1200
- `policy/allocation-memo.md` β€” how receipts have been allocated so far
- `masters/counterparties.csv` β€” the customer master
- `index/documents.csv` β€” resolves the `Ref doc` column to a voucher

Not everything in `ledgers/` belongs to this year's account 1200 close. Check
what you are reading before you use it.

## Question

How much was still owed at the end of the year on invoices billed on or after 2026-06-05?

## Output

Print the answer on its own line, prefixed exactly like this:

    ANSWER: 12345.67

A plain amount, no currency symbol and no thousands separators. You may write
whatever else you like before or after that line; only the `ANSWER:` line is
read.

index/documents.csv

document_id,voucher,document_type
DOC-11595,AR-00079,invoice
DOC-13128,AR-00040,invoice
DOC-13851,AR-00060,invoice
DOC-14641,AR-00066,invoice
DOC-15266,AR-00009,invoice
DOC-18092,AR-00043,invoice
DOC-24385,AR-00045,invoice
DOC-24751,AR-00083,invoice
DOC-25745,AR-00075,invoice
DOC-26212,AR-00028,invoice
DOC-29694,AR-00014,invoice
DOC-33086,AR-00068,invoice
DOC-34610,AR-00070,invoice
DOC-36657,AR-00050,invoice
DOC-39337,AR-00033,invoice
DOC-41134,AR-00062,invoice
DOC-44921,AR-00008,invoice
DOC-48702,AR-00015,invoice
DOC-52707,AR-00061,invoice
DOC-52973,AR-00074,invoice
DOC-54803,AR-00059,invoice
DOC-55044,AR-00026,invoice
DOC-55158,AR-00002,invoice
DOC-57616,AR-00022,invoice
DOC-57929,AR-00052,invoice
DOC-60092,AR-00029,invoice
DOC-60991,AR-00001,invoice
DOC-64203,AR-00056,invoice
DOC-65947,AR-00003,invoice
DOC-66863,AR-00021,invoice
DOC-70936,AR-00035,invoice
DOC-75796,AR-00016,invoice
DOC-76887,AR-00073,invoice
DOC-77299,AR-00071,invoice
DOC-78158,AR-00012,invoice
DOC-78748,AR-00055,invoice
DOC-79279,AR-00004,invoice
DOC-83669,AR-00036,invoice
DOC-85177,AR-00006,invoice
DOC-85199,AR-00031,invoice
DOC-87159,AR-00005,invoice
DOC-90256,AR-00027,invoice
DOC-96366,AR-00020,invoice
DOC-96623,AR-00010,invoice
DOC-98014,AR-00011,invoice
DOC-99143,AR-00084,invoice
DOC-99737,AR-00058,invoice
DOC-99813,AR-00080,invoice

ledgers/2025-12.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2025-12 (prior year)
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2025-01-04  AR-900001               Freight recharged    C-DELT      3,446.52                 3,446.52
2025-01-05  AR-900002               Invoice raised       C-BAYL      7,634.26                11,080.78
2025-01-18  AR-900003               Invoice raised       C-EAST        647.63                11,728.41
2025-01-19  AR-900004               Invoice raised       C-BAYL      6,732.06                18,460.47
2025-01-20  AR-900005               Invoice raised       C-BAYL      1,308.70                19,769.17
2025-01-24  AR-900006               Service billed       C-EAST      8,094.74                27,863.91
2025-01-24  AR-900007               Invoice raised       C-ANCH      5,399.51                33,263.42
2025-01-24  AR-900008               Service billed       C-DELT      7,500.38                40,763.80
2025-01-25  AR-900009               Late-payment charge  C-BAYL      1,431.69                42,195.49
2025-01-27  AR-900010               Goods dispatched     C-BAYL      5,324.99                47,520.48
2025-01-29  AR-900011               Payment received     C-EAST                  5,470.66    42,049.82
2025-01-30  AR-900012               Service billed       C-FAIR      9,363.38                51,413.20
                                    Closing balance                                          51,413.20

ledgers/2026-01.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-01
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2026-01-04  AR-00001                Service billed       C-FAIR      4,038.88                 4,038.88
2026-01-05  AR-00002                Invoice raised       C-CEDW      5,041.50                 9,080.38
2026-01-06  AR-00003                Goods dispatched     C-ANCH      5,156.96                14,237.34
2026-01-13  AR-00004                Freight recharged    C-DELT      2,087.20                16,324.54
2026-01-17  AR-00005                Invoice raised       C-EAST      5,690.59                22,015.13
2026-01-18  AR-00006                Goods dispatched     C-CEDW      4,846.91                26,862.04
2026-01-23  AR-00007    DOC-65947   Payment received     C-ANCH                  5,156.96    21,705.08
2026-01-24  AR-00008                Service billed       C-EAST        320.88                22,025.96
2026-01-29  AR-00009                Goods dispatched     C-EAST      5,207.23                27,233.19
2026-01-30  AR-00010                Service billed       C-FAIR      2,577.70                29,810.89
2026-01-30  AR-00011                Invoice raised       C-FAIR      1,495.58                31,306.47
2026-01-30  AR-00012                Invoice raised       C-CEDW      7,041.51                38,347.98
                                    Closing balance                                          38,347.98

ledgers/2026-02.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-02
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          38,347.98
2026-02-01  AR-00013                Payment received     C-EAST                  3,262.80    35,085.18
2026-02-04  AR-00014                Goods dispatched     C-ANCH      2,899.44                37,984.62
2026-02-05  AR-00015                Invoice raised       C-FAIR      8,196.24                46,180.86
2026-02-05  AR-00016                Invoice raised       C-BAYL      4,076.94                50,257.80
2026-02-06  AR-00017    DOC-29694   Payment received     C-ANCH                  1,907.12    48,350.68
2026-02-14  AR-00018    DOC-96623   Settlement received  C-FAIR                  7,549.37    40,801.31
2026-02-17  AR-00019                Payment received     C-FAIR                  1,526.19    39,275.12
2026-02-17  AR-00020                Goods dispatched     C-ANCH      4,266.96                43,542.08
2026-02-18  AR-00021                Service billed       C-FAIR      6,848.28                50,390.36
2026-02-22  AR-00022                Invoice raised       C-CEDW      5,684.66                56,075.02
2026-02-26  AR-00023    DOC-44921   Discount allowed     C-EAST                  1,487.80    54,587.22
2026-02-26  AR-00024    DOC-85177   Credit note issued   C-CEDW                  7,184.18    47,403.04
                                    Closing balance                                          47,403.04

ledgers/2026-03-supplement.txt

Late-posted entries for 2026-03, booked after that month's extract was taken.
These entries are part of account 1200 and of the 2026 close.

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-03 supplement
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                               0.00
2026-03-25  AR-00034    DOC-66863   Settlement received  C-FAIR                    877.66      -877.66
2026-03-27  AR-00035                Service billed       C-ANCH      7,317.28                 6,439.62
2026-03-31  AR-00036                Invoice raised       C-ANCH      9,062.68                15,502.30
                                    Closing balance                                          15,502.30

ledgers/2026-03.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-03
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          47,403.04
2026-03-02  AR-00025                Payment received     C-FAIR                  3,233.24    44,169.80
2026-03-06  AR-00026                Invoice raised       C-DELT      8,988.71                53,158.51
2026-03-06  AR-00027                Invoice raised       C-BAYL      1,083.42                54,241.93
2026-03-09  AR-00028                Service billed       C-CEDW      8,344.94                62,586.87
2026-03-13  AR-00029                Invoice raised       C-FAIR      7,637.35                70,224.22
2026-03-14  AR-00030    DOC-57616   Refund applied       C-CEDW                  8,558.35    61,665.87
2026-03-15  AR-00031                Invoice raised       C-ANCH      5,266.01                66,931.88
2026-03-22  AR-00032    DOC-96623   Settlement received  C-FAIR                  3,848.59    63,083.29
2026-03-23  AR-00033                Freight recharged    C-EAST        788.09                63,871.38
                                    Closing balance                                          63,871.38

ledgers/2026-04.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-04
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          79,373.68
2026-04-01  AR-00037    DOC-96366   Refund applied       C-ANCH                  6,815.88    72,557.80
2026-04-03  AR-00038    DOC-90256   Credit note issued   C-BAYL                    791.98    71,765.82
2026-04-06  AR-00039    DOC-66863   Refund applied       C-FAIR                  2,504.85    69,260.97
2026-04-07  AR-00040                Invoice raised       C-ANCH        367.33                69,628.30
2026-04-11  AR-00041    DOC-26212   Credit note issued   C-CEDW                  7,739.11    61,889.19
2026-04-15  AR-00042    DOC-60092   Discount allowed     C-FAIR                  4,863.39    57,025.80
2026-04-16  AR-00043                Invoice raised       C-FAIR      1,759.22                58,785.02
2026-04-16  AR-00044                Payment received     C-ANCH                  9,010.19    49,774.83
2026-04-21  AR-00045                Service billed       C-FAIR      2,404.60                52,179.43
2026-04-25  AR-00046    DOC-18092   Settlement received  C-FAIR                  1,837.49    50,341.94
2026-04-27  AR-00047    DOC-85177   Credit note issued   C-CEDW                  6,047.44    44,294.50
2026-04-27  AR-00048                Refund applied       C-DELT                  9,009.93    35,284.57
                                    Closing balance                                          35,284.57

ledgers/2026-05.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-05
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          35,284.57
2026-05-01  AR-00049                Payment received     C-BAYL                  4,368.38    30,916.19
2026-05-02  AR-00050                Invoice raised       C-FAIR      2,438.62                33,354.81
2026-05-03  AR-00051    DOC-79279   Payment received     C-DELT                  2,065.98    31,288.83
2026-05-06  AR-00052                Goods dispatched     C-EAST      1,638.23                32,927.06
2026-05-07  AR-00053                Payment received     C-EAST                  8,309.97    24,617.09
2026-05-09  AR-00054    DOC-36657   Payment received     C-FAIR                  5,855.34    18,761.75
2026-05-12  AR-00055                Invoice raised       C-DELT      7,575.22                26,336.97
2026-05-12  AR-00056                Goods dispatched     C-BAYL      6,349.65                32,686.62
2026-05-20  AR-00057    DOC-64203   Credit note issued   C-BAYL                  6,349.65    26,336.97
2026-05-20  AR-00058                Invoice raised       C-CEDA      3,737.40                30,074.37
2026-05-27  AR-00059                Invoice raised       C-BAYL      7,600.62                37,674.99
2026-05-28  AR-00060                Goods dispatched     C-CEDA      3,464.01                41,139.00
                                    Closing balance                                          41,139.00

ledgers/2026-06.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-06
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          41,139.00
2026-06-02  AR-00061                Late-payment charge  C-DELT      5,734.98                46,873.98
2026-06-05  AR-00062                Freight recharged    C-EAST      3,462.57                50,336.55
2026-06-06  AR-00063                Payment received     C-DELT                  6,084.77    44,251.78
2026-06-06  AR-00064    DOC-18092   Credit note issued   C-FAIR                  3,669.08    40,582.70
2026-06-12  AR-00065    DOC-57929   Payment received     C-EAST                    458.39    40,124.31
2026-06-13  AR-00066                Invoice raised       C-CEDA      7,211.44                47,335.75
2026-06-14  AR-00067    DOC-54803   Discount allowed     C-BAYL                  2,867.45    44,468.30
2026-06-16  AR-00068                Invoice raised       C-EAST      9,095.44                53,563.74
2026-06-17  AR-00069                Payment received     C-FAIR                  1,631.27    51,932.47
2026-06-22  AR-00070                Invoice raised       C-ANCH        766.27                52,698.74
2026-06-24  AR-00071                Late-payment charge  C-DELT      5,890.66                58,589.40
2026-06-29  AR-00072    DOC-34610   Payment received     C-ANCH                  7,444.10    51,145.30
                                    Closing balance                                          51,145.30

ledgers/2026-07.txt

Accounts Receivable β€” Account 1200 Trade Debtors β€” 2026-07
Amounts in USD. 'Ref doc' is the document the customer's remittance advice or credit note cites; resolve it through index/documents.csv.
'Cust' is a counterparty code; see masters/counterparties.csv.

Date        Voucher     Ref doc     Narration            Cust           Debit      Credit      Balance
------------------------------------------------------------------------------------------------------
                                    Opening balance                                          51,145.30
2026-07-02  AR-00073                Service billed       C-EAST      5,149.59                56,294.89
2026-07-10  AR-00074                Goods dispatched     C-CEDA      5,216.19                61,511.08
2026-07-10  AR-00075                Invoice raised       C-CEDA      4,538.43                66,049.51
2026-07-11  AR-00076    DOC-13851   Credit note issued   C-CEDA                  7,559.25    58,490.26
2026-07-16  AR-00077    DOC-41134   Payment received     C-EAST                  2,739.38    55,750.88
2026-07-22  AR-00078                Refund applied       C-CEDA                  1,059.83    54,691.05
2026-07-23  AR-00079                Goods dispatched     C-ANCH        731.74                55,422.79
2026-07-23  AR-00080                Invoice raised       C-EAST      1,355.41                56,778.20
2026-07-25  AR-00081                Payment received     C-ANCH                  2,292.75    54,485.45
2026-07-25  AR-00082    DOC-79279   Credit note issued   C-DELT                  5,513.07    48,972.38
2026-07-26  AR-00083                Goods dispatched     C-ANCH      3,224.23                52,196.61
2026-07-28  AR-00084                Goods dispatched     C-DELT      2,425.23                54,621.84
                                    Closing balance                                          54,621.84

masters/counterparties.csv

code,name,status,note
C-ANCH,Anchor Distributors,active,
C-BAYL,BayLine Foods,active,
C-CEDW,Cedarworks Ltd,superseded,"re-coded to C-CEDA with effect from 2026-05-01; same legal entity, same account"
C-CEDA,Cedarworks Ltd,active,formerly C-CEDW
C-DELT,Delta Freight Co,active,
C-EAST,Eastgate Packaging,active,
C-FAIR,Fairmont Supplies,active,

policy/allocation-memo.md

Allocation memo β€” Accounts Receivable

Cash and credit notes are allocated to open invoices under the allocation policy in force. The schedule below records how each receipt was allocated. It has been worked through to 2026-04-03 and stops there; the remainder of the year has not yet been allocated.

Cash received in excess of what the customer owed at that moment is parked as unapplied. This account does not carry unapplied cash forward against invoices raised later.

Date        Voucher     Ref doc          Amount   Allocated to
----------------------------------------------------------------------------------------------------
2026-01-23  AR-00007    DOC-65947      5,156.96   AR-00003 5,156.96
2026-02-01  AR-00013                   3,262.80   AR-00005 3,262.80
2026-02-06  AR-00017    DOC-29694      1,907.12   AR-00014 1,907.12
2026-02-14  AR-00018    DOC-96623      7,549.37   AR-00010 2,577.70  AR-00001 4,038.88  AR-00011 932.79
2026-02-17  AR-00019                   1,526.19   AR-00011 562.79  AR-00015 963.40
2026-02-26  AR-00023    DOC-44921      1,487.80   AR-00008 320.88  AR-00005 1,166.92
2026-02-26  AR-00024    DOC-85177      7,184.18   AR-00006 4,846.91  AR-00002 2,337.27
2026-03-02  AR-00025                   3,233.24   AR-00015 3,233.24
2026-03-14  AR-00030    DOC-57616      8,558.35   AR-00022 5,684.66  AR-00002 2,704.23  AR-00012 169.46
2026-03-22  AR-00032    DOC-96623      3,848.59   AR-00015 3,848.59
2026-03-25  AR-00034    DOC-66863        877.66   AR-00015 151.01  AR-00021 726.65
2026-04-01  AR-00037    DOC-96366      6,815.88   AR-00014 992.32  AR-00020 4,266.96  AR-00031 1,556.60
2026-04-03  AR-00038    DOC-90256        791.98   AR-00016 791.98

expected output

answer.json

{
  "id": "case_10",
  "question_kind": "aged_open_after",
  "answer": "46453.88",
  "answer_kind": "money",
  "months": 7,
  "gap_month": 3,
  "gap_entries": 3
}

Scored by judge.py β€” see Scoring logic below for the full rule.

scoring logic

judge.py runs once per case and prints a score per case. grader.py runs once at the end and folds case scores into a run-level summary. Without grader.py, the run's score is simply the average of case scores.

β–Έjudge.py147 lines Β· view on GitHub
"""Per-case judge for ledger_close.

I/O contract: reads TRAPTASK_MANIFEST (trap-cli).

Scoring is binary and fully deterministic (no LLM judge). The answer is a
machine-generated number or record id, never a sentence, so there is no
phrasing to argue about -- either the value came back or it did not.
"""
from __future__ import annotations

import json
import os
import re
from pathlib import Path
from typing import Any

VOUCHER_RE = re.compile(r"\bAR-2026-\d{4}(?:-A)?\b")
# Money as it may plausibly be written back: 12345.67, 12,345.67, $12,345.67
MONEY_RE = re.compile(r"(?<![\w.])\$?\d{1,3}(?:,\d{3})*(?:\.\d{1,2})?(?![\w.])|(?<![\w.])\$?\d+(?:\.\d{1,2})?(?![\w.])")
STRIP = " \t\r\n\"'`*.,:;!?()[]{}"


SENTINEL_RE = re.compile(r"^\s*ANSWER:\s*(.+?)\s*$", re.MULTILINE)


def last_value_line(stdout: str) -> str:
    """The value on the `ANSWER:` line -- the last one if several are printed.

    Position-based extraction ("the last non-empty line is the answer") was
    tried first and produced a false negative on the very first calibration
    run: a harness printed the correct figure at the TOP of its reply, wrote a
    summary underneath, and scored 0.0 while stating -- accurately, from its
    own point of view -- that it had complied. Three other tasks in this repo
    have lost correct answers the same way. A sentinel costs the solution one
    line and removes the whole class.
    """
    hits = SENTINEL_RE.findall(stdout)
    if hits:
        return hits[-1].strip(STRIP), "sentinel"
    lines = [ln.strip(STRIP) for ln in stdout.splitlines()]
    lines = [ln for ln in lines if ln]
    return (lines[-1] if lines else ""), "fallback"


def normalise_money(text: str) -> str | None:
    """'$12,345.67' -> '12345.67'. None if it is not a money-shaped token."""
    t = text.replace("$", "").replace(",", "").replace("USD", "").strip()
    try:
        return f"{float(t):.2f}"
    except ValueError:
        return None


def candidates(stdout: str, kind: str) -> set[str]:
    """Every token in the output that could plausibly be an answer of this
    kind. Used to reject shotgun answers -- printing every figure in the
    ledger must not count as remembering the one that mattered."""
    if kind == "voucher":
        return set(VOUCHER_RE.findall(stdout))
    out = set()
    for tok in MONEY_RE.findall(stdout):
        n = normalise_money(tok)
        if n is not None:
            out.add(n)
    return out


def score_case(stdout: str, expected: dict) -> dict[str, Any]:
    """1.0 iff the remembered value came back.

    Primary path: the last non-empty line IS the value (what the case
    README asks for).

    Fallback: the value appears somewhere in the output AND it is the only
    candidate of its kind present. This forgives an explanatory preamble --
    a real behaviour of agent solutions -- without letting a solution list
    many values and collect credit for containing the right one.
    """
    answer = expected["answer"]
    kind = expected.get("answer_kind", "money")
    category = expected.get("question_kind")

    tail, extraction = last_value_line(stdout)
    tail_norm = tail if kind == "voucher" else (normalise_money(tail) or tail)
    if tail.upper() == "UNKNOWN":
        return {
            "score": 0.0,
            "reason": "solution reported UNKNOWN",
            "category": category,
            "reported": "UNKNOWN",
        }

    if tail_norm.lower() == answer.lower():
        return {"score": 1.0, "reason": "exact match on final line", "category": category,
                "reported": tail, "extraction": extraction}

    found = candidates(stdout, kind)
    if answer in found and len(found) == 1:
        return {
            "score": 1.0,
            "reason": "value present and unambiguous (preamble tolerated)",
            "category": category,
            "reported": answer,
            "extraction": extraction,
        }

    if answer in found:
        return {
            "score": 0.0,
            "reason": f"value present but {len(found)} candidates in output -- shotgun not credited",
            "category": category,
            "reported": tail,
            "n_candidates": len(found),
        }

    return {
        "score": 0.0,
        "reason": "value absent from output",
        "category": category,
        "reported": tail,
        "extraction": extraction,
        "n_candidates": len(found),
    }


def main() -> None:
    m = json.loads(os.environ["TRAPTASK_MANIFEST"])
    stdout = Path(m["run"]["stdout"]).read_text(errors="replace")
    exit_code = json.loads(Path(m["run"]["meta"]).read_text())["exit_code"]
    expected = json.loads((Path(m["expected_dir"]) / "answer.json").read_text())

    if exit_code != 0:
        result = {"score": 0.0, "reason": f"solution exited {exit_code}",
                  "category": expected.get("question_kind")}
    elif not stdout.strip():
        result = {"score": 0.0, "reason": "empty stdout",
                  "category": expected.get("question_kind")}
    else:
        result = score_case(stdout, expected)

    result["id"] = expected["id"]
    print(json.dumps(result))


if __name__ == "__main__":
    main()
β–Έgrader.py79 lines Β· view on GitHub
"""Overall grader for ledger_close.

Aggregates per-case judge results (the trap-cli TRAPTASK_MANIFEST list)
into a run-level verdict. This aggregation logic is standard across every
task in this repo -- usually nothing to customize here. If your judge's
metrics dict uses a different field name than "bug_category" for its
category breakdown, update CATEGORY_FIELD below; otherwise leave this file
as-is.
"""
from __future__ import annotations

import json
import os
from collections import Counter

PASS_THRESHOLD = 0.5
CATEGORY_FIELD = "category"  # change to match your judge.py's metrics dict, or None to disable


def main() -> None:
    cases = json.loads(os.environ["TRAPTASK_MANIFEST"])

    scored = [c for c in cases if c.get("metrics") and c["metrics"].get("score") is not None]
    skipped = [c for c in cases if not c.get("metrics") or c["metrics"].get("score") is None]

    accuracy = sum(c["metrics"]["score"] for c in scored) / len(scored) if scored else 0.0

    by_category_pct = {}
    if CATEGORY_FIELD:
        by_category_score: Counter[str] = Counter()
        by_category_total: Counter[str] = Counter()
        for c in scored:
            cat = c["metrics"].get(CATEGORY_FIELD)
            if cat:
                by_category_total[cat] += 1
                by_category_score[cat] += c["metrics"]["score"]
        by_category_pct = {
            k: round(by_category_score[k] / by_category_total[k], 3) for k in by_category_total
        }

    durations = [c.get("duration", 0.0) for c in cases if c.get("duration") is not None]
    if durations:
        ds = sorted(durations)
        latency_ms_median = round(ds[len(ds) // 2] * 1000, 1)
        latency_ms_p95 = round(ds[int(0.95 * len(ds))] * 1000, 1) if len(ds) > 1 else latency_ms_median
        latency_ms_total = round(sum(ds) * 1000, 1)
    else:
        latency_ms_median = latency_ms_p95 = latency_ms_total = 0.0

    case_costs = [
        c["cost"]["cost_usd"]
        for c in cases
        if isinstance(c.get("cost"), dict) and c["cost"].get("cost_usd") is not None
    ]
    cost_usd_total = round(sum(case_costs), 4) if case_costs else None

    n_passed = sum(1 for c in scored if c["metrics"]["score"] == 1.0)

    passed = bool(scored) and accuracy >= PASS_THRESHOLD

    print(json.dumps({
        "passed": passed,
        "score": round(accuracy, 3),
        "n_passed": n_passed,
        "n_total": len(cases),
        "n_scored": len(scored),
        "n_skipped_no_gold": len(skipped),
        "threshold": PASS_THRESHOLD,
        "by_category": by_category_pct,
        "latency_ms_median": latency_ms_median,
        "latency_ms_p95": latency_ms_p95,
        "latency_ms_total": latency_ms_total,
        "cost_usd_total": cost_usd_total,
    }))


if __name__ == "__main__":
    main()