ChatFin/Hold, Skip or Post an Allocation, With Claude

Hold, Skip or Post an Allocation, With Claude

By Ashok ManthenaPublished 5 Nov 20268 min read
You need
Pools, drivers and departments, as CSV
Tested with
Claude Sonnet 5.5, made-up data, 5 Nov 2026
Result
40 statuses and 105 amounts match, both runs

Six rules, 40 pools, 8 departments

Every pool here splits into whole cents. Rule 6 lists seven input problems that must stop the run with nothing written. Of our 40 pools, 12 are at 99.99, 100.00, -99.99 and -100.00, three each.

Four have no driver rows, four have only an inactive driver, two small pools have every driver at 0, and the other 18 are positive and negative pools. The data is made up and has 8 departments.

Rules 2 to 4 of the prompt: post, hold or skip

A pool with no active driver value above 0 is "hold". That includes a pool with no driver rows at all, and one whose only driver rows belong to inactive departments. Any other pool with an amount under 100.00 in absolute value is "skip". Exactly 100.00 is not under. Every other pool is "post".

Input and output files

The script Claude wrote reads pool_costs.csv, drivers.csv and departments.csv and writes pool_status.csv and journal_lines.csv.

Columns in pool_costs.csv, drivers.csv and departments.csv
ColumnUsed for
pool, amount, pool_accountWhat is to be shared. A negative amount is a credit
pool, department, driver_valueThe weights. A pool can have no rows
department, expense_account, activeWhere a share is posted and whether the department counts

Ask Claude for a plan first

Attach pool_costs.csv, drivers.csv and departments.csv and paste this. We do not publish the data, so your numbers will differ from ours.

Prompt 1: plan
I work in the accounting team. At month end a tool should decide, for each shared cost pool, whether the allocation is posted, held for a person, or skipped. It should then prepare the journal for the pools that post.

I have three files:
- pool_costs.csv: one row per pool (pool, pool_name, pool_account, amount). The amount is what sits in the pool account. A negative amount is a credit.
- drivers.csv: one row per pool and department (pool, department, driver_value).
- departments.csv: department, expense_account, active (Y or N).

Our rules, in this order:
1. Only departments marked active = Y count. A department marked N gets nothing.
2. A pool with no active driver value above 0 is "hold". That includes a pool with no driver rows at all, and one whose only driver rows belong to inactive departments.
3. Any other pool with an amount under 100.00 in absolute value is "skip". Exactly 100.00 is not under.
4. Every other pool is "post". Split its amount over the active departments in proportion to their driver values. All the pools in these files split into whole cents, so if any share would not, stop.
5. A positive pool posts as a debit to each department's expense account and one credit to the pool account for the pool amount. A negative pool posts the other way round, with the amounts shown as positive numbers.
6. Stop and write nothing, with a message that names the row, if the input has any of these problems: a pool listed twice in pool_costs.csv, the same pool and department twice in drivers.csv, a negative driver value, a department in drivers.csv that is not in departments.csv, a driver row for a pool that is not in pool_costs.csv, an amount that is not a plain decimal number such as 1,000.00, or an active flag that is not Y or N.

Do not write code yet. Break the job into numbered steps. For each step say what could go wrong. Then list anything in my rules that is unclear.

Both runs gave eight steps. While planning, both ran a quick read-only check of the three files against the rules, although we had asked for no code yet, and neither reported writing an output file.

Both reported the same result from it: 10 hold, 6 skip and 24 post. Both plans raised these questions:

  • Whether "stop" means the whole run writes nothing or only the pool concerned. Both took it to mean the whole run.
  • CP-21 and CP-22 are under 100.00 and have every driver at 0. Run 1 asked whether they should hold or skip. Hold is checked before skip, so both pools hold.
  • Problems rule 6 does not list. Run 2 named a department listed twice in the departments file, a driver that is blank or not a number, and a blank amount, and asked about a lower-case flag. Run 1 asked about blank and non-number drivers and warned that stray spaces and mixed case could break a match.
  • What "held for a person" produces. Run 2 asked whether the person gets a list with the reason and a name.
  • The journal layout: columns, one entry per pool, where the posting date comes from.

We gave no answers and told Claude to use its plan.

Ask Claude to build it

