From ffdd5310941941091dbd5a8550c4ecd594410132 Mon Sep 17 00:00:00 2001 From: 31b4 Date: Mon, 19 Oct 2026 12:50:14 +0200 Subject: [PATCH 01/21] Show gain on net invested in portfolio summary --- CHANGELOG.md | 2 ++ .../PortfolioSummary.test.tsx | 35 +++++++++++++++++++ .../investments-module/PortfolioSummary.tsx | 10 ++++-- docs/investment-metrics.md | 2 +- docs/investment-overview.md | 2 +- 5 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 client/src/components/investments-module/PortfolioSummary.test.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index 04a83ca..3ddc280 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ Intermediate package/UI version bumps are grouped under the next published GitHu ### Fixed +- Investment summary replaces the unavailable lifetime-return label with a clearly named Gain on net invested percentage when known and positive net invested supports the ratio. Daily-linked chart/Today returns retain their existing method (#171). + - Main/investment-epic integration preserves both existing 017 migration filenames, transaction split exports/history and direct investment trade paths. Split mutations share guarded decimal cash arithmetic so concurrent trades, pending confirmation and fractional payments retain exact balances (#169). - Investment price returns explicitly exclude dividends. Dividend events no longer block known purchase costs, gains or history or trigger misleading purchase-review warnings; split and missing-history safeguards remain (#161). diff --git a/client/src/components/investments-module/PortfolioSummary.test.tsx b/client/src/components/investments-module/PortfolioSummary.test.tsx new file mode 100644 index 0000000..2d5e010 --- /dev/null +++ b/client/src/components/investments-module/PortfolioSummary.test.tsx @@ -0,0 +1,35 @@ +import {cleanup,render,screen,within} from '@testing-library/react' +import {afterEach,expect,it} from 'vitest' +import {portfolioMetrics} from '../../../../shared/investment-metrics' +import type {CurrencyMetrics} from '../../../../shared/investment-metrics' +import {PortfolioSummary} from './PortfolioSummary' + +const metrics=(gain:number|null,invested:number|null):CurrencyMetrics=>({ + ...portfolioMetrics([]),currency:'HUF',total_gain:gain,total_invested:invested, + market_today:{gain:10,estimated_return_percent:1,currency:'HUF',date:'2026-10-19',prior_date:'2026-10-18', + covered_holdings:1,total_holdings:1,excluded:[],method:'daily_linked_estimate',boundary:'Daily closes'}, +}) +const total=()=>within(screen.getByRole('heading',{name:'Total gain'}).parentElement!) +afterEach(cleanup) + +it.each([[-100,-10],[100,10],[0,0]])('shows gain % on net invested without substituting the daily-linked estimate (%s)',(gain,percent)=>{ + render(