Skip to content
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 custom handler for the German bank Rheinhessen Sparkasse to the GoCardless app #454

Merged
merged 12 commits into from
Sep 26, 2024

Conversation

DirgoSalga
Copy link
Contributor

Following the guide and using the template, I added the code, similar to other handlers, that should match the transaction as seen in the logs when syncing my bank (Rheinhessen Sparkasse) through Actual.

The only thing that had to be modified was that the notes about the transaction are stored under remittanceInformationStructured and not under remittanceInformationUnstructured.

Testing still pending.

…oCardless app.

Following the guide and using the template added the code, similar to other handlers, that should match the transaction as seen in the logs when syncing my bank through Actual.

The only thing that had to be added was the notes about the transaction are stored under remittanceInformationStructured and not under remittanceInformationUnstructured.

Testing still pending.
@actual-github-bot actual-github-bot bot changed the title Add custom handler for the German bank Rheinhessen Sparkasse to the GoCardless app [WIP] Add custom handler for the German bank Rheinhessen Sparkasse to the GoCardless app Sep 14, 2024
Replaced the indentation from 4 spaces to 2, to fix linting error as recommended by the yarn test.

Added the release notes file 454.md.
@DirgoSalga DirgoSalga changed the title [WIP] Add custom handler for the German bank Rheinhessen Sparkasse to the GoCardless app Add custom handler for the German bank Rheinhessen Sparkasse to the GoCardless app Sep 18, 2024
Copy link
Contributor

coderabbitai bot commented Sep 18, 2024

Walkthrough

The pull request introduces a new bank module, SpkWormsAlzeyRiedMalade51wor, into the bank-factory.js file and creates a corresponding JavaScript module for bank integration. This new module includes methods for normalizing account and transaction data, as well as calculating the starting balance based on transactions. The changes expand the functionality of the bank factory by adding a new bank module without modifying existing logic.

Changes

File Path Change Summary
src/app-gocardless/bank-factory.js Added new bank module SpkWormsAlzeyRiedMalade51wor to the import statement and exported it in the banks array.
src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js Added methods: normalizeAccount(account), normalizeTransaction(transaction, _booked), and calculateStartingBalance(sortedTransactions = [], balances = []).

Possibly related PRs

Suggested labels

✨ Merged

Suggested reviewers

  • MatissJanis

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5a84b18 and 87b2080.

📒 Files selected for processing (1)
  • src/app-gocardless/banks/spk-worms-alzey-ried-malade51wor.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/app-gocardless/banks/spk-worms-alzey-ried-malade51wor.js

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@matt-fidd matt-fidd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! A few minor comments before we can get it merged in

src/app-gocardless/bank-factory.js Outdated Show resolved Hide resolved
src/app-gocardless/bank-factory.js Outdated Show resolved Hide resolved
upcoming-release-notes/454.md Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7ce4c90 and ebc0e5c.

