-
-
Notifications
You must be signed in to change notification settings - Fork 651
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add BANKS_WITH_LIMITED_HISTORY constant and Implement BANKINTER_BKBKE…
…SMM Bank Adapter (#355)
- Loading branch information
Showing
4 changed files
with
120 additions
and
2 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,64 @@ | ||
import { | ||
printIban, | ||
amountToInteger, | ||
sortByBookingDateOrValueDate, | ||
} from '../utils.js'; | ||
|
||
const SORTED_BALANCE_TYPE_LIST = [ | ||
'closingBooked', | ||
'expected', | ||
'forwardAvailable', | ||
'interimAvailable', | ||
'interimBooked', | ||
'nonInvoiced', | ||
'openingBooked', | ||
]; | ||
|
||
/** @type {import('./bank.interface.js').IBank} */ | ||
export default { | ||
institutionIds: ['BANKINTER_BKBKESMM'], | ||
|
||
accessValidForDays: 90, | ||
|
||
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.product, | ||
type: 'checking', | ||
}; | ||
}, | ||
|
||
normalizeTransaction(transaction, _booked) { | ||
return { | ||
...transaction, | ||
debtorName: transaction.debtorName?.replaceAll(';', ' '), | ||
creditorName: transaction.creditorName?.replaceAll(';', ' '), | ||
remittanceInformationUnstructured: | ||
transaction.remittanceInformationUnstructured | ||
.replaceAll(/\/Txt\/(\w\|)?/gi, '') | ||
.replaceAll(';', ' '), | ||
date: transaction.bookingDate || transaction.valueDate, | ||
}; | ||
}, | ||
|
||
sortTransactions(transactions = []) { | ||
return sortByBookingDateOrValueDate(transactions); | ||
}, | ||
|
||
calculateStartingBalance(sortedTransactions = [], balances = []) { | ||
const currentBalance = balances | ||
.filter((item) => SORTED_BALANCE_TYPE_LIST.includes(item.balanceType)) | ||
.sort( | ||
(a, b) => | ||
SORTED_BALANCE_TYPE_LIST.indexOf(a.balanceType) - | ||
SORTED_BALANCE_TYPE_LIST.indexOf(b.balanceType), | ||
)[0]; | ||
return sortedTransactions.reduce((total, trans) => { | ||
return total - amountToInteger(trans.transactionAmount.amount); | ||
}, amountToInteger(currentBalance?.balanceAmount?.amount || 0)); | ||
}, | ||
}; |
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 BANKS_WITH_LIMITED_HISTORY constant and Implement BANKINTER_BKBKESMM Bank Adapter |