-
-
Notifications
You must be signed in to change notification settings - Fork 641
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
Add GoCardless integration for ABNAMRO_ABNANL2A #513
base: master
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request introduces a new bank module named Possibly related PRs
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (3)
src/app-gocardless/banks/abnamro_abnanl2a.js (2)
34-36
: Simplify extraction of 'payeeName'The
replace(/.+\*/, '')
inmatches[1].replace(/.+\*/, '').trim()
may be unnecessary if the remittance information does not contain a'*'
character. Simplifying the code can improve readability without affecting functionality.Apply this diff to simplify the code:
const payeeName = matches - ? matches[1].replace(/.+\*/,'').trim() + ? matches[1].trim() : undefined;
40-41
: Correct typographical errors in commentsThere are minor typographical errors in the comments:
- Line 40:
'anumber'
should be'a number'
.- Line 41:
'aboid'
should be'avoid'
.Apply this diff to correct the typos:
// There are anumber of superfluous keywords in the remittanceInformation. +// There are a number of superfluous keywords in the remittanceInformation. // Remove them to aboid clutter in notes. +// Remove them to avoid clutter in notes.src/app-gocardless/banks/tests/abnamro_abnanl2a.spec.js (1)
5-5
: Correct test description for clarityThe test description contains a redundant word
'and'
. Removing it improves clarity.Apply this diff to fix the test description:
-it('correctly extracts the payee and when not provided', () => { +it('correctly extracts the payee when not provided', () => {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
upcoming-release-notes/513.md
is excluded by!**/*.md
📒 Files selected for processing (3)
src/app-gocardless/bank-factory.js
(2 hunks)src/app-gocardless/banks/abnamro_abnanl2a.js
(1 hunks)src/app-gocardless/banks/tests/abnamro_abnanl2a.spec.js
(1 hunks)
🔇 Additional comments (1)
src/app-gocardless/bank-factory.js (1)
Line range hint 2-35
: Integration of new bank module is correct
The addition of AbnamroAbnanl2a
to the imports and the banks
array is correctly implemented.
let remittanceInformationUnstructured = | ||
transaction.remittanceInformationUnstructuredArray.join(' '); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add error handling for missing 'remittanceInformationUnstructuredArray'
If transaction.remittanceInformationUnstructuredArray
is undefined, calling .join(' ')
will result in a runtime error. Consider providing a default empty array to prevent this issue.
Apply this diff to add a default value:
let remittanceInformationUnstructured =
- transaction.remittanceInformationUnstructuredArray.join(' ');
+ (transaction.remittanceInformationUnstructuredArray || []).join(' ');
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
let remittanceInformationUnstructured = | |
transaction.remittanceInformationUnstructuredArray.join(' '); | |
let remittanceInformationUnstructured = | |
(transaction.remittanceInformationUnstructuredArray || []).join(' '); |
return amountToInteger( | ||
balances.find((balance) => 'interimBooked' === balance.balanceType) | ||
.balanceAmount.amount, | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle cases where 'interimBooked' balance is not found
If no balance with balanceType
equal to 'interimBooked'
is found, balances.find(...)
will return undefined
, and accessing .balanceAmount.amount
will throw an error. Adding error handling ensures robustness.
Apply this diff to add error handling:
} else {
+ const interimBalance = balances.find(
+ (balance) => 'interimBooked' === balance.balanceType,
+ );
+ if (!interimBalance) {
+ // Handle the case where no interimBooked balance is found
+ throw new Error('No interimBooked balance found');
+ }
return amountToInteger(
- balances.find((balance) => 'interimBooked' === balance.balanceType)
- .balanceAmount.amount,
+ interimBalance.balanceAmount.amount,
);
}
Committable suggestion skipped: line range outside the PR's diff.
Add GoCardless integration for ABNAMRO_ABNANL2A, with just a bit of added cleanup: