-
-
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.
Merge branch 'master' into zach/simplefin
- Loading branch information
Showing
19 changed files
with
773 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import getAccountDb from '../src/account-db.js'; | ||
|
||
export const up = async function () { | ||
await getAccountDb().exec( | ||
`UPDATE secrets SET name = 'gocardless_secretId' WHERE name = 'nordigen_secretId'`, | ||
); | ||
await getAccountDb().exec( | ||
`UPDATE secrets SET name = 'gocardless_secretKey' WHERE name = 'nordigen_secretKey'`, | ||
); | ||
}; | ||
|
||
export const down = async function () { | ||
await getAccountDb().exec( | ||
`UPDATE secrets SET name = 'nordigen_secretId' WHERE name = 'gocardless_secretId'`, | ||
); | ||
await getAccountDb().exec( | ||
`UPDATE secrets SET name = 'nordigen_secretKey' WHERE name = 'gocardless_secretKey'`, | ||
); | ||
}; |
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
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,56 @@ | ||
import { printIban, amountToInteger } from '../utils.js'; | ||
|
||
/** @type {import('./bank.interface.js').IBank} */ | ||
export default { | ||
institutionIds: ['ING_INGDDEFF'], | ||
|
||
normalizeAccount(account) { | ||
return { | ||
account_id: account.id, | ||
institution: account.institution, | ||
mask: account.iban.slice(-4), | ||
iban: account.iban, | ||
name: [account.product, printIban(account)].join(' '), | ||
official_name: account.product, | ||
type: 'checking', | ||
}; | ||
}, | ||
|
||
normalizeTransaction(transaction, _booked) { | ||
const remittanceInformationMatch = /remittanceinformation:(.*)$/.exec( | ||
transaction.remittanceInformationUnstructured, | ||
); | ||
const remittanceInformation = remittanceInformationMatch | ||
? remittanceInformationMatch[1] | ||
: transaction.remittanceInformationUnstructured; | ||
|
||
return { | ||
...transaction, | ||
remittanceInformationUnstructured: remittanceInformation, | ||
date: transaction.bookingDate || transaction.valueDate, | ||
}; | ||
}, | ||
|
||
sortTransactions(transactions = []) { | ||
return transactions.sort((a, b) => { | ||
const diff = | ||
+new Date(b.valueDate || b.bookingDate) - | ||
+new Date(a.valueDate || a.bookingDate); | ||
if (diff) return diff; | ||
const idA = parseInt(a.transactionId); | ||
const idB = parseInt(b.transactionId); | ||
if (!isNaN(idA) && !isNaN(idB)) return idB - idA; | ||
return 0; | ||
}); | ||
}, | ||
|
||
calculateStartingBalance(sortedTransactions = [], balances = []) { | ||
const currentBalance = balances.find( | ||
(balance) => 'interimBooked' === balance.balanceType, | ||
); | ||
|
||
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
87 changes: 87 additions & 0 deletions
87
src/app-gocardless/banks/spk-marburg-biedenkopf-heladef1mar.js
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,87 @@ | ||
import { | ||
printIban, | ||
amountToInteger, | ||
sortByBookingDateOrValueDate, | ||
} from '../utils.js'; | ||
import d from 'date-fns'; | ||
|
||
const SORTED_BALANCE_TYPE_LIST = [ | ||
'closingBooked', | ||
'expected', | ||
'forwardAvailable', | ||
'interimAvailable', | ||
'interimBooked', | ||
'nonInvoiced', | ||
'openingBooked', | ||
]; | ||
|
||
/** @type {import('./bank.interface.js').IBank} */ | ||
export default { | ||
institutionIds: ['SPK_MARBURG_BIEDENKOPF_HELADEF1MAR'], | ||
|
||
normalizeAccount(account) { | ||
return { | ||
account_id: account.id, | ||
institution: account.institution, | ||
mask: (account?.iban || '0000').slice(-4), | ||
iban: account?.iban || null, | ||
name: [account.product, printIban(account), account.currency] | ||
.filter(Boolean) | ||
.join(' '), | ||
official_name: account.product, | ||
type: 'checking', | ||
}; | ||
}, | ||
|
||
normalizeTransaction(transaction, _booked) { | ||
const date = | ||
transaction.bookingDate || | ||
transaction.bookingDateTime || | ||
transaction.valueDate || | ||
transaction.valueDateTime; | ||
|
||
// If we couldn't find a valid date field we filter out this transaction | ||
// and hope that we will import it again once the bank has processed the | ||
// transaction further. | ||
if (!date) { | ||
return null; | ||
} | ||
|
||
let remittanceInformationUnstructured; | ||
|
||
if (transaction.remittanceInformationUnstructured) { | ||
remittanceInformationUnstructured = | ||
transaction.remittanceInformationUnstructured; | ||
} else if (transaction.remittanceInformationStructured) { | ||
remittanceInformationUnstructured = | ||
transaction.remittanceInformationStructured; | ||
} else if (transaction.remittanceInformationStructuredArray?.length > 0) { | ||
remittanceInformationUnstructured = | ||
transaction.remittanceInformationStructuredArray?.join(' '); | ||
} | ||
|
||
return { | ||
...transaction, | ||
date: d.format(d.parseISO(date), 'yyyy-MM-dd'), | ||
remittanceInformationUnstructured: remittanceInformationUnstructured, | ||
}; | ||
}, | ||
|
||
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)); | ||
}, | ||
}; |
Oops, something went wrong.