forked from actualbudget/actual-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workaround for non-unique transactionIds for Belfius bank (actual…
…budget#283) Co-authored-by: Toon Willems <[email protected]>
- Loading branch information
Showing
5 changed files
with
66 additions
and
0 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,29 @@ | ||
import Fallback from './integration-bank.js'; | ||
|
||
/** @type {import('./bank.interface.js').IBank} */ | ||
export default { | ||
institutionIds: ['BELFIUS_GKCCBEBB'], | ||
|
||
normalizeAccount(account) { | ||
return Fallback.normalizeAccount(account); | ||
}, | ||
|
||
// The problem is that we have transaction with duplicated transaction ids. | ||
// This is not expected and the nordigen api has a work-around for some backs | ||
// They will set an internalTransactionId which is unique | ||
normalizeTransaction(transaction, _booked) { | ||
return { | ||
...transaction, | ||
transactionId: transaction.internalTransactionId, | ||
date: transaction.bookingDate || transaction.valueDate, | ||
}; | ||
}, | ||
|
||
sortTransactions(transactions = []) { | ||
return Fallback.sortTransactions(transactions); | ||
}, | ||
|
||
calculateStartingBalance(sortedTransactions = [], balances = []) { | ||
return Fallback.calculateStartingBalance(sortedTransactions, balances); | ||
}, | ||
}; |
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,21 @@ | ||
import Belfius from '../belfius_gkccbebb.js'; | ||
import { mockTransactionAmount } from '../../services/tests/fixtures.js'; | ||
|
||
describe('Belfius', () => { | ||
describe('#normalizeTransaction', () => { | ||
it('returns the internalTransactionId as transactionId', () => { | ||
const transaction = { | ||
transactionId: 'non-unique-id', | ||
internalTransactionId: 'D202301180000003', | ||
transactionAmount: mockTransactionAmount, | ||
}; | ||
const normalizedTransaction = Belfius.normalizeTransaction( | ||
transaction, | ||
true, | ||
); | ||
expect(normalizedTransaction.transactionId).toEqual( | ||
transaction.internalTransactionId, | ||
); | ||
}); | ||
}); | ||
}); |
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: Bugfix | ||
authors: [Nudded] | ||
--- | ||
|
||
Fix: non-unique transactionId values for Belfius bank causing missing data. |