mirror of
https://github.com/actualbudget/actual.git
synced 2026-05-10 05:50:49 -05:00
Improve abn amro sync (#534)
* chore: payee name for google pay * chore: revert notes to include all data * chore: release note * chore: fix tests
This commit is contained in:
committed by
GitHub
parent
1808f51e85
commit
215e00ac14
@@ -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),
|
||||
|
||||
@@ -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
upcoming-release-notes/534.md
Normal file
6
upcoming-release-notes/534.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Enhancements
|
||||
authors: [UnderKoen]
|
||||
---
|
||||
|
||||
Make Google Pay transactions work for ABNAMRO_ABNANL2A
|
||||
Reference in New Issue
Block a user