Files
sure/app/models
LPW bf9bcae600 Add gains by tax treatment to investment report with grouped subtype dropdown (#701)
* Add tax treatment metrics to reports, forms, and models

- Implement `build_gains_by_tax_treatment` for grouping gains by tax treatment
- Update investment performance view with tax treatment breakdown
- Add tax treatment field to crypto and investments forms
- Introduce `realized_gain_loss` calculation in the Trade model
- Group investment subtypes by region for improved dropdown organization

* Optimize investment performance report by reducing N+1 queries

- Eager-load associations in `build_gains_by_tax_treatment` to minimize database queries
- Preload holdings for realized gain/loss calculations in trades
- Refactor views to standardize "no data" placeholder using translations
- Adjust styling in tax treatment breakdown for improved layout

* Enhance investment performance translations and optimize holdings lookup logic

- Update `holdings_count` and `sells_count` translations to handle pluralization
- Refactor views to use pluralized translation keys with count interpolation
- Optimize preloaded holdings lookup in `Trade` to ensure deterministic selection using `select` and `max_by`

* Refine preloaded holdings logic in `Trade` model

- Treat empty preloaded holdings as authoritative to prevent unnecessary DB queries
- Add explicit fallback behavior for database query when holdings are not preloaded

---------

Co-authored-by: luckyPipewrench <luckypipewrench@proton.me>
2026-01-19 15:44:49 +01:00
..
2025-03-28 13:08:22 -04:00
2025-12-07 18:11:34 +01:00
2025-11-24 17:54:18 +01:00
2026-01-09 19:38:04 +01:00
2025-11-27 15:24:34 +01:00
2026-01-09 19:38:04 +01:00
2026-01-13 16:46:07 +01:00
2024-02-02 09:05:04 -06:00
2024-10-18 11:26:58 -05:00
2026-01-15 17:00:32 +01:00
2026-01-15 13:14:10 +01:00
2024-10-18 11:26:58 -05:00
2026-01-13 13:51:10 +01:00
2024-11-08 09:58:35 -06:00
2024-08-23 10:06:24 -04:00
2025-05-23 18:58:22 -04:00
2025-11-25 20:21:29 +01:00
2024-08-23 09:33:42 -04:00
2025-11-01 09:12:42 +01:00
2025-10-28 19:32:27 +01:00
2025-11-22 02:14:29 +01:00
2026-01-08 15:20:14 +01:00
2026-01-09 19:38:04 +01:00
2026-01-12 15:05:28 +01:00
2025-11-25 20:21:29 +01:00
2024-05-23 08:09:33 -04:00
2025-03-28 13:08:22 -04:00