Context
Spanish tax law allows losses in the "base del ahorro" to be offset against gains for up to 4 subsequent years (LIRPF Art. 49). Additionally, losses can offset up to 25% of dividends/interest income in the same category.
Currently, DeclaRenta calculates each year independently. Users who had net losses in prior years don't see how much they can carry forward or how it reduces their current-year tax.
How it works (LIRPF Art. 49)
- Same-year offset: Losses offset gains within the same year
- Cross-category (25% rule): If net capital gains are negative, up to 25% of the positive "rendimientos del capital mobiliario" (dividends + interest) can be offset
- Carryforward: Remaining uncompensated losses carry to the next 4 years
- Order: Oldest losses are consumed first (FIFO)
Example
| Year |
Gains |
Losses |
Dividends |
Net loss CF |
Tax base |
| 2021 |
2,000 |
-8,000 |
1,000 |
-5,750 |
0 |
| 2022 |
3,000 |
-500 |
800 |
-3,450 |
0 |
| 2023 |
10,000 |
-1,000 |
1,200 |
0 |
5,250 |
| 2024 |
5,000 |
0 |
600 |
0 |
5,600 |
Year 2021: Net G/L = -6,000. Offset 25% of dividends = 250. Remaining CF = -5,750.
Year 2022: Net G/L = +2,500. Consume 2,500 from CF. Also offset 25% of 800 = 200. Remaining CF = -3,050.
...etc.
Proposed implementation
1. Loss carryforward storage
interface LossCarryforward {
year: number; // year the loss originated
originalAmount: number; // original uncompensated loss
remaining: number; // amount still available
expiresYear: number; // year + 4
}
Store in localStorage alongside year comparison data.
2. Input methods
- Automatic: If the user has processed years 2021-2024, calculate carryforward chain automatically
- Manual: For users who only process the current year, allow manual input of prior-year pending losses (Casilla 0460 from previous declarations)
3. Results integration
Add a "Compensación de pérdidas" card in results:
Net capital gains 2024: 8,500.00 EUR
Pending losses from 2022: -3,050.00 EUR (applied)
Pending losses from 2023: 0.00 EUR
─────────────────────────────────────
Taxable base (ahorro): 5,450.00 EUR
4. Cross-category offset display
Show the 25% dividend offset when applicable:
Net capital gains: -2,000.00 EUR
Dividends: 4,800.00 EUR
25% offset applied: -1,200.00 EUR (from dividends)
Remaining loss CF: -800.00 EUR (to 2025-2028)
5. Casillas mapping
- Casilla 0460: Base imponible del ahorro negativa pendiente de años anteriores
- Casilla 0462: Saldo neto negativo de ganancias y pérdidas a integrar en la base imponible del ahorro
Deadline awareness
- Losses expire after 4 years
- Show a warning: "Tienes -2,300 EUR de pérdidas de 2021 que expiran este año"
Complexity
Medium — the logic is straightforward but the UX needs careful design to not overwhelm casual users. Keep it collapsible / progressive disclosure.
References
- LIRPF Art. 49 (compensaciĂłn de rentas)
- LIRPF Art. 49.1.b (25% cross-category offset)
- Casillas 0460, 0462 del Modelo 100
Context
Spanish tax law allows losses in the "base del ahorro" to be offset against gains for up to 4 subsequent years (LIRPF Art. 49). Additionally, losses can offset up to 25% of dividends/interest income in the same category.
Currently, DeclaRenta calculates each year independently. Users who had net losses in prior years don't see how much they can carry forward or how it reduces their current-year tax.
How it works (LIRPF Art. 49)
Example
Year 2021: Net G/L = -6,000. Offset 25% of dividends = 250. Remaining CF = -5,750.
Year 2022: Net G/L = +2,500. Consume 2,500 from CF. Also offset 25% of 800 = 200. Remaining CF = -3,050.
...etc.
Proposed implementation
1. Loss carryforward storage
Store in localStorage alongside year comparison data.
2. Input methods
3. Results integration
Add a "Compensación de pérdidas" card in results:
4. Cross-category offset display
Show the 25% dividend offset when applicable:
5. Casillas mapping
Deadline awareness
Complexity
Medium — the logic is straightforward but the UX needs careful design to not overwhelm casual users. Keep it collapsible / progressive disclosure.
References