# Readings taken while applying the held-out specs

Written while implementing `rails/faults.py` from `rails/author-specs.json`, and committed before any check, new or
existing, ran on any held-out fault. Each fault was applied once to the clean records only to see that its selection
finds rows (a dry application, no check run). All ten selections found rows. The general rules of the prompt hold
throughout: selections on the original records, ids ascending, fewer rows means all of them, cents half up.

## Readings that apply to every spec

- **New ids** continue a table's sequence: the highest existing number plus one, same prefix and width, in the order of
  the selected rows. New rows go at the end of their table; the checks never rely on a table's stored order.
- **null** in a spec means the table's own empty value (a blank `invoice_id`).
- **"A matching P2 / P4 / P7 / P8 / P9 entry"** means a journal entry whose lines carry that source type and source id
  (for P2 and P4 the charge id, for P7 the dispute id, for P8 the payout id, for P9 the bank line id), dated as the spec
  says when it names a day.
- **Conditions in a selection** ("each must ...", "require ...") filter the candidates before the count is taken: the
  spec's rows are the lowest ids among the candidates that meet every condition.

## Per fault

- **R01.** The two qualifying June 2026 payout lines are BL-001106 and BL-001111. The new bank lines take ids BL-001517
  and BL-001518 at the end of the statement; each new entry has the spec's two lines.
- **R02.** "A matching P4 entry for its charge_id, dated available_on, with debit 6100 and credit 1150 both equal to
  -amount_usd" is read as an entry of exactly those two lines. The payouts, their item counts and the bank keep the
  original amounts, as the spec says.
- **R03.** "Delete each selected capture event" deletes the capture row only; the charge's authorization row stays.
- **R04.** The payment is the lowest payment id in September 2026 that meets every condition. Its bank line's
  remittance names the paid invoice, as required. Only the receivables credit row changes (to 2100, invoice blank).
- **R05.** One payout is created on 2026-09-30 and arrives on 2026-10-01; both lines of its P8 entry move to 2026-09-30.
- **R06.** `round_half_up(amount_presentment / fx_rate, 2)` uses the settlement item's own presented amount and rate.
  "A matching two-line P3 entry for the original difference S-C" is read as the settlement entry for that charge on its
  available day whose 1150 lines net to S-C. The rows are rewritten in line order, first to 1150 and second to 7100, as
  the spec says, whichever account each held before.
- **R07.** The selected refund (RF-00022) is on a USD card, so its P5 entry has two lines (4900 and 1150) and no currency
  difference; the spec allows two or three. Only the 4900 row's account changes.
- **R08.** The win's dispute fee item is the dispute_fee settlement item with the same dispute id and charge.
- **R09.** "Matching complete P4 entries" is read as entries of exactly two lines, one 6100 debit and one 1150 credit of
  the same amount, both with source type fee and the same charge id, whose charge has exactly one fee item available on
  the entry's day for minus that amount. The lowest entry id is taken.
- **R10.** "Whole-dollar floor" is the amount rounded down to whole dollars, written with two decimals. Only the payout
  record and the two lines of its P8 entry change; the bank keeps the full amount.

## The declared faults

The declared faults of DESIGN-rails.md section 6 are applied by the same file. One finds nothing: no card refund is
debited by the processor in September 2026 (the last refund in the records is debited on 2026-08-31), so "a refund never
posted" is reported as not applied, not moved to another month.
