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

SSK_DUSSELDORF_DUSSDEDDXXX: remove non-booked transactions from import #553

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

DennaGherlyn
Copy link
Contributor

The "Stadtsparkasse Düsseldorf" fills uncleared transactions with placeholder text. This text is not useful for human eyes or rule mapping. When the transaction is cleared the bank replaces the text with the correct payee and updates the notes. These don't get picked up on the next import, because the fields are already filled, therefore I removed the import of uncleared transactions.

@actual-github-bot actual-github-bot bot changed the title SSK_DUSSELDORF_DUSSDEDDXXX: remove non-booked transactions from import [WIP] SSK_DUSSELDORF_DUSSDEDDXXX: remove non-booked transactions from import Jan 16, 2025
@DennaGherlyn DennaGherlyn changed the title [WIP] SSK_DUSSELDORF_DUSSDEDDXXX: remove non-booked transactions from import SSK_DUSSELDORF_DUSSDEDDXXX: remove non-booked transactions from import Jan 16, 2025
Copy link
Contributor

coderabbitai bot commented Jan 16, 2025

Warning

Rate limit exceeded

@DennaGherlyn has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 54 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between d36d396 and dad0b59.

📒 Files selected for processing (1)
  • src/app-gocardless/banks/tests/ssk_dusseldorf_dussdeddxxx.spec.js (1 hunks)

Walkthrough

The pull request introduces changes to the normalizeTransaction method in the ssk_dusseldorf_dussdeddxxx.js file. A new conditional check is added to determine if a transaction has been booked by the bank. If the _booked parameter is falsy, the method logs a debug message and returns null, preventing the import of unbooked transactions. Comments are included to clarify that unbooked transactions do not provide necessary information for the payee and notes fields. The existing logic for prioritizing remittance information and setting the creditor name remains unchanged and is executed only for booked transactions. Additionally, the method's handling of remittance information is updated to use an array, filtering out falsy values before joining them into a string.

Possibly related PRs

Suggested labels

sparkles: Merged

Suggested reviewers

  • UnderKoen

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: 1

🧹 Nitpick comments (2)
src/app-gocardless/banks/ssk_dusseldorf_dussdeddxxx.js (2)

10-16: LGTM! Consider adding debug logging.

The implementation effectively addresses the issue with unbooked transactions containing placeholder text. The comments clearly explain the rationale.

Consider adding debug logging when skipping unbooked transactions to aid troubleshooting:

    if (!_booked) {
+     console.debug('Skipping unbooked transaction:', transaction.id);
      return null;
    }

Line range hint 26-29: Improve string concatenation logic.

When concatenating additionalInformation, the current code adds a leading space even when remittanceInformationUnstructured is null. Consider using string trimming to avoid unnecessary spaces.

     if (transaction.additionalInformation)
       remittanceInformationUnstructured =
-        (remittanceInformationUnstructured ?? '') +
-        ' ' +
-        transaction.additionalInformation;
+        [remittanceInformationUnstructured, transaction.additionalInformation]
+          .filter(Boolean)
+          .join(' ');
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 45d53ff and 6fe19b1.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/553.md is excluded by !**/*.md
📒 Files selected for processing (1)
  • src/app-gocardless/banks/ssk_dusseldorf_dussdeddxxx.js (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build Docker image (alpine)
  • GitHub Check: Build Docker image (ubuntu)

src/app-gocardless/banks/ssk_dusseldorf_dussdeddxxx.js 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: 2

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

15-15: Fix typo in test data.

There's a typo in aditional which should be additional.

-    additionalInformation: 'some aditional information',
+    additionalInformation: 'some additional information',
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6fe19b1 and 847f456.

📒 Files selected for processing (2)
  • src/app-gocardless/banks/ssk_dusseldorf_dussdeddxxx.js (1 hunks)
  • src/app-gocardless/banks/tests/ssk_dusseldorf_dussdeddxxx.spec.js (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Test
src/app-gocardless/banks/ssk_dusseldorf_dussdeddxxx.js

[warning] 24-37: Code coverage warning: Branch coverage is only 70%. Consider adding more test cases to cover all code branches.

src/app-gocardless/banks/tests/ssk_dusseldorf_dussdeddxxx.spec.js

[error] 48-48: Test failure: Expected payeeName to be 'a useful creditor name' but received 'A Useful Creditor Name'. Case sensitivity mismatch in creditor name normalization.

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build Docker image (alpine)
  • GitHub Check: Build Docker image (ubuntu)
🔇 Additional comments (2)
src/app-gocardless/banks/ssk_dusseldorf_dussdeddxxx.js (2)

10-20: LGTM! Well-documented unbooked transaction handling.

The implementation aligns perfectly with the PR objectives. The comments clearly explain why unbooked transactions are skipped, which helps future maintainers understand the rationale.


29-34: Consider adding test cases for empty additionalInformation.

The .filter(Boolean) handles falsy values well, but the branch coverage warning suggests we need more test cases.

Add test cases for:

  • When additionalInformation is an empty string
  • When additionalInformation is undefined
  • When both remittanceInformationUnstructured and additionalInformation are empty
it('handles empty additional information', () => {
  const emptyAdditionalInfo = { ...bookedTransactionOne, additionalInformation: '' };
  const undefinedAdditionalInfo = { ...bookedTransactionOne, additionalInformation: undefined };
  const allEmpty = {
    ...bookedTransactionOne,
    remittanceInformationUnstructured: '',
    additionalInformation: ''
  };
  
  // Add assertions for each case
});
✅ Verification successful

The review comment is valid - test coverage can be improved

  • Examined test file src/app-gocardless/banks/tests/ssk_dusseldorf_dussdeddxxx.spec.js
  • Confirmed no existing test cases for empty/undefined additionalInformation scenarios
  • The suggested test cases would improve edge case coverage while matching the existing test style
🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Find test files related to ssk_dusseldorf_dussdeddxxx
fd "ssk_dusseldorf_dussdeddxxx\.(test|spec)\.js$" || fd "__tests__.*ssk_dusseldorf_dussdeddxxx\.js$"

# If test file exists, check its content for existing test cases
rg -l "ssk_dusseldorf_dussdeddxxx" --type js | xargs rg -A 10 "it\(.*additionalInformation.*\)" || true

Length of output: 220


Script:

#!/bin/bash
# Get the content of the test file
cat src/app-gocardless/banks/tests/ssk_dusseldorf_dussdeddxxx.spec.js

Length of output: 2379

Comment on lines 67 to 71
it('returns null for unbooked transactions', () => {
expect(
SskDusseldorfDussdeddxxx.normalizeTransaction(unbookedTransaction, false),
).toBeNull;
});
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

Fix incorrect assertion method.

The test for unbooked transactions has two issues:

  1. .toBeNull is a matcher function but it's being referenced instead of called
  2. The test doesn't verify the debug log message
-    ).toBeNull;
+    ).toBeNull();
+    expect(console.debug).toHaveBeenCalledWith(
+      'Skipping unbooked transaction:',
+      unbookedTransaction.transactionId
+    );

Add this setup at the beginning of the test:

beforeEach(() => {
  jest.spyOn(console, 'debug').mockImplementation();
});

afterEach(() => {
  jest.restoreAllMocks();
});

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/ssk_dusseldorf_dussdeddxxx.spec.js (2)

15-15: Fix typo in test data.

There's a typo in the additionalInformation field: "aditional" should be "additional".

-    additionalInformation: 'some aditional information',
+    additionalInformation: 'some additional information',

Also applies to: 29-29


56-71: Add test cases for edge scenarios.

To improve test coverage, consider adding the following test cases:

  1. Test with undefined _booked parameter
  2. Test with transaction missing transactionId
it('returns null when _booked parameter is undefined', () => {
  expect(
    SskDusseldorfDussdeddxxx.normalizeTransaction(unbookedTransaction)
  ).toBeNull();
});

it('handles transaction without transactionId gracefully', () => {
  const transactionWithoutId = { ...unbookedTransaction };
  delete transactionWithoutId.transactionId;
  
  expect(
    SskDusseldorfDussdeddxxx.normalizeTransaction(transactionWithoutId, false)
  ).toBeNull();
  expect(console.debug).toHaveBeenCalledWith(
    'Skipping unbooked transaction:',
    undefined
  );
});
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 847f456 and d36d396.

📒 Files selected for processing (1)
  • src/app-gocardless/banks/tests/ssk_dusseldorf_dussdeddxxx.spec.js (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build Docker image (alpine)
  • GitHub Check: Build Docker image (ubuntu)
🔇 Additional comments (1)
src/app-gocardless/banks/tests/ssk_dusseldorf_dussdeddxxx.spec.js (1)

67-71: Fix incorrect assertion and add debug log verification.

The test for unbooked transactions needs two fixes:

  1. .toBeNull is a matcher function but it's being referenced instead of called
  2. The test should verify the debug log message
+  beforeEach(() => {
+    jest.spyOn(console, 'debug').mockImplementation();
+  });
+
+  afterEach(() => {
+    jest.restoreAllMocks();
+  });
+
   it('returns null for unbooked transactions', () => {
     expect(
       SskDusseldorfDussdeddxxx.normalizeTransaction(unbookedTransaction, false),
-    ).toBeNull;
+    ).toBeNull();
+    expect(console.debug).toHaveBeenCalledWith(
+      'Skipping unbooked transaction:',
+      unbookedTransaction.transactionId
+    );
   });

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.

1 participant