bank-statement-to-excel 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/statement.js +12 -4
  2. package/package.json +1 -1
package/lib/statement.js CHANGED
@@ -251,7 +251,7 @@ const CLOSING = new RegExp([
251
251
  'eindsaldo', 'nieuw\\s+(openstaand\\s+)?saldo', 'endsaldo', 'neuer\\s+(konto)?stand', 'utgaende\\s+saldo',
252
252
  ].join('|'), 'i');
253
253
  // "Balance as of 01.05.2025: 15.320,00 €": the earliest of these is the opening balance, the latest the closing one
254
- const BALANCE_ON = /^(balance|saldo|solde|kontostand|stand)\b.*\b(as\s+(of|at)|on|per|au|al|del|am|op|em|a\s+fecha|du)\b/i;
254
+ const BALANCE_ON = /^(balance|saldo|solde|kontostand|stand)\b(.*\b(as\s+(of|at)|on|per|au|al|del|am|op|em|a\s+fecha|du)\b|\s+\d{1,2}[/.-]\d{1,2}[/.-]\d{2,4}\b)/i;
255
255
  const OUT_SECTION = /withdrawal|subtraction|deduction|debit|\bchecks?\b|\bfees\b|charges|\bpayments\b|purchases/;
256
256
  const IN_SECTION = /deposit|addition|credit/;
257
257
  const SUMMARY = /^(total|totales|totaal|totale|suma|summe|summa|subtotal|saldo|solde|balance|carried|brought|importe\s+total)\b/i;
@@ -265,8 +265,8 @@ const HEADERS = [
265
265
  ['valueDate', /f\.?\s*valor|fecha\s+valor|value\s+date|^valor$|^valuta|valutadatum|wertstellung|^wert$|rentedatum|interest\s+date|date\s+de\s+valeur|data\s+(valuta|valor)|post(ing|ed)?\s+date|^posted$|fecha\s+contable/],
266
266
  ['date', /fecha|^f\.?\s*oper|^dates?\b|trans(action|\.)?\s+date|^fec\.?$|^datum|buchungs(tag|datum)|^data\b|date\s+(de\s+l['’]?)?op|bokforingsda|transaktionsda|^日期/],
267
267
  ['balance', /saldo|balance|solde|kontostand|^stand$|結餘|余额/],
268
- ['debit', /cargo|subtract(ed|ions?)|deducted|^debe$|debito|debit|paid\s+out|withdrawal|money\s+out|reintegro|retiro|salida|^out$|^af$|afschrijving|^soll$|belastung|uscite|addebit|^dare$|retrait|^提取|支出|uttag/],
269
- ['credit', /abono|amounts?\s+added|additions?|^haber$|credito|credit|paid\s+in|deposit|money\s+in|ingreso|entrada|^in$|^bij$|bijschrijving|^haben$|gutschrift|entrate|accredit|^avere$|depot|versement|^存入|收入|insattning/],
268
+ ['debit', /cargo|subtract(ed|ions?)|deducted|^debe$|debito|debit|paid\s+out|withdrawal|money\s+out|reintegro|retiro|salida|^out$|^(bedrag\s+)?af\b|debet|afschrijving|^soll$|belastung|uscite|addebit|^dare$|retrait|^提取|支出|uttag/],
269
+ ['credit', /abono|amounts?\s+added|additions?|^haber$|credito|credit|paid\s+in|deposit|money\s+in|ingreso|entrada|^in$|^(bedrag\s+)?bij\b|bijschrijving|^haben$|gutschrift|entrate|accredit|^avere$|depot|versement|^存入|收入|insattning/],
270
270
  ['amount', /importe|amount|cantidad|^eur$|^euros?$|bedrag|betrag|montant|importo|montante|belopp/],
271
271
  ['description', /concepto|descripci|detalle|movimiento|description|details|transaction|particulars|narrative|referencia|omschrijving|verwendungszweck|buchungstext|libelle|operation|descrizione|causale|descricao|historico|merchant|counterparty|tegenpartij|naam|payee|beneficiar|^text$|beskrivning|mottagare|meddelande/],
272
272
  ];
@@ -479,6 +479,12 @@ export function detectTable(lines, opts = {}) {
479
479
  }
480
480
  return -1;
481
481
  };
482
+ // A date and a balance under "Datum vanaf | Beginsaldo" (Rabobank account summary) are not movements
483
+ classified.forEach((l, i) => {
484
+ if (!l.tx || l.cells.some(c => c.kind === 'text')) return;
485
+ const h = headerAbove(i), roles = h >= 0 ? classified[h].cells.map(c => headerRole(c.text)).filter(Boolean) : [];
486
+ if (roles.includes('balance') && roles.every(r => ['date', 'valueDate', 'balance'].includes(r))) l.tx = false;
487
+ });
482
488
  // Money in and money out side by side ("Date Description Amount | Date Description Amount") is the main table itself
483
489
  const any = classified.findIndex(l => l.tx), top = headerAbove(any);
484
490
  const plain = classified.findIndex(l => l.tx && !grid(l));
@@ -654,7 +660,9 @@ export function detectTable(lines, opts = {}) {
654
660
  if (labelled === 'closing') { closing = v; balanceText.closing = own[own.length - 1].text; }
655
661
  if (labelled === 'on') {
656
662
  const d = [...line.text.matchAll(FULL_DATE)].map(m => fullDate(m[0])).find(Boolean);
657
- if (d) balancesOn.push({ date: excelSerial(d), value: v });
663
+ // "Saldo 01-01-2020 € 5.431,36 € 10.626,00 € 12.000,00" (ABN AMRO): the figure right after a dated label is its own
664
+ const first = /\d{2,4}$/.test(line.cells[at]?.text || '') && line.cells[at + 1]?.kind === 'number' ? parseAmount(line.cells[at + 1].text, numberStyle) : v;
665
+ if (d) balancesOn.push({ date: excelSerial(d), value: first });
658
666
  }
659
667
  }
660
668
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bank-statement-to-excel",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Convert PDF bank statements to Excel, CSV or JSON on your own computer. CLI and MCP server for AI agents. Same converter as extractoaexcel.com.",
5
5
  "type": "module",
6
6
  "bin": { "bank-statement-to-excel": "cli.mjs" },