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

Improve abn amro sync #534

Merged
merged 4 commits into from
Jan 7, 2025
Merged

Improve abn amro sync #534

merged 4 commits into from
Jan 7, 2025

Conversation

UnderKoen
Copy link
Member

For payment made with google pay this also cleanes the payee_name.

Removes the removal of certain terms in the notes. As for me it really helpful to have BEA and GEA in the notes. (GEA is for atm withdraws)

The cleaning should be achieved with actualbudget/actual#3606 I think. @nsulzer would you be opposed by this?

@actual-github-bot actual-github-bot bot changed the title Improve abn amro sync [WIP] Improve abn amro sync Jan 3, 2025
@UnderKoen UnderKoen changed the title [WIP] Improve abn amro sync Improve abn amro sync Jan 3, 2025
Copy link
Contributor

coderabbitai bot commented Jan 3, 2025

Walkthrough

The pull request introduces modifications to the ABNAMRO bank transaction normalization logic in two files: abnamro_abnanl2a.js and its corresponding test file abnamro_abnanl2a.spec.js. The changes primarily focus on refining the normalizeTransaction method's handling of remittance information and payee name extraction.

In the main implementation file, the code has been updated to directly assign the joined remittanceInformationUnstructuredArray to transaction.remittanceInformationUnstructured, using a comma as a separator. The payee name extraction logic has been modified to map over the array and find the first regex match, replacing the previous approach that used an intermediate variable.

The test file complements these changes by adding a new test case for Google Pay transactions and updating an existing test to reflect the new comma-separated remittance information handling. These modifications aim to improve the robustness and flexibility of transaction normalization for ABNAMRO bank transactions.


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. (Beta)
  • @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

🧹 Nitpick comments (2)
src/app-gocardless/banks/tests/abnamro_abnanl2a.spec.js (1)

28-28: Double-check spacing and punctuation in joined string

In some transaction entries, commas appear without a trailing space (e.g., "...Name,PAS123..."). This is consistent with the final joined result here, but ensure that the consumer of these notes doesn't require consistent spacing after commas. If any consumer or downstream parser expects normalized spacing, consider adjusting the join logic or test data for readability.

src/app-gocardless/banks/abnamro_abnanl2a.js (1)

27-28: Potential edge cases with comma-separated fields

By opting to join the unstructured array with commas, if any of those elements already contain embedded commas, it may result in ambiguous or confusing entries. If these entries are guaranteed to be well-formatted or always comma-free, then this approach is fine. Otherwise, consider a safer or more robust delimiter—or escaping the existing commas—to avoid conflated data fields.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2005c1b and 08817a1.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/534.md is excluded by !**/*.md
📒 Files selected for processing (2)
  • src/app-gocardless/banks/abnamro_abnanl2a.js (1 hunks)
  • src/app-gocardless/banks/tests/abnamro_abnanl2a.spec.js (1 hunks)
🔇 Additional comments (3)
src/app-gocardless/banks/tests/abnamro_abnanl2a.spec.js (2)

32-32: Empty line: no action needed


33-59: Good addition of a Google Pay test

This new test cleanly verifies that when the remittanceInformationUnstructuredArray contains a Google Pay entry, the payee is extracted correctly as "Other Payee Name," and the joined string contains all fragments. The test coverage looks good for this scenario.

src/app-gocardless/banks/abnamro_abnanl2a.js (1)

32-34: Regex approach for payee extraction is concise, but handle unexpected formats

The current pattern matches strings like “CCV*Other payee name,PAS123” by capturing the substring before ,PAS. Ensure that this pattern won’t accidentally miss payee names if they include special characters or if “PAS” appears out of place. If there is any risk, consider adding fallback logic or additional validation for unrecognized lines.

@nsulzer
Copy link
Contributor

nsulzer commented Jan 4, 2025

Hiya @UnderKoen, after tinkering with the rule action templating a bit, I have no objections. I agree that it's convinent to keep all information and let people decide for themselves what to keep. Also, thanks for cleaning up the payeeName extraction 😅.

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

@UnderKoen UnderKoen merged commit 215e00a into master Jan 7, 2025
10 checks passed
@UnderKoen UnderKoen deleted the UnderKoen/improve_abn_amro branch January 7, 2025 19:05
@thomwiggers
Copy link

The way the approach in the PR works is that it relies on particular payment service providers that inject their own name into the transaction description; e.g., in the provided test case, this is CCV and the regex relies on CCV* being part of the string to strip it.

This is not a very solid approach; many payment terminals do not have the same treatment. E.g., looking at my own transactions, Albert Heijn is listed as something like BEA, Apple Pay Albert Heijn,PAS123,NR:123456, 01.01.24/10:59, ZAANDAM. If the intention of this PR was to remove Google Pay, it seems better to explicitly include ((Google|Apple) Pay)? into the regex.

@thomwiggers
Copy link

Or were you intending to just remove the payment service provider from the vendor name? (because AFAIK that's not related to Google Pay at all).

@thomwiggers
Copy link

Never mind, I misunderstood how the parsing changed: it now only matches on line 2 of the input and that automatically removes the Apple Pay indicator as well.

@UnderKoen
Copy link
Member Author

Hey @thomwiggers ,
This approach uses the fact that the payee name is on a seprate line. Most of the times the second one.

So for your example in #540

remittanceInformationUnstructuredArray: [
	'BEA, Apple Pay',
	'Other payee name,PAS123', <-- this one
	'NR:123A4B, 09.12.23/15:43',
	'CITY',
],

It would look for the line with PAS... in it

@thomwiggers
Copy link

Yeah I clearly wasn't awake enough last night, all good!

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.

4 participants