Skip to content

fix(trade-republic): declare foreign dividends at the euros TR credits, as the DGT allows (#476) - #477

Merged
GeiserX merged 2 commits into
mainfrom
fix/476-tr-dividend-credited-eur
Nov 25, 2026
Merged

GeiserX merged 2 commits into
mainfrom
fix/476-tr-dividend-credited-eur

Conversation

@GeiserX

@GeiserX GeiserX commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Trade Republic credits foreign dividends already converted to euros. Box 0029 still took original_amount × the ECB rate, while 0588 took TR's own euro withholding. The two boxes used different bases, and neither matched the user's statement.

DGT consulta V5732-26 (2 October 2026) covers this case. A dividend paid already converted into euros, because the taxpayer has no account in that currency, needs no official rate: you declare the euros. A converted TR dividend is now booked at the gross EUR amount (original_amount × fx_rate). The net credit (amount + tax) is never used. The ECB rate on original_amount stays only as the fallback when amount is empty, unreadable or 0.

In real exports TR's fx_rate is the ECB rate of the business day before payment, with no margin. So the change is one day of EUR/USD movement, in either direction.

Not done here: after the move to the Spanish branch, the tax cell may hold the Spanish 19% next to the foreign withholding, which would belong in 0596. We have no real row to confirm it, and #476 asks the reporter for one.

Tests: the full suite passes (7243). With the old parser, the two new assertions fail. CLAUDE.md, docs/casillas.md and docs/brokers.md carry the rule.

Fixes #476

Summary by CodeRabbit

  • Bug Fixes

    • Trade Republic dividends now use the readable, nonzero euro amount credited by the broker as gross income, with withholding reported separately.
    • When that euro amount is missing, unreadable, or zero, dividends continue to be valued using the original amount and the ECB rate for the payment date.
  • Documentation

    • Updated guidance on reporting broker-converted euro amounts and foreign-currency dividends.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

Trade Republic dividend rows now use a readable, nonzero account-currency amount when available. Otherwise, the parser retains the original-currency amount and broker-conversion flag. Documentation and tests reflect the booking rule, tax handling, and fallback.

Changes: Trade Republic dividend booking

Layer / File(s) Summary
Dividend valuation rule
CLAUDE.md, docs/brokers.md, docs/casillas.md
Documentation describes using the reported gross euro amount without ECB conversion when available. It describes ECB valuation of the original-currency amount as the fallback.
Amount selection and transaction output
src/parsers/trade-republic.ts, tests/parsers/trade-republic.test.ts
The parser selects a readable, nonzero account-currency amount when available. Otherwise, it uses the original-currency amount and marks the dividend as broker-converted. Parser tests cover both paths.
Integration and fixture expectations
tests/integration/tr-foreign-dividend-e2e.test.ts, tests/integration/trade-republic-rows-e2e.test.ts, tests/parsers/fixtures.test.ts
Tests expect credited euro amounts and retain withholding assertions. Integration tests also cover reversals and mismatched signs.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Low

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@codecov

codecov Bot commented Nov 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.52%. Comparing base (24d669e) to head (04720cc).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #477   +/-   ##
=======================================
  Coverage   95.52%   95.52%           
=======================================
  Files          66       66           
  Lines       11165    11169    +4     
  Branches     4257     4261    +4     
=======================================
+ Hits        10665    10669    +4     
  Misses        402      402           
  Partials       98       98           
Files with missing lines Coverage Δ
src/parsers/trade-republic.ts 98.06% <100.00%> (+0.03%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@GeiserX
GeiserX merged commit 25c33ff into main Nov 25, 2026
7 of 8 checks passed
@GeiserX
GeiserX deleted the fix/476-tr-dividend-credited-eur branch November 25, 2026 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dividendos de Trade Republic abonados en euros: ¿importe abonado o original_amount × BCE?

1 participant