A bank writes "Hofer Dankt" where the ledger says "Hofer", and nothing
could change it: [importers.mappings] only picks the contra account.
importers.toml now takes a shared top-level [payees] table and a
per-entry [importers.payees] (tried first). A key is a case-insensitive
substring, or a case-insensitive regex between slashes; the first match
in file order wins. The raw payee is matched, or the narration when the
row has none. The rewrite runs on every importer's output (CSV, OFX,
WASM, and the component's importer.extract for an entry's own table),
after account mappings matched the raw text and before ordering and
--existing dedup. Only the payee changes. A bad pattern is a config
error naming its table, reported by --list-importers too.
Closes #2550
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
What
Implements the option-A decision on #2550:
rledger extractrewrites a bank's payee text to the name the ledger uses.[payees]table inimporters.toml, plus an optional per-entry[importers.payees], tried first.[importers.mappings], or a case-insensitive regex written between slashes ("/^AMZN Mktp/"). The first match in file order wins. File order is kept with the same key-span technique the equal-length mappings fix (importers.mappings: equal-length overlapping keys produce nondeterministic accounts #2423) used. That code is now shared byMappingsand the newPayeeTable. Matching goes throughrustledger_ops::categorize::RulesEngine, the engine mappings already use, so the two can't drift apart.rustledger_importer::payees::PayeeRules::applyruns on the importer's output inrun_with_ledgers, right afterimporter.extractand beforeorder::chronologicaland--existingdedup. So it covers CSV, OFX and WASM, and dedup compares canonical names. The WASI component'simporter.extractapplies the entry's own table too.importer 'bank': [importers.payees]: "/(/" is not a valid regular expression: ...orthe top-level [payees] table: ....load_importers_configvalidates the tables, so--list-importers(andag-rledger) report it too.build_config_from_entryvalidates the entry's table for the component.Decision made where the issue left it open: the shared table applies whenever an
importers.tomlis found,--autoand raw column flags included, the same waywasm_importer_dirdoes. On a run that would not otherwise read the config (--auto), a file that fails to load is skipped with a warning, not an error. That keepstest_auto_is_not_failed_by_an_unparsable_config_it_never_readstrue.Docs: a new "Payee Rewriting" section in
docs/commands/extract.md, plus a note in Duplicate Detection. CHANGELOG has an entry under Importing & Ingestion.Tests
"HOFER DANKT"still matches the raw text.[[importers]]entry.plugin_conformance::wasm_importer_output_gets_payee_rewrites, through the real binary.extract_applies_the_entry_payee_table(CSV + OFX, plus the bad-regex error).--existingdedup matches a ledger that uses the canonical name (AMZN Mktp DE*4Z81T→Amazon).--list-importers.ag-rledger extractapplies both tables, andag-rledger extract --list-importersaccepts them and rejects a bad pattern.--autoapplies a[payees]table from animporters.tomlit discovered.PayeeRules.Every new test was shown to fail with the fix reverted: the
applycalls removed in the CLI and the component,validate_payeesremoved, the key-order sort removed, and the blank-payee filter removed. The one exception ispayees_tables_are_accepted_by_list_importers, an acceptance check:ImportersFilehas nodeny_unknown_fields, so it passes either way.Local:
cargo test -p rustledger-importer(265),-p rustledger-ffi-component(40) and-p rustledger --all-features(1001, includingag_rledger_testandplugin_conformancewith the WASM guests built), all passing. Also rancargo clippy --workspace --all-features --all-targets -D warnings,cargo doc -D warningsfor the three crates, and the release-config clippy. The only warning there is the existing unusedwasm_plugins_dirincli_commands_test.rs, which is also on main.Closes #2550
🤖 Generated with Claude Code
https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr