Skip to content
This repository has been archived by the owner on Feb 10, 2025. It is now read-only.

Improve abn amro sync #534

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions src/app-gocardless/banks/abnamro_abnanl2a.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,17 @@ export default {

normalizeTransaction(transaction, _booked) {
// There is no remittanceInformationUnstructured, so we'll make it
let remittanceInformationUnstructured =
transaction.remittanceInformationUnstructuredArray.join(' ');
transaction.remittanceInformationUnstructured =
transaction.remittanceInformationUnstructuredArray.join(', ');

// Remove clutter to extract the payee from remittanceInformationUnstructured ...
// ... when not otherwise provided.
const matches =
remittanceInformationUnstructured.match(/Betaalpas(.+),PAS/);
const payeeName = matches
? matches[1].replace(/.+\*/, '').trim()
: undefined;
const payeeName = transaction.remittanceInformationUnstructuredArray
.map((el) => el.match(/^(?:.*\*)?(.+),PAS\d+$/))
.find((match) => match)?.[1];
transaction.debtorName = transaction.debtorName || payeeName;
transaction.creditorName = transaction.creditorName || payeeName;

// There are anumber of superfluous keywords in the remittanceInformation.
// Remove them to aboid clutter in notes.
const keywordsToRemove = ['.EA, Betaalpas', ',PAS\\d{3}', 'NR:.+, '];
const regex = new RegExp(keywordsToRemove.join('|'), 'g');
transaction.remittanceInformationUnstructured =
remittanceInformationUnstructured.replace(regex, '').trim();

return {
...transaction,
payeeName: formatPayeeName(transaction),
Expand Down
30 changes: 29 additions & 1 deletion src/app-gocardless/banks/tests/abnamro_abnanl2a.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,37 @@ describe('AbnamroAbnanl2a', () => {
);

expect(normalizedTransaction.remittanceInformationUnstructured).toEqual(
'My Payee Name 09.12.23/15:43 CITY',
'BEA, Betaalpas, My Payee Name,PAS123, NR:123A4B, 09.12.23/15:43, CITY',
);
expect(normalizedTransaction.payeeName).toEqual('My Payee Name');
});

it('correctly extracts the payee for google pay', () => {
const transaction = {
transactionId: '0123456789012345',
bookingDate: '2023-12-11',
valueDateTime: '2023-12-09T15:43:37.950',
transactionAmount: {
amount: '-10.00',
currency: 'EUR',
},
remittanceInformationUnstructuredArray: [
'BEA, Google Pay',
'CCV*Other payee name,PAS123',
'NR:123A4B, 09.12.23/15:43',
'CITY',
],
};

const normalizedTransaction = AbnamroAbnanl2a.normalizeTransaction(
transaction,
false,
);

expect(normalizedTransaction.remittanceInformationUnstructured).toEqual(
'BEA, Google Pay, CCV*Other payee name,PAS123, NR:123A4B, 09.12.23/15:43, CITY',
);
expect(normalizedTransaction.payeeName).toEqual('Other Payee Name');
});
});
});
6 changes: 6 additions & 0 deletions upcoming-release-notes/534.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [UnderKoen]
---

Make Google Pay transactions work for ABNAMRO_ABNANL2A
Loading