Skip to content

Enable Banking: keep same-day identical rows when the bank sends no ids - #9

Open
richardmuthwill wants to merge 1 commit into
nextwork-projects:mainfrom
richardmuthwill:fix/enablebanking-duplicate-ids
Open

richardmuthwill wants to merge 1 commit into
nextwork-projects:mainfrom
richardmuthwill:fix/enablebanking-duplicate-ids

Conversation

@richardmuthwill

Copy link
Copy Markdown

Problem

Swedbank (through Enable Banking) sends transactions with no transaction_id or entry_reference. ebTxn then builds the id from day, amount and text. Two identical rows on one day, like two equal transfers to the same account, get the same plaid_transaction_id.

The insert in saveFeed then fails on transactions_plaid_transaction_id_key. The whole sync saves nothing: balances come in, but no transactions, on every sync.

Fix

ebFeed now passes its rows through ebUniqueIds. Repeats get |2, |3 and so on, the same way the statement import numbers repeats in withKeys.

  • The first row keeps its id, so rows already saved don't change.
  • Same-looking rows are interchangeable, so the numbers stay stable from sync to sync.
  • date_from is a whole day, so a sync never sees only part of a day's repeats.

Checks

  • node src/lib/providers/feeds.test.ts: added a case with two identical rows and one different row.
  • npx tsc --noEmit and eslint on the changed files.
  • Tested against a real Swedbank (Sweden) link in production restricted mode: before, every sync failed with the duplicate key error. After, all six accounts synced, about 3,300 transactions over two years.

🤖 Generated with Claude Code

Swedbank (through Enable Banking) sends transactions with no transaction_id
or entry_reference, so broke builds the id from day, amount and text. Two
identical rows on one day, like two equal transfers, got the same id. The
insert then failed on transactions_plaid_transaction_id_key and the whole
sync saved nothing.

Repeats now get |2, |3 and so on, as the statement import already does.
The first row keeps its id, and same-looking rows are interchangeable, so
the ids stay stable from sync to sync.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant