Statement import: ABN AMRO's TXT/TAB download
It has no header row, so nothing came in. Recognize its eight columns, and take the other party's name out of ABN's coded text (/NAME/, card payments, Naam:). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0232766260
commit
33a8a237ea
4 files changed
+42
-3
No files matched your search
@@ -15,6 +15,7 @@ brokeless is a self-hosted copy of [broke](https://github.com/nextwork-projects/
|
||||
| Banks | Plaid and other cloud bank feeds | Statement import (CSV, OFX, QIF, PDF), or link ING and other European banks through Enable Banking (optional, goes through their cloud) |
|
||||
| Enable Banking feed | Never run against the real service | Checked against their API docs; fixes for duplicate transactions and pasted keys; tested end to end against a stand-in |
|
||||
| ING Netherlands CSV | Spending and income all came in as income | Reads the "Af Bij" column |
|
||||
| ABN AMRO TXT/TAB | Imported nothing (no header row) and kept coded descriptions | Recognized, with the name pulled out of `/NAME/`, card and `Naam:` text |
|
||||
| Updates | Pulls from GitHub on every start | Never by itself. You review upstream commits and merge the ones you want. |
|
||||
| Calls out | Update check on GitHub, exchange rates from frankfurter.dev | Both off (`BROKE_OFFLINE=1`) |
|
||||
| Next.js and React | 15.5.4 and 19.1.0 (critical advisory) | 15.5.29 and 19.1.10 |
|
||||
@@ -63,7 +64,7 @@ Needs Docker with Compose. The steps below use Unraid's IP as the example, but a
|
||||
|
||||
5. Lock it to you: set `DISABLE_SIGNUP=true` in `docker/.env`, then run the `up -d` command again.
|
||||
|
||||
6. Add your bank: Accounts, Add accounts, Import a statement. For ING, download your transactions from Mijn ING as CSV (comma or semicolon both work). Importing the same file again adds nothing. To have transactions come in by themselves instead, see [Link your bank](#link-your-bank-ing-and-other-european-banks).
|
||||
6. Add your bank: Accounts, Add accounts, Import a statement. For ING, download your transactions from Mijn ING as CSV (comma or semicolon both work). For ABN AMRO, download them as TXT (a `.TAB` file). Importing the same file again adds nothing. To have transactions come in by themselves instead, see [Link your bank](#link-your-bank-ing-and-other-european-banks).
|
||||
|
||||
More detail, including what each container does: [docker/README.md](docker/README.md).
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ export function ImportStatement({ accounts, locale, currency, link = false, trig
|
||||
|
||||
<label className="block space-y-1.5">
|
||||
<span className="text-sm font-medium">Statement file</span>
|
||||
<input data-autofocus type="file" accept=".csv,.txt,.ofx,.qfx,.qif,.pdf,text/csv,application/pdf" onChange={(e) => choose(e.target.files?.[0])} className="select file:mr-3 file:rounded-full file:border-0 file:bg-canvas file:px-3 file:py-1 file:text-sm" />
|
||||
<input data-autofocus type="file" accept=".csv,.txt,.tab,.ofx,.qfx,.qif,.pdf,text/csv,application/pdf" onChange={(e) => choose(e.target.files?.[0])} className="select file:mr-3 file:rounded-full file:border-0 file:bg-canvas file:px-3 file:py-1 file:text-sm" />
|
||||
</label>
|
||||
{pdfFile && (
|
||||
<form onSubmit={(e) => { e.preventDefault(); readPdf(pdfFile, pdfPass); }} className="space-y-2">
|
||||
|
||||
@@ -156,3 +156,19 @@ console.log("statement ok");
|
||||
`, "nl-NL");
|
||||
assert.deepEqual(brief(c.rows), [["2026-11-14", 42.17, "Albert Heijn 1234"], ["2026-11-13", -2500, "Werkgever BV"], ["2026-11-12", 13.99, "Netflix"]]);
|
||||
}
|
||||
|
||||
// ABN AMRO TXT/TAB download: no header, tab separated, signed amounts, coded descriptions.
|
||||
{
|
||||
const c = csv([
|
||||
"123456789\tEUR\t20261114\t2000,00\t1957,83\t20261114\t-42,17\tBEA, Apple Pay ALBERT HEIJN 1234,PAS123 NR:ABC123, 14.11.26/18:02 AMSTERDAM",
|
||||
"123456789\tEUR\t20261113\t-500,00\t2000,00\t20261113\t2500,00\t/TRTP/SEPA OVERBOEKING/IBAN/NL00RABO0123456789/BIC/RABONL2U/NAME/Werkgever BV/REMI/Salaris november/EREF/NOTPROVIDED",
|
||||
"123456789\tEUR\t20261112\t-486,01\t-500,00\t20261112\t-13,99\tSEPA Incasso algemeen doorlopend Incassant: NL00ZZZ000000000000 Naam: Netflix International B.V. Machtiging: 123 Omschrijving: Netflix",
|
||||
"123456789\tEUR\t20261111\t-436,01\t-486,01\t20261111\t-50,00\tGEA NR:XX123 11.11.26/10.15 ABN AMRO BANK NV,PAS123",
|
||||
].join("\n") + "\n", "nl-NL");
|
||||
assert.deepEqual(brief(c.rows), [
|
||||
["2026-11-14", 42.17, "ALBERT HEIJN 1234"],
|
||||
["2026-11-13", -2500, "Werkgever BV"],
|
||||
["2026-11-12", 13.99, "Netflix International B.V."],
|
||||
["2026-11-11", 50, "ABN AMRO BANK NV"],
|
||||
]);
|
||||
}
|
||||
+23
-1
@@ -133,9 +133,15 @@ const find = (header: string[], tests: RegExp[], skip: RegExp = /$^/) => {
|
||||
return -1;
|
||||
};
|
||||
|
||||
// ABN AMRO's TXT/TAB download has no header: account, currency, date, opening balance, closing balance, value date,
|
||||
// signed amount, description. Two of the other columns are amounts too, so it can't be guessed from the values.
|
||||
const isAbnAmro = (t: Table, col: (i: number) => string[]) =>
|
||||
t.header.length === 8 && t.header[0] === "Column 1" && col(1).every((v) => /^[A-Z]{3}$/.test(v)) && col(2).every((v) => /^\d{8}$/.test(v));
|
||||
|
||||
export function guessMapping(t: Table, locale: string): Mapping {
|
||||
const h = t.header.map((x) => x.toLowerCase().trim());
|
||||
const col = (i: number) => t.rows.slice(0, 50).map((r) => r[i] ?? "");
|
||||
if (isAbnAmro(t, col)) return { date: 2, name: 7, amount: 6, debit: -1, credit: -1, order: "ymd", outPositive: false, category: -1 };
|
||||
let date = find(h, [/^(transaction |txn |posted |posting )?date$/, /date/], /value|process|created/);
|
||||
if (date < 0) date = h.findIndex((_, i) => col(i).filter(looksDate).length > col(i).length / 2);
|
||||
let name = find(h, [/payee/, /counter ?party/, /^name$/, /^details$/, /narration/, /description/, /merchant/, /memo/, /particulars/, /reference/]);
|
||||
@@ -159,6 +165,22 @@ export function withKeys(rows: Omit<Row, "key">[], ids?: (string | undefined)[])
|
||||
});
|
||||
}
|
||||
|
||||
// Dutch banks (ABN AMRO above all) pack the other party's name into coded text. Pull the name out; any other text
|
||||
// stays as the bank wrote it.
|
||||
export function cleanName(raw: string) {
|
||||
const s = raw.replace(/\s+/g, " ").trim();
|
||||
// SEPA transfer or direct debit: /TRTP/SEPA OVERBOEKING/IBAN/.../NAME/Werkgever BV/REMI/...
|
||||
const sepa = s.match(/\/NAME\/([^/]+)/);
|
||||
if (sepa) return sepa[1].trim();
|
||||
// Card payment or cash: "BEA, Apple Pay ALBERT HEIJN 1234,PAS123 NR:..." or "BEA NR:XX 14.11.26/18.02 ALBERT HEIJN,PAS123"
|
||||
const card = s.match(/^(?:BEA|GEA|eCom)\b[,:]?\s*(?:(?:Apple|Google) Pay|Betaalpas)?\s*(.+?),\s*PAS\d+/i);
|
||||
if (card) return card[1].replace(/^NR:\S+\s+\d{2}\.\d{2}\.\d{2}\/\d{2}[.:]\d{2}\s+/, "").trim();
|
||||
// Older SEPA text: "SEPA Incasso ... Naam: Netflix International B.V. Machtiging: ..."
|
||||
const naam = s.match(/\bNaam:\s*(.+?)(?=\s+(?:Machtiging|Omschrijving|IBAN|Kenmerk|BIC|Incassant|Betalingskenm\.?)[:\s]|$)/i);
|
||||
if (naam) return naam[1].trim();
|
||||
return s;
|
||||
}
|
||||
|
||||
export function applyMapping(t: Table, m: Mapping, locale: string): { rows: Row[]; skipped: number } {
|
||||
const out: Omit<Row, "key">[] = [];
|
||||
let skipped = 0;
|
||||
@@ -178,7 +200,7 @@ export function applyMapping(t: Table, m: Mapping, locale: string): { rows: Row[
|
||||
const cr = m.credit >= 0 ? parseAmount(r[m.credit] ?? "", locale) : null;
|
||||
if (dr !== null || cr !== null) amount = Math.abs(dr ?? 0) - Math.abs(cr ?? 0);
|
||||
}
|
||||
const name = (m.name >= 0 ? r[m.name] ?? "" : "").replace(/\s+/g, " ").trim();
|
||||
const name = cleanName(m.name >= 0 ? r[m.name] ?? "" : "");
|
||||
if (!date || amount === null || !amount) skipped++;
|
||||
else {
|
||||
const category = (m.category ?? -1) >= 0 ? (r[m.category!] ?? "").trim() : "";
|
||||
|
||||
Reference in new issue
Block a user