Skip to content

Commit

Permalink
Create nordea_ndeadkkk.js
Browse files Browse the repository at this point in the history
  • Loading branch information
hsk-dk authored Sep 27, 2024
1 parent 0757f9d commit c63885f
Showing 1 changed file with 67 additions and 0 deletions.
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));
},
};

0 comments on commit c63885f

Please sign in to comment.