Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create nordea_ndeadkkk.js #466

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions src/app-gocardless/banks/nordea_ndeadkkk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import Fallback from './integration-bank.js';

import { printIban, amountToInteger } from '../utils.js';
import { formatPayeeName } from '../../util/payee-name.js';

/** @type {import('./bank.interface.js').IBank} */
export default {

Check failure on line 7 in src/app-gocardless/banks/nordea_ndeadkkk.js

View workflow job for this annotation

GitHub Actions / build

Type '{ institutionIds: string[]; accessValidForDays: number; normalizeAccount(account: DetailedAccountWithInstitution): { account_id: string; institution: Institution; ... 4 more ...; type: string; }; normalizeTransaction(transaction: Transaction, _booked: boolean): { ...; } | { ...; }; calculateStartingBalance(sortedTra...' is not assignable to type 'IBank'.
...Fallback,

institutionIds: ['NORDEA_NDEADKKK'],

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',
};
},

/**
* Following the GoCardless documentation[0] we should prefer `bookingDate`
* here, though some of their bank integrations uses the date field
* differently from what's described in their documentation and so it's
* sometimes necessary to use `valueDate` instead.
*
* [0]: https://nordigen.zendesk.com/hc/en-gb/articles/7899367372829-valueDate-and-bookingDate-for-transactions
*/
normalizeTransaction(transaction, _booked) {
//transactions "transactionId" starts with P must be ignored
if (

Check failure on line 36 in src/app-gocardless/banks/nordea_ndeadkkk.js

View workflow job for this annotation

GitHub Actions / lint

Replace `⏎······transaction.transactionId.startsWith(⏎········'P',⏎······)⏎····` with `transaction.transactionId.startsWith('P')`
transaction.transactionId.startsWith(
'P',
)
) {
return {Null};

Check failure on line 41 in src/app-gocardless/banks/nordea_ndeadkkk.js

View workflow job for this annotation

GitHub Actions / lint

Replace `Null` with `·Null·`

Check failure on line 41 in src/app-gocardless/banks/nordea_ndeadkkk.js

View workflow job for this annotation

GitHub Actions / lint

'Null' is not defined

Check failure on line 41 in src/app-gocardless/banks/nordea_ndeadkkk.js

View workflow job for this annotation

GitHub Actions / build

No value exists in scope for the shorthand property 'Null'. Either declare one or provide an initializer.
}
return {
...transaction,
payeeName: formatPayeeName(transaction),
date: transaction.bookingDate || transaction.valueDate,
};
},

/**
* For NORDEA_NDEADKKK we don't know what balance was
* after each transaction so we have to calculate it by getting
* current balance from the account and subtract all the transactions
*
* As a current balance we use `interimBooked` balance type because
* it includes transaction placed during current day
*/
calculateStartingBalance(sortedTransactions = [], balances = []) {
const currentBalance = balances.find(
(balance) => 'interimAvailable' === balance.balanceType,
);

return sortedTransactions.reduce((total, trans) => {
return total - amountToInteger(trans.transactionAmount.amount);
}, amountToInteger(currentBalance.balanceAmount.amount));
},
};
Loading