Files ignored due to path filters (1)
  • upcoming-release-notes/454.md is excluded by !**/*.md
Files selected for processing (2)
  • src/app-gocardless/bank-factory.js (2 hunks)
  • src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/app-gocardless/banks/spk_worms_alzey_ried_malade51wor.js
Additional context used
GitHub Check: build
src/app-gocardless/bank-factory.js

[failure] 26-26:
Cannot find module './banks/spk-worms-alzey-ried-malade51wor.js' or its corresponding type declarations.

Additional comments not posted (2)
src/app-gocardless/bank-factory.js (2)

26-26: The past review comment suggesting to rename the import to match the naming convention is still applicable.

Tools
GitHub Check: build

[failure] 26-26:
Cannot find module './banks/spk-worms-alzey-ried-malade51wor.js' or its corresponding type declarations.


55-55: LGTM!

The new bank module is correctly added to the exported banks array.

src/app-gocardless/bank-factory.js Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ebc0e5c and 94f67b6.

Files selected for processing (1)
  • src/app-gocardless/banks/spk-worms-alzey-ried-malade51wor.js (1 hunks)

Since no changes were made to the default functions, they should be deleted from this specific bank (SPK_WORMS_ALZEY_RIED_MALADE51WOR).
Remove import of unsed variables.
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 (1)
src/app-gocardless/banks/spk-worms-alzey-ried-malade51wor.js (1)

1-30: Overall implementation looks good, next steps for completion

The implementation of the custom handler for the Rheinhessen Sparkasse bank is well-structured and aligns with the PR objectives. Key points:

  1. The handler extends the fallback integration correctly.
  2. Bank-specific details (institutionIds, accessValidForDays) are properly set.
  3. The normalizeTransaction function processes transactions as expected, including the use of remittanceInformationStructured as mentioned in the PR description.

To complete this PR:

  1. Address the suggested changes in the previous comments.
  2. Implement the pending tests mentioned in the PR description.
  3. Write the release notes as reminded in the PR description.
  4. Consider adding comments to explain any bank-specific logic, especially in the normalizeTransaction function.

For future improvements, consider:

  1. Implementing error handling for edge cases in transaction processing.
  2. Adding logging for important operations to aid in debugging and monitoring.
  3. Creating a test suite that covers various transaction scenarios specific to this bank.
🧰 Tools
GitHub Check: lint

[failure] 3-3:
'printIban' is defined but never used


[failure] 3-3:
'amountToInteger' is defined but never used

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 94f67b6 and 5a84b18.

📒 Files selected for processing (1)
  • src/app-gocardless/banks/spk-worms-alzey-ried-malade51wor.js (1 hunks)
🧰 Additional context used
GitHub Check: lint
src/app-gocardless/banks/spk-worms-alzey-ried-malade51wor.js

[failure] 3-3:
'printIban' is defined but never used


[failure] 3-3:
'amountToInteger' is defined but never used

🔇 Additional comments not posted (1)
src/app-gocardless/banks/spk-worms-alzey-ried-malade51wor.js (1)

6-12: LGTM: Exported object correctly configured

The exported object is properly set up:

  1. It extends the Fallback integration as expected.
  2. The institutionIds correctly identifies the Rheinhessen Sparkasse bank (SPK_WORMS_ALZEY_RIED_MALADE51WOR).
  3. The accessValidForDays is set to 90, which is a reasonable duration for access validity.

This implementation aligns well with the PR objectives.

Comment on lines 1 to 4
import Fallback from './integration-bank.js';

import { printIban, amountToInteger } from '../utils.js';
import { formatPayeeName } from '../../util/payee-name.js';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove unused imports to improve code cleanliness

The static analysis tool correctly identified that printIban and amountToInteger are imported but not used in this file. To keep the code clean and prevent potential confusion, it's recommended to remove unused imports.

Apply this diff to remove the unused imports:

 import Fallback from './integration-bank.js';

-import { printIban, amountToInteger } from '../utils.js';
 import { formatPayeeName } from '../../util/payee-name.js';
📝 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.

Suggested change
import Fallback from './integration-bank.js';
import { printIban, amountToInteger } from '../utils.js';
import { formatPayeeName } from '../../util/payee-name.js';
import Fallback from './integration-bank.js';
import { formatPayeeName } from '../../util/payee-name.js';
🧰 Tools
GitHub Check: lint

[failure] 3-3:
'printIban' is defined but never used


[failure] 3-3:
'amountToInteger' is defined but never used

Comment on lines +14 to +29
normalizeTransaction(transaction, _booked) {
const date = transaction.bookingDate || transaction.valueDate;
if (!date) {
return null;
}

transaction.remittanceInformationUnstructured =
transaction.remittanceInformationUnstructured ??
transaction.remittanceInformationStructured ??
transaction.remittanceInformationStructuredArray?.join(' ');
return {
...transaction,
payeeName: formatPayeeName(transaction),
date: transaction.bookingDate || transaction.valueDate,
};
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Refactor to avoid mutating the transaction object

The normalizeTransaction function is mostly well-implemented, but there's an issue with directly mutating the transaction object. This was correctly identified in a previous review comment. Let's address this to improve the function's immutability.

Apply this diff to refactor the function:

 normalizeTransaction(transaction, _booked) {
   const date = transaction.bookingDate || transaction.valueDate;
   if (!date) {
     return null;
   }

-  transaction.remittanceInformationUnstructured =
-    transaction.remittanceInformationUnstructured ??
-    transaction.remittanceInformationStructured ??
-    transaction.remittanceInformationStructuredArray?.join(' ');
   return {
     ...transaction,
+    remittanceInformationUnstructured:
+      transaction.remittanceInformationUnstructured ??
+      transaction.remittanceInformationStructured ??
+      transaction.remittanceInformationStructuredArray?.join(' '),
     payeeName: formatPayeeName(transaction),
     date: transaction.bookingDate || transaction.valueDate,
   };
 },

This change ensures that we're not modifying the original transaction object, which aligns better with immutability principles and prevents potential side effects.

📝 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.

Suggested change
normalizeTransaction(transaction, _booked) {
const date = transaction.bookingDate || transaction.valueDate;
if (!date) {
return null;
}
transaction.remittanceInformationUnstructured =
transaction.remittanceInformationUnstructured ??
transaction.remittanceInformationStructured ??
transaction.remittanceInformationStructuredArray?.join(' ');
return {
...transaction,
payeeName: formatPayeeName(transaction),
date: transaction.bookingDate || transaction.valueDate,
};
},
normalizeTransaction(transaction, _booked) {
const date = transaction.bookingDate || transaction.valueDate;
if (!date) {
return null;
}
return {
...transaction,
remittanceInformationUnstructured:
transaction.remittanceInformationUnstructured ??
transaction.remittanceInformationStructured ??
transaction.remittanceInformationStructuredArray?.join(' '),
payeeName: formatPayeeName(transaction),
date: transaction.bookingDate || transaction.valueDate,
};
},

Copy link
Contributor

@matt-fidd matt-fidd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants