Skip to content

feat(bank-payments): standard multi-format statement import - #514

Merged
Panelica merged 16 commits into
Panelica:mainfrom
hedon77:feat/bank-payments-csv-import
Nov 29, 2026
Merged

Panelica merged 16 commits into
Panelica:mainfrom
hedon77:feat/bank-payments-csv-import

Conversation

@hedon77

@hedon77 hedon77 commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

BankPayments now exposes one Bank / parser selector. The first option is Standard (auto), which detects and imports CSV, MT940 or ISO 20022 camt.053.001.08. Bank-specific parsers remain for banks with unusual formats.

Adding another bank is an adapter/parser extension; the import, duplicate detection, verification and matching pipeline stays shared.

Included

  • Single Bank / parser selector with Standard (auto).
  • CAMT.053 parser with local validation against the bundled official XSD.
  • Standard MT940 parser.
  • Standard CSV parser with delimiter/encoding detection and common Polish/English column aliases.
  • CSV/MT940/CAMT.053 through the same import form.
  • Source-aware verification labels: CSV, MT940, CAMT.053.
  • Verification-only mode and confirmed/unconfirmed filters.
  • Split-VAT cleanup preserved in raw_payload.
  • Remembered default bank/parser.
  • EN/PL/DE/TR/ZH translations.
  • Addon version 0.4.0.

How a new bank is added

  • Add a bank adapter/parser when its export differs from the standard.
  • Register it under the bank configuration.
  • Add a fixture and parser test.
  • No changes are needed in matching, verification or booking logic.

Safety

  • No changes to core invoice or payment logic.
  • Additive migrations only.
  • XML is validated locally; no network access or external entities.
  • Imported statements never modify invoices directly.
  • Booked transfers cannot be dismissed.

Verification

  • BankPayments standard auto import tests: 16 passed, 114 assertions.
  • CAMT.053 parser and XSD rejection tests.
  • CSV/MT940 parser tests.
  • Verification/filter tests.
  • Route guard and translation checks.

@hedon77 hedon77 changed the title feat(bank-payments): universal multi-bank import foundation feat(bank-payments): standard multi-format statement import Nov 29, 2026
@Panelica
Panelica merged commit d38b560 into Panelica:main Nov 29, 2026
1 check passed
Panelica pushed a commit that referenced this pull request Nov 29, 2026
#511 styled that toolbar from the core stylesheet and #514 rebuilt it around
the second filter with its own rules inside the addon's view. Both arrived
within a day of each other; the merge kept #514's, which leaves .matches-page-
action and .matches-filterbar in resources/css/app.css with nothing referencing
them - measured by grepping every view and template.

They are removed, and the addon's presentation stays with the addon, which is
where a module's styles belong.
@Panelica

Copy link
Copy Markdown
Owner

Merged as d38b5605, with the conflicts against #511 resolved in favour of your newer toolbar. This is a substantial piece of work and the pipeline design is the right one: one selector, format detected from the file itself, and the import, duplicate detection, matching and booking stages untouched.

What I checked, since a statement row becomes money:

  • A statement row does not become a second transaction. The dedup query on bank, date, amount, currency and reference finds the transfer already known from the e-mail and marks it confirmed instead of inserting a twin. That is what keeps one transfer from being booked twice, and it is the first thing I went looking for.
  • Verification does not gate booking. BankPaymentImporter never reads verified_at, so the backfill migrations are a label and a filter, not a payment decision. Good: migration …000004 infers verification from a matching CSV row on bank, date, amount, currency and reference, which for an empty reference can mark more than one e-mail row from a single statement entry. Harmless where it is, and worth remembering if verified_at ever starts gating anything.
  • The camt.053 XML is validated against the bundled schema before a value is read, and EndToEndId ends up inside the reference text, so two camt entries that differ only by that id stay distinct.
  • Rollbacks. …000001's down() deletes the rows with no bank_message_id before restoring the NOT NULL — those rows can only exist because of this feature, so it does restore the previous state; a comment saying that would help the next reader. …000002 rewrites reference on existing rows and says plainly that the original title is not recoverable; the split-VAT metadata is kept in raw_payload, and TransferTitle has a test.

One finding I did not fix, because it changes import semantics and is yours to decide. The dedup key is (bank, date, amount, currency, reference), so two genuinely different transfers that agree on all five are collapsed: the second is counted in duplicates and never imported. The realistic case is the one that matters most to an operator — a customer who pays the same invoice twice on the same day with the same title, which is exactly the overpayment someone has to refund. For camt.053 the EndToEndId in the reference saves you; for CSV and MT940 there is nothing to tell the two apart, although MT940 does carry the bank's own reference on :61:, which the parser currently drops.

The fix I would write is counting rather than matching: for each (date, amount, currency, reference) seen in the file, treat a row as a duplicate only when the number of existing transactions already covers the number of rows the statement lists. Say the word and I will send it with a fixture that has the same transfer twice.

One commit on top, a02b70a2: #511 styled this toolbar from resources/css/app.css and your branch rebuilt it with its own rules inside the addon's view. The merge kept yours, which left .matches-page-action and .matches-filterbar in the core stylesheet with nothing referencing them, so they are gone — the addon's presentation stays with the addon.

Migrations ran up and the four module migrations applied cleanly; addon tests 62 passed; full suite on the merge result 5,679 parallel and 112 serial, no failures.

@hedon77

hedon77 commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up: #516 implements the count-aware deduplication you proposed. It counts stored rows and their position in the statement, so two identical genuine payments are imported while a repeated import stays idempotent. Fixture and tests cover two identical rows, reimport, and one-existing-plus-two-in-file. The migration down() comment is added too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants