Skip to content

Conversation

@quentinreytinas
Copy link

@quentinreytinas quentinreytinas commented Jan 17, 2026

Why:
With Wise (France), the counterparty is often a technical CARD-xxxx token; this hides the human-readable label and makes lists harder to scan.

What
Skip counterparty values matching /\ACARD-\d+\z/i when building the name.
Preserve existing priority order (counterparty → bank_transaction_code → remittance).
Add a test covering CARD-* fallback behavior.

Scope:
EnableBanking only.

Validation:
Added unit test: processor_test.rb

Summary by CodeRabbit

  • Bug Fixes

    • Transaction naming now ignores technical card identifiers (e.g., CARD-1234) and falls back to the bank transaction description for clearer names.
  • Tests

    • Added unit tests to verify selection between human-readable counterparties and fallback to transaction descriptions when counterparties are technical identifiers.

✏️ Tip: You can customize this high-level summary in your review settings.

@dosubot
Copy link

dosubot bot commented Jan 17, 2026

Related Documentation

Checked 1 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@coderabbitai
Copy link

coderabbitai bot commented Jan 17, 2026

📝 Walkthrough

Walkthrough

A small logic change in EnableBankingEntry::Processor's name method now treats counterparty values matching the CARD-\d+ pattern as technical and falls back to the bank transaction code description; unit tests were added to verify both the technical-card fallback and normal human-readable counterparty behavior.

Changes

Cohort / File(s) Change Summary
Processor Logic
app/models/enable_banking_entry/processor.rb
Early-return guard updated to ignore counterparty values matching CARD-\d+, allowing fallback to the bank transaction code description
Unit Tests
test/models/enable_banking_entry/processor_test.rb
Added EnableBankingEntry::ProcessorTest with build_name helper and two tests: one ensuring CARD-1234 is skipped in favor of bank description, another confirming a human-readable counterparty is used

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I saw a CARD-1234 hop in the night,
Numbers too tidy, not quite a delight.
I nudged it aside for the bank's plain tale,
While "ACME SHOP" stays bold on the trail.
Tests nibble carrots to ensure it’s right. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: skipping CARD-* pattern counterparty values in the EnableBanking name logic.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/models/enable_banking_entry/processor.rb (1)

77-83: Guard the CARD- regex against non-String counterparties.*

match? will raise if counterparty is present but not a String. A small guard keeps the new behavior while preventing a potential NoMethodError.

💡 Proposed fix
-      return counterparty if counterparty.present? && !counterparty.match?(/\ACARD-\d+\z/i)
+      if counterparty.present?
+        return counterparty unless counterparty.is_a?(String) && counterparty.match?(/\ACARD-\d+\z/i)
+      end
🧹 Nitpick comments (1)
test/models/enable_banking_entry/processor_test.rb (1)

4-6: Prefer OpenStruct over Object.new for test doubles.

Test guidelines recommend OpenStruct for mocks; it’s clearer and aligns with project conventions.

♻️ Proposed tweak
+require "ostruct"
 
 def build_name(data)
-  processor = EnableBankingEntry::Processor.new(data, enable_banking_account: Object.new)
+  processor = EnableBankingEntry::Processor.new(data, enable_banking_account: OpenStruct.new)
   processor.send(:name)
 end

Whitespace added before 'ACME SHOP' in remittance_information.

Signed-off-by: Juan José Mata <jjmata@jjmata.com>
@jjmata jjmata requested a review from sokie January 17, 2026 17:02
@jjmata jjmata added this to the v0.6.7 milestone Jan 17, 2026
@jjmata jjmata requested a review from alessiocappa January 17, 2026 17:03
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

end

return counterparty if counterparty.present?
return counterparty if counterparty.present? && !counterparty.match?(/\ACARD-\d+\z/i)
Copy link

Choose a reason for hiding this comment

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

CARD-* filter missing from merchant method creates inconsistency

Medium Severity

The name method now skips CARD-* technical identifiers, but the merchant method uses identical counterparty extraction logic without this filter. When a counterparty is "CARD-1234", the transaction gets a readable name (from fallback) but still creates/links a merchant named "CARD-1234". This inconsistency partially defeats the PR's goal of improving readability since merchant lists will still contain technical identifiers.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thoughts on this PR comment @quentinreytinas?

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

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants