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

ISYBANK_ITBBITMM should prefer valueDate over bookingDate #510

Merged
merged 4 commits into from
Dec 16, 2024

Conversation

matt-fidd
Copy link
Contributor

Reported in Github, valueDate is more accurate for ISYBANK_ITBBITMM

@actual-github-bot actual-github-bot bot changed the title ISYBANK_ITBBITMM should prefer valueDate over bookingDate [WIP] ISYBANK_ITBBITMM should prefer valueDate over bookingDate Nov 25, 2024
@matt-fidd matt-fidd changed the title [WIP] ISYBANK_ITBBITMM should prefer valueDate over bookingDate ISYBANK_ITBBITMM should prefer valueDate over bookingDate Nov 25, 2024
Copy link
Contributor

coderabbitai bot commented Nov 25, 2024

Walkthrough

The pull request introduces changes to two files within the application. In src/app-gocardless/bank-factory.js, a new import statement for IsyBankItbbitmm is added, and this bank is included in the exported array of bank modules. The functionality of the default export function remains unchanged, continuing to search for a bank based on the provided institutionId. In the newly created file src/app-gocardless/banks/isybank-itbbitmm.js, a default export object is defined that extends the Fallback module from integration-bank.js. This object includes an institutionIds array with the identifier ISYBANK_ITBBITMM and a method normalizeTransaction, which overrides the corresponding method in the Fallback module. The normalizeTransaction method updates the bookingDate of a transaction based on the availability of valueDate and then calls the original method from the Fallback module.

Possibly related PRs

Suggested labels

:sparkles: Merged


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ba59678 and 4aa37a0.

📒 Files selected for processing (1)
  • src/app-gocardless/bank-factory.js (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/app-gocardless/bank-factory.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 generate docstrings to generate docstrings for this PR. (Experiment)
  • @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

@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: 0

🧹 Outside diff range and nitpick comments (1)
src/app-gocardless/banks/isybank-itbbitmm.js (1)

9-15: Consider adding defensive validation

The implementation correctly prefers valueDate over bookingDate as intended. However, consider adding validation to ensure robust handling of edge cases.

Consider this more defensive implementation:

 normalizeTransaction(transaction, booked) {
+    if (!transaction || typeof transaction !== 'object') {
+      return Fallback.normalizeTransaction(transaction, booked);
+    }
+
+    // Ensure dates are valid before assignment
+    if (transaction.valueDate instanceof Date || 
+        (typeof transaction.valueDate === 'string' && !isNaN(Date.parse(transaction.valueDate)))) {
       transaction.bookingDate = transaction.valueDate ?? transaction.bookingDate;
+    }
 
     return Fallback.normalizeTransaction(transaction, booked);
 },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 69a04a5 and ba59678.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/510.md is excluded by !**/*.md
📒 Files selected for processing (2)
  • src/app-gocardless/bank-factory.js (2 hunks)
  • src/app-gocardless/banks/isybank-itbbitmm.js (1 hunks)
🔇 Additional comments (6)
src/app-gocardless/banks/isybank-itbbitmm.js (3)

1-3: LGTM! Good use of TypeScript-like typing

The import statement and JSDoc type annotation provide good type safety and IDE support.


4-5: LGTM! Good use of composition pattern

Using object spread to extend the Fallback implementation is a clean approach.


7-7: Verify the institution ID usage across the codebase

The institution ID matches the PR objective. Let's verify its usage.

✅ Verification successful

Institution ID 'ISYBANK_ITBBITMM' is properly configured and consistently used

The verification shows that the institution ID is:

  • Correctly defined in the bank configuration file
  • Properly imported and exported in the bank factory
  • No inconsistencies or typos found in the usage across the codebase
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the institution ID usage and ensure consistency

# Check for any other occurrences of this institution ID
rg "ISYBANK_ITBBITMM" --type js --type ts

# Check for any potential typos or variations
rg -i "isybank" --type js --type ts

Length of output: 395

src/app-gocardless/bank-factory.js (3)

16-16: LGTM! Import follows established patterns.

The new import statement maintains consistency with existing imports and follows alphabetical ordering.


48-48: LGTM! Bank module correctly added to exports.

The IsyBankItbbitmm module is properly added to the banks array, maintaining alphabetical order.


Line range hint 67-115: Verify if ISYBANK_ITBBITMM should be in BANKS_WITH_LIMITED_HISTORY.

Please verify if the new bank integration has any history limitations that would require it to be added to the BANKS_WITH_LIMITED_HISTORY array.

✅ Verification successful

ISYBANK_ITBBITMM should not be added to BANKS_WITH_LIMITED_HISTORY

Based on the code analysis:

  • The bank implementation inherits from the default IntegrationBank which has a standard 90-day access period
  • There are no specific history limitations mentioned in the bank's implementation
  • The bank only customizes the transaction date normalization behavior
  • BANKS_WITH_LIMITED_HISTORY is used to restrict maxHistoricalDays during session initialization, and there's no evidence suggesting ISYBANK_ITBBITMM needs this restriction
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the new bank has history limitations mentioned in its implementation

# Search for history-related comments or configurations in the bank implementation
rg -i "history|limit" src/app-gocardless/banks/isybank-itbbitmm.js

# Check if other bank implementations reference ISYBANK_ITBBITMM in relation to history limitations
rg -i "ISYBANK_ITBBITMM.*history|history.*ISYBANK_ITBBITMM"

Length of output: 130


Script:

#!/bin/bash
# Let's try a different approach to verify history limitations

# First, let's check if the bank file exists and see its content
fd "isybank-itbbitmm.js" --type f

# Let's also check for any documentation or configuration files that might mention history limitations
rg -i "isybank.*itbbitmm" 

# Let's examine the implementation of other banks that are in BANKS_WITH_LIMITED_HISTORY to see patterns
# Taking a few examples from the list
rg -i "history|limit" src/app-gocardless/banks/revolut.js
rg -i "history|limit" src/app-gocardless/banks/n26.js

Length of output: 705


Script:

#!/bin/bash
# Let's examine the actual implementation of isybank to look for any limitations

# Check the full content of the isybank implementation
cat src/app-gocardless/banks/isybank-itbbitmm.js

# Let's also check for any documentation about bank limitations
fd -e md -e txt | xargs rg -i "bank.*history.*limit|transaction.*history.*limit"

# Let's also check the integration bank implementation since it was referenced in the code
fd "integration-bank.js" --type f

Length of output: 683


Script:

#!/bin/bash
# Let's check the integration bank implementation for any default limitations
cat src/app-gocardless/banks/integration-bank.js

# Let's also check if there are any specific patterns or configurations
# that determine if a bank should be in BANKS_WITH_LIMITED_HISTORY
rg -i "BANKS_WITH_LIMITED_HISTORY" -A 5 -B 5

Length of output: 5486

@matt-fidd matt-fidd merged commit d637a69 into actualbudget:master Dec 16, 2024
8 checks passed
@matt-fidd matt-fidd deleted the isybank-itbbitmm branch December 16, 2024 20:05
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