{
 "faults": [
  {
   "id": "R01",
   "title": "Duplicate payout receipt imported into bank and ledger",
   "real_world_cause": "A bank-feed retry imports processor receipts twice under fresh statement-line IDs. The accounting connector posts both copies.",
   "tables": [
    "bank_statement_lines",
    "gl_journal_lines"
   ],
   "selection": "Select the 2 bank_statement_lines rows with lowest line_id among rows with counterparty='card processor', posted_on between 2026-06-01 and 2026-06-30 inclusive, and amount>0. Each must reference an existing processor_payouts.payout_id whose arrival_on equals posted_on and amount_usd equals amount, and have a matching P8 entry for that payout.",
   "changes": "For each selected original bank row b, let A=b.amount and d=b.posted_on. Add one bank_statement_lines row with line_id=new bank ID, posted_on=d, amount=A, counterparty=b.counterparty, reference=b.reference. Add one new gl_journal_lines entry with two rows: (entry_id=new journal ID, line_no=1, posted_on=d, account='1000', debit=A, credit=0.00, source_type='payout', source_id=b.reference, invoice_id=null); (same entry_id, line_no=2, posted_on=d, account='1150', debit=0.00, credit=A, source_type='payout', source_id=b.reference, invoice_id=null). Keep the original bank rows and entries. Do not change processor payouts or settlement items; the duplicate records represent no additional money movement.",
   "first_month": "2026-06",
   "books_effect": "Let A_total be the sum of the selected original bank amounts. Cash 1000 is overstated by A_total and Processor clearing 1150 has a debit balance understated by A_total. Correct balances count each actual payout receipt once and exclude both the duplicate bank rows and their duplicate P8 postings.",
   "month_end_close_would_catch": true,
   "month_end_close_reason": "Each payout reference appears twice in the bank and ledger but corresponds to only one processor payout."
  },
  {
   "id": "R02",
   "title": "Processing fee rows dropped from settlement import",
   "real_world_cause": "A settlement-file filter drops selected fee records. The fee-posting integration therefore omits their journals even though the processor deducted the fees from its payouts.",
   "tables": [
    "processor_settlement_items",
    "gl_journal_lines"
   ],
   "selection": "Select the 3 processor_settlement_items rows with lowest item_id among rows with item_type='fee', available_on between 2025-05-01 and 2025-05-31 inclusive, amount_usd<0, and non-null payout_id. Each must have a matching P4 entry for its charge_id, dated available_on, with debit 6100 and credit 1150 both equal to -amount_usd.",
   "changes": "Delete each selected settlement item and both lines of its matching P4 entry. Do not change the associated charge item, processor events, payout amount, payout item_count, bank receipt or P8 entry. These retained payout totals and item counts describe the actual processor payout, while its imported item detail is now incomplete. No fees, payouts or other amounts are recomputed.",
   "first_month": "2025-05",
   "books_effect": "Let F be minus the sum of the deleted items' original amount_usd. Processor fees 6100 is understated by F and Processor clearing 1150 is overstated by F. Correct balances include the omitted fees as debit 6100 and credit 1150; Cash remains correct because the actual net payout was retained.",
   "month_end_close_would_catch": true,
   "month_end_close_reason": "The retained payout amounts and item counts no longer reconcile to their settlement detail, and clearing retains the omitted fee amounts."
  },
  {
   "id": "R03",
   "title": "Capture webhooks lost after successful authorization",
   "real_world_cause": "A webhook queue loses successful capture messages. Authorizations and settlement reports arrive through separate paths, but the accounting system never posts the missing captures.",
   "tables": [
    "processor_events",
    "gl_journal_lines"
   ],
   "selection": "Select the 2 processor_events rows with lowest event_id among rows with event_type='capture', event_on between 2025-07-01 and 2025-07-31 inclusive, and amount_usd>0. Each must be the only capture event for its charge_id, have an authorization event for the same charge_id, have a charge settlement item for that charge_id, and have a matching P2 entry dated event_on.",
   "changes": "Delete each selected capture event and both lines of its matching P2 entry. Keep its authorization, invoice, settlement charge, fee, payout, bank receipt and all other journal entries unchanged. Do not change subsequent captures on the same invoice, including partial-payment completions. Settlement and cash records still describe the successful original capture.",
   "first_month": "2025-07",
   "books_effect": "Let C be the sum of the deleted capture events' original amount_usd. Receivables 1100 is overstated by C and Processor clearing 1150 is understated by C. Correct balances credit the paid invoice receivable and debit clearing by each missing capture's amount_usd, including only that capture's portion when the invoice had multiple captures.",
   "month_end_close_would_catch": true,
   "month_end_close_reason": "Settled charges without capture events or P2 entries leave paid invoices outstanding and create an unexplained clearing shortfall."
  },
  {
   "id": "R04",
   "title": "Identified contract receipt stranded in unapplied cash",
   "real_world_cause": "A payment-application handoff fails after finance's invoicing tool records the correct invoice. The ledger connector sends the receipt to unapplied cash instead of clearing that invoice.",
   "tables": [
    "gl_journal_lines"
   ],
   "selection": "Select the 1 contract_payments row with lowest payment_id among rows with paid_on between 2026-09-01 and 2026-09-30 inclusive and amount>0 that satisfy the following conditions. Its invoice has exactly one distinct contract_id in contract_invoice_lines; join that contract to crm_contracts to obtain account_id. There is exactly one bank_statement_lines row with posted_on=paid_on, amount=payment amount, counterparty=that account_id, and reference=the payment's invoice_id. There is a matching P9 entry with source_id equal to that bank line_id, debit 1000 for the payment amount, and credit 1100 for the same amount allocated to the payment's invoice_id.",
   "changes": "In the selected payment's matching P9 entry, change only the credit 1100 row: set account='2100' and invoice_id=null. Keep its debit, credit, source fields, posting date and entry_id unchanged. Keep the cash debit row unchanged. Do not change contract_payments, invoice lines or the bank statement; they retain the correct payment and remittance information.",
   "first_month": "2026-09",
   "books_effect": "Let A be the selected payment amount. Receivables 1100 is overstated by A and Unapplied cash 2100 is overstated by A. Correct balances apply the receipt as a credit to 1100 on the identified contract invoice, with no unapplied-cash liability for this receipt; Cash remains correct.",
   "month_end_close_would_catch": true,
   "month_end_close_reason": "The unapplied receipt has an exact invoice reference and a matching contract_payments allocation that identifies the receivable it should clear."
  },
  {
   "id": "R05",
   "title": "October payout receipt posted in September",
   "real_world_cause": "A payout connector uses the processor's payout creation date as the cash posting date. A payout initiated on September 30 is consequently booked before it reaches the bank.",
   "tables": [
    "gl_journal_lines"
   ],
   "selection": "Select the 1 processor_payouts row with lowest payout_id among rows with created_on='2026-09-30', arrival_on='2026-10-01', and amount_usd>0. Require exactly one matching bank_statement_lines row with counterparty='card processor', reference=payout_id, posted_on=arrival_on and amount=amount_usd, plus a matching P8 entry originally dated 2026-10-01.",
   "changes": "Set posted_on='2026-09-30' on both lines of the selected payout's P8 entry. Preserve its amounts, accounts, source fields, invoice_id, entry_id and line_no. Do not change the processor payout, its settlement items or the bank arrival record. Do not add another October P8 entry.",
   "first_month": "2026-09",
   "books_effect": "Let A be the selected payout amount. At September 30, Cash 1000 is overstated by A and Processor clearing 1150 is understated by A. Correct September balances exclude this bank receipt and retain A in clearing until the October 1 bank arrival, when P8 should post.",
   "month_end_close_would_catch": true,
   "month_end_close_reason": "The ledger includes September cash whose payout arrival and bank statement date are both October 1."
  },
  {
   "id": "R06",
   "title": "Accounting adapter inverts the settlement FX rate",
   "real_world_cause": "An accounting adapter mistakes a USD-per-CAD rate for CAD-per-USD. It divides the presented amount by the rate when calculating the settlement journal.",
   "tables": [
    "gl_journal_lines"
   ],
   "selection": "Select the 2 processor_settlement_items rows with lowest item_id among rows with item_type='charge', currency='CAD', available_on between 2026-09-01 and 2026-09-25 inclusive, and 0<fx_rate<1. For each candidate require exactly one capture event for charge_id. Define C as that capture's amount_usd, S as the item's original amount_usd, and S_bad as round_half_up(amount_presentment/fx_rate, 2). Require S_bad>S, S_bad>C, S!=C, and a matching two-line P3 entry for the original difference S-C dated available_on.",
   "changes": "For each selected item define D_bad=S_bad-C using the original values retained during selection. Order its matching P3 entry's two rows by line_no. On the first row set account='1150', debit=D_bad, credit=0.00 and invoice_id=null. On the second row set account='7100', debit=0.00, credit=D_bad and invoice_id=null. Preserve every other column on both rows. Do not change processor_fx_rates, processor events, settlement items, fees, payouts, bank receipts or other journals; only the accounting translation is wrong.",
   "first_month": "2026-09",
   "books_effect": "Let E be the sum of S_bad-S across selected items. Processor clearing 1150 is overstated by E and Currency gains and losses 7100 has an excess credit of E, overstating net currency gains or understating net currency losses. Correct P3 postings use S-C from the actual settled USD amounts; fee expense and Cash remain unchanged.",
   "month_end_close_would_catch": true,
   "month_end_close_reason": "The settlement journals disagree with the processor's USD settlement amounts and leave excess clearing unsupported by actual payouts."
  },
  {
   "id": "R07",
   "title": "Customer refund classified as a processing expense",
   "real_world_cause": "A refund account-mapping change points the billing refund debit to Processor fees. The processor clearing credit and any currency difference still post correctly.",
   "tables": [
    "gl_journal_lines"
   ],
   "selection": "Select the 1 processor_events row with lowest event_id among rows with event_type='refund', event_on between 2026-08-01 and 2026-08-31 inclusive, and amount_usd>0. Require its reference to match exactly one card_refunds.refund_id and require a matching complete P5 entry dated event_on. The P5 entry may have two or three lines, but must contain exactly one row with account='4900', debit equal to the billing refund amount and credit=0.00.",
   "changes": "Change account from '4900' to '6100' on that single refund debit row. Preserve all its other columns and every other line of its entry, including any 7100 currency difference. Keep the billing refund, processor refund event, settlement refund item, payouts and bank receipts unchanged. No amount is recomputed.",
   "first_month": "2026-08",
   "books_effect": "Let B be the selected billing refund amount. Refunds 4900 is understated by B and Processor fees 6100 is overstated by B. Correct balances classify B as a refund debit under P5 rather than a processing expense; Cash, clearing and currency gains and losses remain correct.",
   "month_end_close_would_catch": true,
   "month_end_close_reason": "The billing refund and processor refund event support a 4900 debit, while the ledger instead includes that amount among processing fees."
  },
  {
   "id": "R08",
   "title": "Dispute win incorrectly reimburses the dispute fee",
   "real_world_cause": "A dispute-win handler assumes that winning returns both principal and the dispute fee. It adds a fee-recovery journal even though this processor never returns the fee.",
   "tables": [
    "gl_journal_lines"
   ],
   "selection": "Select the 1 processor_events row with lowest event_id among rows with event_type='dispute_won', event_on between 2026-08-01 and 2026-08-31 inclusive, and amount_usd>0. Require a matching P7 entry dated event_on, an earlier dispute_opened event with the same reference and charge_id, and exactly one processor_settlement_items row with item_type='dispute_fee', the same reference and charge_id, and amount_usd=-17.50.",
   "changes": "For selected event e, add one new gl_journal_lines entry with two rows: (entry_id=new journal ID, line_no=1, posted_on=e.event_on, account='1150', debit=17.50, credit=0.00, source_type='dispute_won', source_id=e.reference, invoice_id=null); (same entry_id, line_no=2, posted_on=e.event_on, account='6120', debit=0.00, credit=17.50, source_type='dispute_won', source_id=e.reference, invoice_id=null). Keep the existing P7 principal-recovery entry. Do not add any processor event, settlement item, payout or bank receipt; the fee recovery is fictitious.",
   "first_month": "2026-08",
   "books_effect": "Processor clearing 1150 is overstated by 17.50 and Dispute fees 6120 is understated by 17.50. Correct balances retain the original nonrefundable dispute fee in expense and recognize only the actual principal returned by P7.",
   "month_end_close_would_catch": true,
   "month_end_close_reason": "The extra clearing debit has no processor reversal or payout support, and RAILS.md explicitly states that the dispute fee is never returned."
  },
  {
   "id": "R09",
   "title": "Manual journal nets processing fees against Billings",
   "real_world_cause": "An accountant interprets net processor receipts as the basis for presenting card billings. A manual reclassification moves a processing fee out of expense and into a reduction of Billings.",
   "tables": [
    "gl_journal_lines"
   ],
   "selection": "Select the 1 gl_journal_lines entry with lowest entry_id among matching complete P4 entries posted between 2026-06-01 and 2026-06-30 inclusive. Require exactly one debit 6100 row and one credit 1150 row for the same positive amount F, with source_type='fee' and a shared source_id equal to the charge_id of exactly one fee settlement item dated that entry's posted_on with amount_usd=-F.",
   "changes": "Let F be the selected entry's original debit to 6100 and c its source_id. Add one new gl_journal_lines entry with two rows: (entry_id=new journal ID, line_no=1, posted_on='2026-06-30', account='4000', debit=F, credit=0.00, source_type='fee', source_id=c, invoice_id=null); (same entry_id, line_no=2, posted_on='2026-06-30', account='6100', debit=0.00, credit=F, source_type='fee', source_id=c, invoice_id=null). Keep the original P4 entry and all processor, bank and billing records unchanged. The manual journal uses the original charge reference and the existing fee source classification.",
   "first_month": "2026-06",
   "books_effect": "Billings 4000 has a credit balance understated by F and Processor fees 6100 is understated by F. Correct balances retain gross invoiced billings under P1 and retain the fee as expense under P4, with no manual reclassification; Cash, Receivables, clearing and total profit are unchanged.",
   "month_end_close_would_catch": false,
   "month_end_close_reason": "The balanced reclassification leaves cash, receivables, clearing and total profit unchanged, so detection requires examining the account classification or reconciling Billings and fees to their sources."
  },
  {
   "id": "R10",
   "title": "Payout report parser truncates cents",
   "real_world_cause": "A payout-report parser converts decimal amounts to whole dollars before loading them. The accounting connector uses those truncated report amounts for P8, while the bank feed retains the actual receipts.",
   "tables": [
    "processor_payouts",
    "gl_journal_lines"
   ],
   "selection": "Select the 2 processor_payouts rows with lowest payout_id among rows with created_on between 2026-04-01 and 2026-04-30 inclusive, arrival_on between 2026-04-01 and 2026-04-30 inclusive, amount_usd>=1.00, and amount_usd unequal to its whole-dollar floor. Require exactly one bank_statement_lines row with counterparty='card processor', reference=payout_id, posted_on=arrival_on and amount equal to the original amount_usd, plus a matching P8 entry.",
   "changes": "For each selected payout let A be its original amount_usd and T=floor(A), expressed with two decimal places. Set processor_payouts.amount_usd=T. In its matching P8 entry set the 1000 row's debit=T and the 1150 row's credit=T, retaining their zero opposite-side amounts and every other column. Do not change payout item_count, dates, settlement items, fees or bank_statement_lines. The bank retains A because only the report and its dependent accounting import were truncated; do not recompute actual cash movements.",
   "first_month": "2026-04",
   "books_effect": "Let E be the sum of A-T across selected payouts. Cash 1000 is understated by E and Processor clearing 1150 is overstated by E. Correct balances post each actual bank receipt A under P8 and use the original payout amount that reconciles to the settlement items.",
   "month_end_close_would_catch": true,
   "month_end_close_reason": "Each affected payout and P8 entry differs from its bank receipt by the discarded cents, and its payout amount no longer agrees with the settlement detail."
  }
 ]
}
