diff --git a/app/apps/investments/services.py b/app/apps/investments/services.py index 45d411b4..e2dbca10 100644 --- a/app/apps/investments/services.py +++ b/app/apps/investments/services.py @@ -373,8 +373,10 @@ def summarize(performances, convert=False): "has_rate_history": True, "flows": [], "as_of": perf.as_of, + "holdings": [], }, ) + total["holdings"].append(perf) for key in ("cost_basis", "total_return", "income", "currency_effect"): total[key] += figures[key] total["has_rate_history"] &= figures.get("has_rate_history", True) @@ -388,4 +390,13 @@ def summarize(performances, convert=False): total["money_weighted"] = money_weighted_return( total["flows"], total["market_value"], total["as_of"] ) + # The same holdings in their own currencies, for a converted total + total["breakdown"] = ( + sorted( + summarize(total["holdings"]), + key=lambda part: part["currency"] != total["currency"], + ) + if total["converted_from"] + else [] + ) return list(totals.values()) diff --git a/app/templates/investments/fragments/_totals.html b/app/templates/investments/fragments/_totals.html index 4592309c..8dbdbfa1 100644 --- a/app/templates/investments/fragments/_totals.html +++ b/app/templates/investments/fragments/_totals.html @@ -4,16 +4,15 @@