Repository navigation
fix(revolut): keep stock tickers like META out of crypto and stop dropping dividends and splits - #371
Conversation
…pping dividends and splits META, U, S, W, M, BILL and eleven other US tickers were also in the CoinGecko coin list, so a Revolut stock trade in them was classed CRYPTO: the sale went to the "otros elementos" block instead of listed shares, and the holding counted for Modelo 721 instead of 720/D-6. They are now in the generator's stock-ticker conflict list and out of the generated set. In the transaction log, DIVIDEND rows (empty quantity) and STOCK SPLIT rows (zero amount) were skipped before any type check, with no warning. Dividends now become Dividends cash rows with a note that Revolut reports them net. A split becomes an FS/RS corporate action sized from the holding built up in the file, and the FIFO engine now applies an ISIN-less split to the symbol-keyed lots, as wash-sale already did. Any other ticker row is counted in the unknown-type warning whatever its amount.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 46 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configurationConfiguration used: Repository: GeiserX/DeclaRenta/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (12)
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. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #371 +/- ##
==========================================
+ Coverage 92.40% 92.55% +0.15%
==========================================
Files 56 56
Lines 6409 6502 +93
Branches 2168 2205 +37
==========================================
+ Hits 5922 6018 +96
+ Misses 407 406 -1
+ Partials 80 78 -2
🚀 New features to boost your workflow:
|
A Revolut STOCK SPLIT row gives only the shares added. The parser sized the ratio from the holding inside its own file, but yearly exports are parsed one by one and merged, and FIFO then applied that ratio to every lot of the symbol. With 5 shares bought in the 2023 file and 1 in the 2024 file, +54 became 55-for-1 instead of 10-for-1 and a sale of 60 was costed at 436.36 instead of 2700, with no warning. The parser now carries the signed quantity on the corporate action. The FIFO engine sizes the ratio at split time from the lots it holds under that key, (held + added) / held, across all merged files, and warns (fifo.split_unresolved) when it holds nothing. wash-sale.ts takes the ratio FIFO applied, so the anti-churning cap stays in the same share units. Revolut's own entity-transfer rows are skipped quietly.
…t of crypto so they keep their pre-sale anti-churning block CVX, STX, ADI, BDX and CFG are S&P 500 tickers that are also CoinGecko coin symbols, so a Revolut row in them was typed CRYPTO. With crypto now on the art. 33.5.e window (only the year after the sale), a held buy before a loss sale no longer blocked the loss of these listed shares, which letter f covers (2 months before or after). They join the generator's stock-ticker conflict list and leave the generated set, as META and the others did in #371.
Problem
A Revolut user who traded META got it treated as a crypto-asset. So did U (Unity), S, W, M, H, BILL, AMP, TEL, BIO, IP, VVV, BEAM, MET, GT, LIT and CASH. All of them are also coin symbols in the CoinGecko list the parser uses to spot crypto. The sale went to the "otros elementos" block (1633/1637) instead of listed shares (0328/0331). An open position counted for Modelo 721 and dropped out of 720 and D-6.
The transaction log also lost two kinds of row without a word. A
DIVIDENDrow has an empty Quantity and aSTOCK SPLITrow has a zero amount. The parser skipped every row with no quantity before it looked at the type, and it only warned about unknown rows that had an amount. So dividends never reached 0029. After a split, the later sale found only the pre-split shares, raised "lotes insuficientes" and booked the rest at zero cost, which overstates the gain.Fix
STOCK_TICKER_CONFLICTSinscripts/update-crypto-symbols.ts, and I took them out ofsrc/parsers/crypto-symbols.ts. I removed them by hand from the existing snapshot rather than refetching CoinGecko, so this diff doesn't also churn the rest of the list. The next run of the script gives the same result. BTC, ETH and the other real coins are still CRYPTO.DIVIDENDrow becomes aDividendscash transaction. Revolut reports it net of withholding with no separate withholding row, so an info message tells the user to take the gross amount and the tax withheld from Revolut's annual tax report for 0029 and 0588.STOCK SPLITrow becomes an FS or RS corporate action that carries the shares added (negative for a reverse split). The parser does not size the ratio. Yearly exports are parsed one file at a time and then merged, so one file's holding can be only part of the position. The FIFO engine sizes it at the split date from the lots it holds for that symbol across every file: (held + added) / held. It then rescales the lots and each lot keeps its full cost (Art. 37.1.a LIRPF). If it holds nothing, the split is not applied andfifo.split_unresolvedwarns, in all five locales. A row with no quantity at all gets the parser'srevolut.split_unresolvedwarning.wash-sale.tsuses the ratio FIFO applied, so the anti-churning cap and the deferred-loss release compare shares in the same units after the split.wash-sale.tsuses. Actions that carry an ISIN or a "SPLIT n FOR d" ratio work as before.Regression tests
The new tests are in
tests/parsers/revolut.test.ts. Run against main, 27 of the 114 fail:Two yearly files show why the parser can't size the split. The 2023 file buys 5 NVDA for USD 2000. The 2024 file buys 1 for USD 700, then has STOCK SPLIT +54 and SELL 60. Sizing from the 2024 file alone gave 55-for-1 and a cost of 436.36 with no warning. Now the engine sizes it from the lots of both files: 10-for-1, cost 2700. The first version of this branch failed five of the new tests:
All 114 pass now. One test covers the anti-churning cap across a split: 10 bought in January, 1 in February, a 10-for-1 split, then a loss sale of 100. It defers 50 of the 500 loss. If I stop passing FIFO's ratios to
detectWashSales, it fails withexpected '0.00' to be '50.00'.Also run: the FIFO, corporate-action, wash-sale, report, merge and i18n test files (337 tests pass),
tsc --noEmitand eslint on the changed files.