fix(import): the IIF export refuses an entry on two A/R or A/P accounts

BS-format-2 item 7: QuickBooks Desktop records at most one A/R or A/P
account in a transaction (Intuit's own warning, sources/intuit-iif.md
and rules/format/BS-format-2.toml), so an entry with lines on two
receivable accounts, two payable accounts, or one of each cannot be
written as one IIF transaction. journal_to_iif used to write it and
merely list it in Iif::receivable_payable.

Now the export collects every entry whose lines touch more than one
distinct A/R/A/P account and returns
IifError::SeveralReceivablePayableAccounts, naming the entries and
saying why and what to do (reverse and post as two entries through a
clearing account; splitting one would change what it says). It never
splits an entry itself. ledger_package::export_iif and build_package
pass the refusal through, so books.export and books.export_cpa_package
return it before a file is handed over.

The README test's entry on both controls moved to its own refusal test;
the valid books it covers (one A/R entry, one A/P entry) are unchanged,
as are every IIF golden and every test of the file's bytes.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
This commit is contained in:
swaitsandDeepSeek V4.1 Flash committed 2026-11-08 14:32:23 -07:00
1 parent 4b295ee224
commit 45ea103283
5 files changed
+280 -26

No files matched your search

+15 -6
View File
@@ -260,12 +260,21 @@ by the as-of day, otherwise by wanderbooks type `OCASSET` (asset), `OCLIAB`
`COGS`, `EXINC` and `EXEXP` are in `ledger_import::QbAccountType` but nothing
in the books maps to them yet.
**Gap:** an entry with lines on more than one A/R or A/P account (the
receivables and payables roles are two accounts, so one entry can hold both)
must be refused by the spec (Intuit: QuickBooks will not record it), but
`journal_to_iif` writes it and only lists it in `Iif::receivable_payable`
(a flag for any entry with such a line). Unenforced until the engine refuses
it.
**Enforced:** `ledger_import::iif::journal_to_iif` refuses an entry with
lines on more than one A/R or A/P account
(`IifError::SeveralReceivablePayableAccounts`), naming every such entry and
saying QuickBooks Desktop records at most one A/R or A/P account a
transaction and that splitting the entry would change what it says;
`ledger_package::export_iif` and `build_package` and `ledger-mcp`
`books.export` and `books.export_cpa_package` return that refusal instead of
a file. **Checked:** `ledger-import` `tests/spec_import.rs`
(`iif_writes_an_entry_on_one_receivable_or_payable_account`,
`iif_refuses_an_entry_on_two_receivable_or_payable_accounts`,
`iif_refuses_an_entry_on_two_receivable_accounts`); `ledger-package`
`tests/package.rs`
(`the_package_refuses_an_entry_on_two_receivable_or_payable_accounts`);
`ledger-cli` `oracle_mcp.rs`
(`iif_and_the_package_refuse_an_entry_on_two_receivable_or_payable_accounts`).
**Enforced:** `ledger_import::iif` (`field`, `iif_accounts`, `iif_classes`,
`journal_to_iif`, `Iif::warnings`, `Iif::changes`, `Iif::receivable_payable`),