Skip to content
This repository has been archived by the owner on Feb 10, 2025. It is now read-only.

Commit

Permalink
update instructions on GoCardless handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-fidd committed Feb 11, 2025
1 parent 232b2ff commit 4441caa
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions src/app-gocardless/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ If the default bank integration does not work for you, you can integrate a new b

This will trigger the process of fetching the data from the bank and will log the data in the backend. Use this data to fill the logic of the bank class.

4. Create new a bank class based on `app-gocardless/banks/sandboxfinance-sfin0000.js`.
4. Create new a bank class based on an existing example in `app-gocardless/banks`.

Name of the file and class should be created based on the ID of the integrated institution, found in step 1.
Name of the file and class should follow the existing patterns and be created based on the ID of the integrated institution, found in step 1.

5. Fill the logic of `normalizeAccount`, `normalizeTransaction`, `sortTransactions`, and `calculateStartingBalance` functions.
You do not need to fill every function, only those which are necessary for the integration to work.
Expand Down Expand Up @@ -69,7 +69,7 @@ If the default bank integration does not work for you, you can integrate a new b
- `sortTransactions` function:
```log
Available (first 10) transactions properties for new integration of institution in sortTransactions function
Available (first 10) transactions properties for new integration of institution in sortTransactions function
{
top10SortedTransactions: '[
{
Expand Down Expand Up @@ -162,3 +162,34 @@ If the default bank integration does not work for you, you can integrate a new b
6. Add new bank integration to `BankFactory` class in file `actual-server/app-gocardless/bank-factory.js`
7. Remember to add tests for new bank integration in
## normalizeTransaction
This is the most commonly used override as it allows you to change the data that is returned to the client.
Please follow the following patterns when implementing a custom normalizeTransaction method:
1. If you need to edit the values of transaction fields (excluding the transaction amount) do not mutate the original transaction object. Instead, create a shallow copy and make your changes there.
2. End the function by returning the result of calling the fallback normalizeTransaction method from integration-bank.js
E.g.
```js
import Fallback from './integration-bank.js';
export default {
...
normalizeTransaction(transaction, booked) {
// create a shallow copy of the transaction object
const editedTrans = { ...transaction };
// make any changes required to the copy
editedTrans.remittanceInformationUnstructured = transaction.remittanceInformationStructured;
// call the fallback method, passing in your edited transaction as the 3rd parameter
// this will calculate the date, payee name and notes fields based on your changes
// but leave the original fields available for mapping in the UI
return Fallback.normalizeTransaction(transaction, booked, editedTrans);
}
...
}
```

0 comments on commit 4441caa

Please sign in to comment.