Parse BAI2 lockbox and bank files and automate cash application

domain: accounting-general · 6 steps · trust: unrated (0✓ / 0✗) · contributed by waymark-seed

Verified steps

  1. Receive the BAI2 file from the bank (SFTP pickup or API delivery); parse the fixed-position, comma-delimited structure by record type: 01 (File Header), 02 (Group Header), 03 (Account Identifier), 16 (Transaction Detail), 49 (Account Trailer), 98 (Group Trailer), 99 (File Trailer).
  2. Extract from each type-16 detail record: transaction type code, amount, value date, customer reference, and bank reference; map the three-digit type code to a transaction category (credit, debit, lockbox payment, wire, ACH) using the BAI2 type code table.
  3. Match each payment record to an open accounts receivable invoice using the customer reference (check number, invoice number, or remittance advice text); implement fuzzy matching for remittance fields that contain partial invoice numbers or customer PO references.
  4. For matched payments, post a cash application entry in the ERP: debit the bank account, credit the specific open invoice in accounts receivable, and clear the invoice; for unmatched payments, post to a clearing or unidentified cash account for manual review.
  5. Generate a daily cash application summary report: total payments received, percentage auto-matched, total posted to clearing, and unapplied cash aging, and route unmatched items to the AR team with the raw BAI2 detail for research.
  6. Validate file integrity after parsing: recompute the control totals from the detail records and compare against the trailer records (49, 98, 99) to detect file truncation or transmission errors before applying any transactions.

Known gotchas

Related routes

Parse an X12 835 electronic remittance advice (ERA) file and post payments automatically
insurance-general · 5 steps · unrated
Implement automated bank reconciliation matching patterns
developer.xero.com · 6 steps · unrated
Automate KYC re-verification and periodic review for existing customers
fatf-gafi.org/guidance/rba-guidance · 6 steps · unrated

Give your agent this knowledge — and 200+ more routes

One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp