From 635ef27696a5fa6a31278d170485a6b2afa3dcce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C4=81vis?= Date: Fri, 8 Nov 2024 23:05:51 +0100 Subject: [PATCH 1/4] Enrich pending transaction creditor info for SWEDBANK_HABALV22 (#497) --- src/app-gocardless/banks/swedbank-habalv22.js | 37 ++++++++++++++----- .../banks/tests/swedbank-habalv22.spec.js | 27 ++++++++++++-- upcoming-release-notes/497.md | 6 +++ 3 files changed, 57 insertions(+), 13 deletions(-) create mode 100644 upcoming-release-notes/497.md diff --git a/src/app-gocardless/banks/swedbank-habalv22.js b/src/app-gocardless/banks/swedbank-habalv22.js index 5602b3ca2..87c745cd1 100644 --- a/src/app-gocardless/banks/swedbank-habalv22.js +++ b/src/app-gocardless/banks/swedbank-habalv22.js @@ -14,17 +14,36 @@ export default { * The actual transaction date for card transactions is only available in the remittanceInformationUnstructured field when the transaction is booked. */ normalizeTransaction(transaction, booked) { - const dateMatch = transaction.remittanceInformationUnstructured?.match( - /PIRKUMS [\d*]+ (\d{2}.\d{2}.\d{4})/, - ); + const isCardTransaction = + transaction.remittanceInformationUnstructured?.startsWith('PIRKUMS'); + + if (isCardTransaction) { + if (!booked && !transaction.creditorName) { + const creditorNameMatch = + transaction.remittanceInformationUnstructured?.match( + /PIRKUMS [\d*]+ \d{2}\.\d{2}\.\d{2} \d{2}:\d{2} [\d.]+ \w{3} \(\d+\) (.+)/, + ); + + if (creditorNameMatch) { + transaction = { + ...transaction, + creditorName: creditorNameMatch[1], + }; + } + } + + const dateMatch = transaction.remittanceInformationUnstructured?.match( + /PIRKUMS [\d*]+ (\d{2}\.\d{2}\.\d{4})/, + ); - if (dateMatch) { - const extractedDate = d.parse(dateMatch[1], 'dd.MM.yyyy', new Date()); + if (dateMatch) { + const extractedDate = d.parse(dateMatch[1], 'dd.MM.yyyy', new Date()); - return Fallback.normalizeTransaction( - { ...transaction, bookingDate: d.format(extractedDate, 'yyyy-MM-dd') }, - booked, - ); + transaction = { + ...transaction, + bookingDate: d.format(extractedDate, 'yyyy-MM-dd'), + }; + } } return Fallback.normalizeTransaction(transaction, booked); diff --git a/src/app-gocardless/banks/tests/swedbank-habalv22.spec.js b/src/app-gocardless/banks/tests/swedbank-habalv22.spec.js index 02a163238..91e2e0121 100644 --- a/src/app-gocardless/banks/tests/swedbank-habalv22.spec.js +++ b/src/app-gocardless/banks/tests/swedbank-habalv22.spec.js @@ -1,7 +1,7 @@ import SwedbankHabaLV22 from '../swedbank-habalv22.js'; describe('#normalizeTransaction', () => { - const cardTransaction = { + const bookedCardTransaction = { transactionId: '2024102900000000-1', bookingDate: '2024-10-29', valueDate: '2024-10-29', @@ -18,11 +18,12 @@ describe('#normalizeTransaction', () => { it('extracts card transaction date', () => { expect( - SwedbankHabaLV22.normalizeTransaction(cardTransaction, true).bookingDate, + SwedbankHabaLV22.normalizeTransaction(bookedCardTransaction, true) + .bookingDate, ).toEqual('2024-10-28'); expect( - SwedbankHabaLV22.normalizeTransaction(cardTransaction, true).date, + SwedbankHabaLV22.normalizeTransaction(bookedCardTransaction, true).date, ).toEqual('2024-10-28'); }); @@ -32,7 +33,7 @@ describe('#normalizeTransaction', () => { ['null value', null], ])('normalizes non-card transaction with %s', (_, remittanceInfo) => { const transaction = { - ...cardTransaction, + ...bookedCardTransaction, remittanceInformationUnstructured: remittanceInfo, }; const normalized = SwedbankHabaLV22.normalizeTransaction(transaction, true); @@ -40,4 +41,22 @@ describe('#normalizeTransaction', () => { expect(normalized.bookingDate).toEqual('2024-10-29'); expect(normalized.date).toEqual('2024-10-29'); }); + + const pendingCardTransaction = { + transactionId: '2024102900000000-1', + valueDate: '2024-10-29', + transactionAmount: { + amount: '-22.99', + currency: 'EUR', + }, + remittanceInformationUnstructured: + 'PIRKUMS 424242******4242 28.10.24 13:37 22.99 EUR (111111) SOME CREDITOR NAME', + }; + + it('extracts pending card transaction creditor name', () => { + expect( + SwedbankHabaLV22.normalizeTransaction(pendingCardTransaction, false) + .creditorName, + ).toEqual('SOME CREDITOR NAME'); + }); }); diff --git a/upcoming-release-notes/497.md b/upcoming-release-notes/497.md new file mode 100644 index 000000000..0836318c8 --- /dev/null +++ b/upcoming-release-notes/497.md @@ -0,0 +1,6 @@ +--- +category: Enhancements +authors: [dmednis] +--- + +Improve support for "SWEDBANK_HABALV22" transaction date & enrich creditor name for pending transactions \ No newline at end of file From d412590b338ae118e35699745027759c38074164 Mon Sep 17 00:00:00 2001 From: Matt Fiddaman Date: Sat, 9 Nov 2024 09:26:26 +0000 Subject: [PATCH 2/4] `ING_PL_INGBPLPW` should prefer valueDate over bookingDate (#493) --- src/app-gocardless/banks/ing-pl-ingbplpw.js | 2 +- upcoming-release-notes/493.md | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 upcoming-release-notes/493.md diff --git a/src/app-gocardless/banks/ing-pl-ingbplpw.js b/src/app-gocardless/banks/ing-pl-ingbplpw.js index 13928fbe2..05b7b9dde 100644 --- a/src/app-gocardless/banks/ing-pl-ingbplpw.js +++ b/src/app-gocardless/banks/ing-pl-ingbplpw.js @@ -27,7 +27,7 @@ export default { return { ...transaction, payeeName: formatPayeeName(transaction), - date: transaction.bookingDate || transaction.valueDate, + date: transaction.valueDate ?? transaction.bookingDate, }; }, diff --git a/upcoming-release-notes/493.md b/upcoming-release-notes/493.md new file mode 100644 index 000000000..b8767a9a7 --- /dev/null +++ b/upcoming-release-notes/493.md @@ -0,0 +1,6 @@ +--- +category: Enhancements +authors: [matt-fidd] +--- + +GoCardless: `ING_PL_INGBPLPW` should prefer valueDate over bookingDate From 266de169db859e5d77fbfa9c5209d43cfdf32c16 Mon Sep 17 00:00:00 2001 From: Matt Fiddaman Date: Sat, 9 Nov 2024 09:26:40 +0000 Subject: [PATCH 3/4] use SimpleFin pending flag for cleared status (#494) --- src/app-simplefin/app-simplefin.js | 2 +- upcoming-release-notes/494.md | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 upcoming-release-notes/494.md diff --git a/src/app-simplefin/app-simplefin.js b/src/app-simplefin/app-simplefin.js index 27760987a..436ebd552 100644 --- a/src/app-simplefin/app-simplefin.js +++ b/src/app-simplefin/app-simplefin.js @@ -202,7 +202,7 @@ function getAccountResponse(results, accountId, startDate) { let dateToUse = 0; - if (trans.posted == 0) { + if (trans.pending ?? trans.posted == 0) { newTrans.booked = false; dateToUse = trans.transacted_at; } else { diff --git a/upcoming-release-notes/494.md b/upcoming-release-notes/494.md new file mode 100644 index 000000000..9efdee05c --- /dev/null +++ b/upcoming-release-notes/494.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [matt-fidd] +--- + +Prefer using the SimpleFin pending flag to set cleared status From b1bf7ee7cdd1f2e2fb77f5a883fbc065fe6c7337 Mon Sep 17 00:00:00 2001 From: Matt Fiddaman Date: Sat, 9 Nov 2024 09:26:49 +0000 Subject: [PATCH 4/4] add support for `1822-DIREKT-HELADEF1822` transaction information (#484) --- .../banks/1822-direkt-heladef1822.js | 16 ++++++++++++++++ upcoming-release-notes/484.md | 6 ++++++ 2 files changed, 22 insertions(+) create mode 100644 src/app-gocardless/banks/1822-direkt-heladef1822.js create mode 100644 upcoming-release-notes/484.md diff --git a/src/app-gocardless/banks/1822-direkt-heladef1822.js b/src/app-gocardless/banks/1822-direkt-heladef1822.js new file mode 100644 index 000000000..74a239354 --- /dev/null +++ b/src/app-gocardless/banks/1822-direkt-heladef1822.js @@ -0,0 +1,16 @@ +import Fallback from './integration-bank.js'; + +/** @type {import('./bank.interface.js').IBank} */ +export default { + ...Fallback, + + institutionIds: ['DIREKT_HELADEF1822'], + + normalizeTransaction(transaction, booked) { + transaction.remittanceInformationUnstructured = + transaction.remittanceInformationUnstructured ?? + transaction.remittanceInformationStructured; + + return Fallback.normalizeTransaction(transaction, booked); + }, +}; diff --git a/upcoming-release-notes/484.md b/upcoming-release-notes/484.md new file mode 100644 index 000000000..2d7c9e07c --- /dev/null +++ b/upcoming-release-notes/484.md @@ -0,0 +1,6 @@ +--- +category: Enhancements +authors: [matt-fidd] +--- + +Add support for `1822-DIREKT-HELADEF1822` transaction information