-
-
Notifications
You must be signed in to change notification settings - Fork 614
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DANSKEBANK_DABANO22 integration (#244)
- Loading branch information
Showing
3 changed files
with
68 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,60 @@ | ||
import { | ||
printIban, | ||
amountToInteger, | ||
sortByBookingDateOrValueDate, | ||
} from '../utils.js'; | ||
|
||
/** @type {import('./bank.interface.js').IBank} */ | ||
export default { | ||
institutionIds: ['DANSKEBANK_DABANO22'], | ||
|
||
normalizeAccount(account) { | ||
return { | ||
account_id: account.id, | ||
institution: account.institution, | ||
mask: account.iban.slice(-4), | ||
iban: account.iban, | ||
name: [account.name, printIban(account)].join(' '), | ||
official_name: account.name, | ||
type: 'checking', | ||
}; | ||
}, | ||
|
||
normalizeTransaction(transaction, _booked) { | ||
/** | ||
* Danske Bank appends the EndToEndID: NOTPROVIDED to | ||
* remittanceInformationUnstructured, cluttering the data. | ||
* | ||
* We clean thais up by removing any instances of this string from all transactions. | ||
* | ||
*/ | ||
transaction.remittanceInformationUnstructured = | ||
transaction.remittanceInformationUnstructured.replace( | ||
'\nEndToEndID: NOTPROVIDED', | ||
'', | ||
); | ||
|
||
/** | ||
* The valueDate in transactions from Danske Bank is not the one expected, but rather the date | ||
* the funds are expected to be paid back for credit accounts. | ||
*/ | ||
return { | ||
...transaction, | ||
date: transaction.bookingDate, | ||
}; | ||
}, | ||
|
||
sortTransactions(transactions = []) { | ||
return sortByBookingDateOrValueDate(transactions); | ||
}, | ||
|
||
calculateStartingBalance(sortedTransactions = [], balances = []) { | ||
const currentBalance = balances.find( | ||
(balance) => balance.balanceType === 'interimAvailable', | ||
); | ||
|
||
return sortedTransactions.reduce((total, trans) => { | ||
return total - amountToInteger(trans.transactionAmount.amount); | ||
}, amountToInteger(currentBalance.balanceAmount.amount)); | ||
}, | ||
}; |
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: [LudvigHz] | ||
--- | ||
|
||
Add GoCardless integration for Danske Bank Private NO |