Prompt 2: build and run
Good. Use that plan. Write one Python script, standard library only, that reads the three files and writes two files. pool_status.csv has one row per pool: pool, status (post, hold or skip), posted_total (the pool amount for post, 0.00 otherwise). journal_lines.csv has one row per journal line for the pools that post: entry (JE- followed by the pool), date (2026-10-31), account, department, debit, credit. Use exact decimal arithmetic for money. Never change my files. Run it, then show me the number of pools with each status, every pool that is not "post" with the reason, and check that every entry balances.

Claude Sonnet 5.5 (claude-sonnet-5-5) answered both prompts on 5 Nov 2026 as two turns of one Claude Code session with the files in a working folder, and the same two prompts again in a new session.

The first script is 245 lines of Python and the second is 300, standard library only, with exact arithmetic from Decimal and Fraction. Each posted 24 pools, put 10 on hold and skipped 6, and wrote 129 journal lines with 125,760.00 of debits and the same in credits.

Status of CP-01 to CP-22. CP-23 to CP-40 all post
PoolsAmountStatusWhy
CP-01 to CP-0399.99SkipUnder 100.00
CP-04 to CP-06-99.99SkipUnder 100.00 in absolute value
CP-07 to CP-09100.00PostFour departments take 25.00 each, or five take 20.00 each
CP-10 to CP-12-100.00PostA credit. The departments are credited and the pool account is debited 100.00
CP-13 to CP-164,800.00 and three moreHoldNo driver rows at all
CP-17 to CP-203,300.00 and three moreHoldThe only driver rows belong to inactive departments (Grove or Harbor)
CP-2150.00HoldEvery driver is 0
CP-22-20.00HoldSame, with a credit

Run 1 left the unused side of each journal line blank and run 2 wrote 0.00; the amounts match. Both kept the pool's own sign in posted_total (CP-10 shows -100.00) and showed journal amounts as positive numbers.

Both runs left the reason for each held or skipped pool out of the files. Our prompt gave pool_status.csv three columns and none holds a reason, so CP-13 shows only its amount and the word hold. Add a reason column to the prompt.

Checks: a key, 25 edge files, 1,993 random pools

1. A key kept out of the working folder

Our own code gave the status of all 40 pools and the amount on every department line, and we kept the key out of the folder we told Claude to work in.

We compared 40 statuses and 105 journal amounts, and the side each amount posts on. Neither run differed from the key. The two status files are identical, no pool that should not post has a journal line, and every entry balances.

2. Edge cases

We ran 25 small files through both scripts.

Edge case results
What we sentWhat happened
99.99 and -99.99; then 100.00 and -100.00; then 0.00Skip, skip, post, post as a credit, skip
50.00 with every driver at 0; 500.00 with no driver rows; 99.00 where the only driver is inactiveHold each time
An inactive department with a driver of 3 beside two active ones with 1 each on 400.00Post: 200.00 to each active department. The inactive one gets nothing
100.01 over four equal driversStopped, nothing written. Run 1 ends with: "share for department Delta would be 25.002500, not a whole number of cents"
A pool listed twice; the same pool and department twice; a negative driver; a department that is not in the departments file; a driver for a pool that does not exist; an amount typed 1,000.00; an active flag of MaybeEach stops the run with nothing written. The message gives the file, the line and the problem
An active flag of lower-case y; a blank amount; a driver of abc; a department listed twice in the departments fileStopped. A lower-case flag and a blank amount fall under rule 6. A non-number driver and a repeated department do not, and both runs stop on them anyway
A bad active flag on a department when the only pool would skip anywayStopped. Both runs check every row before they decide anything
A month in which nothing posts: 99.99 over three drivers, or a pool on holdRun 1 writes its two files and finishes. Run 2 writes both files, then ends with a Python error and exit code 1

3. 1,993 random pools against our own function

We made 2,000 random pools with positive and negative amounts, up to five departments, active and inactive, zero drivers and pools with no drivers, and amounts at 99.99 and 100.00.

Seven were dropped because their shares did not split into whole cents, which the rules stop on, leaving 1,993. Of them 528 are hold, 381 post and 1,084 skip.

Both scripts gave our status and our journal amounts on every pool, and wrote no journal for a pool that should not post. The key and our function share one reading of the six rules, so a wrong reading would pass in both scripts.