-
-
Notifications
You must be signed in to change notification settings - Fork 650
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Bizum transactions in Revolut (#459)
* fix: rename proprietaryBank to proprietaryBankTransactionCode * feat: Add support for RevolutRevolt21 Bizum transactions * test: Add RevolutRevolt21 bizum transactions tests * chore: Add upcoming release note * fix: Add missing bookingDate to tests * fix: sort everything alphabetically
- Loading branch information
Showing
5 changed files
with
149 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { formatPayeeName } from '../../util/payee-name.js'; | ||
import * as d from 'date-fns'; | ||
import Fallback from './integration-bank.js'; | ||
|
||
/** @type {import('./bank.interface.js').IBank} */ | ||
export default { | ||
...Fallback, | ||
|
||
institutionIds: ['REVOLUT_REVOLT21'], | ||
|
||
accessValidForDays: 90, | ||
|
||
normalizeTransaction(transaction, _booked) { | ||
if ( | ||
transaction.remittanceInformationUnstructuredArray[0].startsWith( | ||
'Bizum payment from: ', | ||
) | ||
) { | ||
const date = | ||
transaction.bookingDate || | ||
transaction.bookingDateTime || | ||
transaction.valueDate || | ||
transaction.valueDateTime; | ||
|
||
return { | ||
...transaction, | ||
payeeName: | ||
transaction.remittanceInformationUnstructuredArray[0].replace( | ||
'Bizum payment from: ', | ||
'', | ||
), | ||
remittanceInformationUnstructured: | ||
transaction.remittanceInformationUnstructuredArray[1], | ||
date: d.format(d.parseISO(date), 'yyyy-MM-dd'), | ||
}; | ||
} | ||
|
||
if ( | ||
transaction.remittanceInformationUnstructuredArray[0].startsWith( | ||
'Bizum payment to: ', | ||
) | ||
) { | ||
const date = | ||
transaction.bookingDate || | ||
transaction.bookingDateTime || | ||
transaction.valueDate || | ||
transaction.valueDateTime; | ||
|
||
return { | ||
...transaction, | ||
payeeName: formatPayeeName(transaction), | ||
remittanceInformationUnstructured: | ||
transaction.remittanceInformationUnstructuredArray[1], | ||
date: d.format(d.parseISO(date), 'yyyy-MM-dd'), | ||
}; | ||
} | ||
|
||
return Fallback.normalizeTransaction(transaction, _booked); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import RevolutRevolt21 from '../revolut_revolt21.js'; | ||
|
||
describe('RevolutRevolt21', () => { | ||
describe('#normalizeTransaction', () => { | ||
it('returns the expected remittanceInformationUnstructured from a bizum expense transfer', () => { | ||
const transaction = { | ||
transactionAmount: { amount: '-1.00', currency: 'EUR' }, | ||
remittanceInformationUnstructuredArray: [ | ||
'Bizum payment to: CREDITOR NAME', | ||
'Bizum description', | ||
], | ||
bookingDate: '2024-09-21', | ||
}; | ||
|
||
const normalizedTransaction = RevolutRevolt21.normalizeTransaction( | ||
transaction, | ||
true, | ||
); | ||
|
||
expect(normalizedTransaction.remittanceInformationUnstructured).toEqual( | ||
'Bizum description', | ||
); | ||
}); | ||
}); | ||
|
||
it('returns the expected payeeName and remittanceInformationUnstructured from a bizum income transfer', () => { | ||
const transaction = { | ||
transactionAmount: { amount: '1.00', currency: 'EUR' }, | ||
remittanceInformationUnstructuredArray: [ | ||
'Bizum payment from: DEBTOR NAME', | ||
'Bizum description', | ||
], | ||
bookingDate: '2024-09-21', | ||
}; | ||
|
||
const normalizedTransaction = RevolutRevolt21.normalizeTransaction( | ||
transaction, | ||
true, | ||
); | ||
|
||
expect(normalizedTransaction.payeeName).toEqual('DEBTOR NAME'); | ||
expect(normalizedTransaction.remittanceInformationUnstructured).toEqual( | ||
'Bizum description', | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
category: Enhancements | ||
authors: [hostyn] | ||
--- | ||
|
||
Add support for Bizum transactions in Revolut |