-
-
Notifications
You must be signed in to change notification settings - Fork 514
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GoCardless bank integration for American Express AESUDEF1 (#239)
- Loading branch information
Showing
13 changed files
with
129 additions
and
17 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 |
---|---|---|
@@ -1,9 +1,16 @@ | ||
import AmericanExpressAesudef1 from './banks/american-express-aesudef1.js'; | ||
import IngPlIngbplpw from './banks/ing-pl-ingbplpw.js'; | ||
import IntegrationBank from './banks/integration-bank.js'; | ||
import MbankRetailBrexplpw from './banks/mbank-retail-brexplpw.js'; | ||
import SandboxfinanceSfin0000 from './banks/sandboxfinance-sfin0000.js'; | ||
|
||
const banks = [MbankRetailBrexplpw, SandboxfinanceSfin0000, IngPlIngbplpw]; | ||
const banks = [ | ||
AmericanExpressAesudef1, | ||
IngPlIngbplpw, | ||
MbankRetailBrexplpw, | ||
SandboxfinanceSfin0000, | ||
]; | ||
|
||
export default (institutionId) => | ||
banks.find((b) => b.institutionId === institutionId) || IntegrationBank; | ||
banks.find((b) => b.institutionIds.includes(institutionId)) || | ||
IntegrationBank; |
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,55 @@ | ||
import { amountToInteger, sortByBookingDate } from '../utils.js'; | ||
|
||
/** @type {import('./bank.interface.js').IBank} */ | ||
export default { | ||
institutionIds: ['AMERICAN_EXPRESS_AESUDEF1'], | ||
|
||
normalizeAccount(account) { | ||
return { | ||
account_id: account.id, | ||
institution: account.institution, | ||
// The `iban` field for these American Express cards is actually a masked | ||
// version of the PAN. No IBAN is provided. | ||
mask: account.iban.slice(-5), | ||
iban: null, | ||
name: [account.details, `(${account.iban.slice(-5)})`].join(' '), | ||
official_name: account.details, | ||
// The Actual account `type` field is legacy and is currently not used | ||
// for anything, so we leave it as the default of `checking`. | ||
type: 'checking', | ||
}; | ||
}, | ||
|
||
normalizeTransaction(transaction, _booked) { | ||
/** | ||
* The American Express Europe integration sends the actual date of | ||
* purchase as `bookingDate`, and `valueDate` appears to contain a date | ||
* related to the actual booking date, though sometimes offset by a day | ||
* compared to the American Express website. | ||
*/ | ||
delete transaction.valueDate; | ||
return transaction; | ||
}, | ||
|
||
sortTransactions(transactions = []) { | ||
return sortByBookingDate(transactions); | ||
}, | ||
|
||
/** | ||
* For SANDBOXFINANCE_SFIN0000 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) => 'information' === balance.balanceType.toString(), | ||
); | ||
|
||
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
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
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
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,6 @@ | ||
--- | ||
category: Enhancements | ||
authors: [kyrias] | ||
--- | ||
|
||
Add American Express AESUDEF1 GoCardless bank integration |