mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-11-27 19:02:54 +01:00
Merge pull request #658 from eitchtee/feat/investments-redesign
feat(investments): calmer list and detail pages
This commit is contained in:
8 files changed
+251
-247
No files matched your search
@@ -5,6 +5,11 @@ from . import views
|
||||
urlpatterns = [
|
||||
path("investments/", views.investments_index, name="investments_index"),
|
||||
path("investments/list/", views.investments_list, name="investments_list"),
|
||||
path(
|
||||
"investments/group-by/",
|
||||
views.investments_group_by,
|
||||
name="investments_group_by",
|
||||
),
|
||||
path("investments/charts/", views.investments_charts, name="investments_charts"),
|
||||
path(
|
||||
"investments/rebalance/",
|
||||
|
||||
@@ -25,7 +25,7 @@ from apps.transactions.models import Transaction
|
||||
|
||||
def _holdings():
|
||||
return Account.objects.filter(is_investment=True, is_archived=False).select_related(
|
||||
"group", "currency", "exchange_currency"
|
||||
"group", "investment_class", "currency", "exchange_currency"
|
||||
)
|
||||
|
||||
|
||||
@@ -34,31 +34,47 @@ def investments_index(request):
|
||||
return render(request, "investments/pages/index.html")
|
||||
|
||||
|
||||
GROUP_BY = ("group", "investment_class")
|
||||
|
||||
|
||||
def _grouped(performances, attr):
|
||||
groups = {}
|
||||
for perf in performances:
|
||||
group = getattr(perf.account, attr)
|
||||
groups.setdefault(group.id if group else None, (group, []))[1].append(perf)
|
||||
return [
|
||||
{"group": group, "holdings": items, "totals": summarize(items)}
|
||||
for group, items in sorted(
|
||||
groups.values(), key=lambda g: (g[0] is None, g[0] and g[0].name)
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
@only_htmx
|
||||
@login_required
|
||||
def investments_list(request):
|
||||
performances = [get_holding_performance(account) for account in _holdings()]
|
||||
|
||||
groups = {}
|
||||
for perf in performances:
|
||||
group = perf.account.group
|
||||
groups.setdefault(group.id if group else None, (group, []))[1].append(perf)
|
||||
|
||||
# Both groupings are rendered so the toggle flips client-side without recomputing
|
||||
return render(
|
||||
request,
|
||||
"investments/fragments/list.html",
|
||||
{
|
||||
"groups": [
|
||||
{"group": group, "holdings": items, "totals": summarize(items)}
|
||||
for group, items in sorted(
|
||||
groups.values(), key=lambda g: (g[0] is None, g[0] and g[0].name)
|
||||
)
|
||||
],
|
||||
"groupings": [(attr, _grouped(performances, attr)) for attr in GROUP_BY],
|
||||
"totals": summarize(performances, convert=True),
|
||||
"group_by": request.session.get("investments_group_by", "group"),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@only_htmx
|
||||
@login_required
|
||||
def investments_group_by(request):
|
||||
if request.GET.get("group_by") in GROUP_BY:
|
||||
request.session["investments_group_by"] = request.GET["group_by"]
|
||||
return HttpResponse(status=204)
|
||||
|
||||
|
||||
def _money(currency):
|
||||
"""What chartMoney (charts.js) needs to format amounts like the rest of the app."""
|
||||
return {
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
<span class="size-2.5 rounded-full shrink-0" style="background: {{ share.color }}"></span>
|
||||
<span class="truncate">{{ share.name }}</span>
|
||||
{% if share.plan.off %}
|
||||
<i class="fa-solid fa-triangle-exclamation text-warning text-xs"
|
||||
data-tippy-content="{% blocktranslate with share=share.plan.share|floatformat:1 target=share.plan.target|floatformat:'-2' %}{{ share }}% of your investments with a target, against a target of {{ target }}%{% endblocktranslate %}"></i>
|
||||
<span class="text-xs text-warning whitespace-nowrap">{% blocktranslate with target=share.plan.target|floatformat:'-2' %}target {{ target }}%{% endblocktranslate %}</span>
|
||||
{% endif %}
|
||||
<span class="ms-auto tabular-nums text-base-content/60">{{ share.share|floatformat:1 }}%</span>
|
||||
<span class="w-28 text-end tabular-nums whitespace-nowrap"><c-amount.display :amount="share.amount" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display></span>
|
||||
|
||||
@@ -1 +1 @@
|
||||
{% load i18n %}{% if mw %}<span class="whitespace-nowrap" data-tippy-content="{% if mw.annualized %}{% translate 'Annual return, weighted by when money went in and out' %}{% else %}{% translate 'Return since the first contribution, weighted by when money went in and out' %}{% endif %}">{% include 'investments/fragments/_percentage.html' with value=mw.percentage %}{% if mw.annualized %}<span class="text-base-content/50">{% translate '/yr' %}</span>{% endif %}</span>{% endif %}
|
||||
{% load i18n %}{% if mw %}<span class="whitespace-nowrap">{% include 'investments/fragments/_percentage.html' with value=mw.percentage %}{% if mw.annualized %}<span class="text-base-content/50">{% translate '/yr' %}</span>{% endif %}</span>{% endif %}
|
||||
@@ -1,51 +1,56 @@
|
||||
{% load i18n %}
|
||||
{% with c=total.currency %}
|
||||
<div class="card bg-base-100 card-border shadow">
|
||||
<div class="card-body p-5 gap-4">
|
||||
<div class="flex flex-wrap items-end justify-between gap-x-6 gap-y-3">
|
||||
<div>
|
||||
<div class="text-3xl font-bold tabular-nums">
|
||||
<c-amount.display :amount="total.market_value" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sm:text-right">
|
||||
<div class="text-lg tabular-nums flex items-baseline gap-2 sm:justify-end">
|
||||
<c-amount.display :amount="total.total_return" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" color="auto" divless></c-amount.display>
|
||||
<span class="text-sm">{% include 'investments/fragments/_mwr.html' with mw=total.money_weighted %}</span>
|
||||
<span class="text-sm text-base-content/50">{% translate 'total return' %}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body p-5 gap-1">
|
||||
<div class="text-sm text-base-content/50">{% translate 'Portfolio value' %}{% if totals|length > 1 %} · {{ c.name }}{% endif %}</div>
|
||||
<div class="text-3xl sm:text-4xl font-bold tabular-nums tracking-tight whitespace-nowrap">
|
||||
<c-amount.display :amount="total.market_value" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-x-6 gap-y-1 text-sm text-base-content/60">
|
||||
<div>{% translate 'Invested' %} <span class="text-base-content tabular-nums"><c-amount.display :amount="total.cost_basis" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display></span></div>
|
||||
<div>{% translate 'Income' %} <span class="text-base-content tabular-nums"><c-amount.display :amount="total.income" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display></span></div>
|
||||
{% if total.converted_from %}
|
||||
{% if total.has_rate_history %}
|
||||
<div data-tippy-content="{% translate 'How much of the return came from exchange rates moving since you invested' %}">{% translate 'Currency effect' %} <span class="tabular-nums"><c-amount.display :amount="total.currency_effect" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" color="auto" divless></c-amount.display></span></div>
|
||||
{% else %}
|
||||
<div>{% translate 'Currency effect' %} <i class="fa-solid fa-triangle-exclamation text-warning text-xs" data-tippy-content="{% translate 'Every date is converted with the same rate. Add historical exchange rates (or an automatic rate service) to see how much exchange rates moved your return.' %}"></i></div>
|
||||
<div class="text-sm tabular-nums flex flex-wrap items-baseline gap-x-2">
|
||||
<span class="whitespace-nowrap"><c-amount.display :amount="total.total_return" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" color="auto" divless></c-amount.display>
|
||||
{% include 'investments/fragments/_mwr.html' with mw=total.money_weighted %}</span>
|
||||
<span class="text-base-content/50">{% translate 'all time' %}</span>
|
||||
</div>
|
||||
|
||||
{# Secondary figures stay out of sight until asked for #}
|
||||
<details class="group mt-3 text-sm">
|
||||
<summary class="cursor-pointer list-none text-base-content/50 hover:text-base-content transition-colors duration-150 w-fit select-none">
|
||||
{% translate 'Details' %} <i class="fa-solid fa-chevron-down text-xs transition-transform duration-150 group-open:rotate-180"></i>
|
||||
</summary>
|
||||
<dl class="mt-3 flex flex-col divide-y divide-base-content/10 tabular-nums">
|
||||
<div class="flex justify-between gap-4 py-2">
|
||||
<dt class="text-base-content/60 min-w-0">{% translate 'Invested' %}</dt>
|
||||
<dd class="text-end whitespace-nowrap"><c-amount.display :amount="total.cost_basis" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display></dd>
|
||||
</div>
|
||||
<div class="flex justify-between gap-4 py-2">
|
||||
<dt class="text-base-content/60 min-w-0">{% translate 'Income' %}</dt>
|
||||
<dd class="text-end whitespace-nowrap"><c-amount.display :amount="total.income" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display></dd>
|
||||
</div>
|
||||
{% if total.converted_from %}
|
||||
<div class="flex justify-between gap-4 py-2">
|
||||
<dt class="text-base-content/60 min-w-0">{% translate 'Currency effect' %}</dt>
|
||||
<dd class="text-end whitespace-nowrap">
|
||||
{% if total.has_rate_history %}
|
||||
<c-amount.display :amount="total.currency_effect" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" color="auto" divless></c-amount.display>
|
||||
{% else %}
|
||||
<span class="text-base-content/50 whitespace-normal">{% translate 'Needs historical exchange rates' %}</span>
|
||||
{% endif %}
|
||||
</dd>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if total.breakdown %}
|
||||
<div class="flex flex-col gap-1 -mx-2 -mb-2">
|
||||
{% for part in total.breakdown %}
|
||||
{% with p=part.currency %}
|
||||
<details class="collapse collapse-arrow rounded-box">
|
||||
<summary class="collapse-title min-h-0 py-2 px-2 pe-10 text-sm flex items-baseline justify-between gap-4">
|
||||
<span class="text-base-content/60">{{ p.name }}</span>
|
||||
<span class="tabular-nums"><c-amount.display :amount="part.market_value" :prefix="p.prefix" :suffix="p.suffix" :decimal_places="p.decimal_places" divless></c-amount.display></span>
|
||||
</summary>
|
||||
<div class="collapse-content px-2 text-sm text-base-content/60 flex flex-wrap gap-x-6 gap-y-1">
|
||||
<div>{% translate 'Return' %} <span class="tabular-nums"><c-amount.display :amount="part.total_return" :prefix="p.prefix" :suffix="p.suffix" :decimal_places="p.decimal_places" color="auto" divless></c-amount.display></span> {% include 'investments/fragments/_mwr.html' with mw=part.money_weighted %}</div>
|
||||
<div>{% translate 'Invested' %} <span class="text-base-content tabular-nums"><c-amount.display :amount="part.cost_basis" :prefix="p.prefix" :suffix="p.suffix" :decimal_places="p.decimal_places" divless></c-amount.display></span></div>
|
||||
<div>{% translate 'Income' %} <span class="text-base-content tabular-nums"><c-amount.display :amount="part.income" :prefix="p.prefix" :suffix="p.suffix" :decimal_places="p.decimal_places" divless></c-amount.display></span></div>
|
||||
</div>
|
||||
</details>
|
||||
<div class="flex justify-between gap-4 py-2">
|
||||
<dt class="text-base-content/60 min-w-0">{% blocktranslate with name=p.name %}In {{ name }}{% endblocktranslate %}</dt>
|
||||
<dd class="flex items-baseline gap-2 whitespace-nowrap">
|
||||
<c-amount.display :amount="part.market_value" :prefix="p.prefix" :suffix="p.suffix" :decimal_places="p.decimal_places" divless></c-amount.display>
|
||||
<span class="text-xs">{% include 'investments/fragments/_mwr.html' with mw=part.money_weighted %}</span>
|
||||
</dd>
|
||||
</div>
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</dl>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
{% endwith %}
|
||||
@@ -31,69 +31,34 @@
|
||||
{% endif %}
|
||||
</c-components.fab>
|
||||
<div class="container pb-20">
|
||||
<div class="flex flex-wrap justify-between items-start gap-3 mb-4">
|
||||
<div class="min-w-0">
|
||||
<div class="text-3xl font-bold font-mono flex items-center gap-2">
|
||||
<a href="{% url 'investments_index' %}" hx-boost="true" class="no-underline text-base-content/40 hover:text-base-content transition-colors duration-150" aria-label="{% translate 'Investments' %}"><i class="fa-solid fa-arrow-left fa-fw text-lg"></i></a>
|
||||
<span class="truncate">{{ account.name }}</span>
|
||||
<button class="btn btn-ghost btn-sm btn-square text-base-content/40 hover:text-base-content"
|
||||
aria-label="{% translate 'Edit account' %}" data-tippy-content="{% translate 'Edit account' %}"
|
||||
hx-get="{% url 'account_edit' pk=account.id %}" hx-target="#generic-offcanvas">
|
||||
<i class="fa-solid fa-pencil text-base"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="text-sm text-base-content/60 mt-1">
|
||||
{% if account.group %}{{ account.group.name }} · {% endif %}
|
||||
{% if perf.priced %}{{ a.name }} → {{ c.name }}{% else %}{% translate 'Tracked by value' %}{% endif %}
|
||||
{% if perf.estimated %}<i class="fa-solid fa-circle-exclamation text-warning ml-1" data-tippy-content="{% translate 'Some units moved in or out without a linked payment, so they were valued at the market price of that day' %}"></i>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-2 mb-1">
|
||||
<a href="{% url 'investments_index' %}" hx-boost="true" class="btn btn-ghost btn-sm btn-square text-base-content/50 hover:text-base-content" aria-label="{% translate 'Investments' %}"><i class="fa-solid fa-arrow-left"></i></a>
|
||||
<h1 class="text-2xl font-bold truncate">{{ account.name }}</h1>
|
||||
<button class="btn btn-ghost btn-sm btn-square text-base-content/40 hover:text-base-content"
|
||||
aria-label="{% translate 'Edit account' %}"
|
||||
hx-get="{% url 'account_edit' pk=account.id %}" hx-target="#generic-offcanvas">
|
||||
<i class="fa-solid fa-pencil"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="text-sm text-base-content/50 mb-6 ps-10">
|
||||
{% if account.group %}{{ account.group.name }} · {% endif %}
|
||||
{% if perf.priced %}{{ a.name }} → {{ c.name }}{% else %}{% translate 'Tracked by value' %}{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="card bg-base-100 card-border shadow mb-4">
|
||||
<div class="card-body p-5 gap-5">
|
||||
<div class="flex flex-wrap items-end justify-between gap-x-6 gap-y-3">
|
||||
<div>
|
||||
<div class="text-4xl font-bold tabular-nums">
|
||||
{% if perf.market_value is not None %}<c-amount.display :amount="perf.market_value" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>{% else %}-{% endif %}
|
||||
</div>
|
||||
<div class="text-sm tabular-nums mt-1 flex items-baseline gap-2">
|
||||
<c-amount.display :amount="perf.total_return" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" color="auto" divless></c-amount.display>
|
||||
{% include 'investments/fragments/_mwr.html' with mw=perf.money_weighted %}
|
||||
<span class="text-base-content/50">{% translate 'total return' %}</span>
|
||||
</div>
|
||||
{% if home %}
|
||||
{% with h=home.currency %}
|
||||
<div class="text-sm tabular-nums mt-1 flex flex-wrap items-baseline gap-x-2 text-base-content/60">
|
||||
<span>{% translate 'In' %} {{ h.name }}:</span>
|
||||
<c-amount.display :amount="home.market_value" :prefix="h.prefix" :suffix="h.suffix" :decimal_places="h.decimal_places" divless></c-amount.display>
|
||||
<span>·</span>
|
||||
<c-amount.display :amount="home.total_return" :prefix="h.prefix" :suffix="h.suffix" :decimal_places="h.decimal_places" color="auto" divless></c-amount.display>
|
||||
{% include 'investments/fragments/_mwr.html' with mw=home.money_weighted %}
|
||||
{% if home.has_rate_history %}
|
||||
<span data-tippy-content="{% translate 'How much of the return came from exchange rates moving since you invested' %}">· {% translate 'currency effect' %}
|
||||
<c-amount.display :amount="home.currency_effect" :prefix="h.prefix" :suffix="h.suffix" :decimal_places="h.decimal_places" color="auto" divless></c-amount.display>
|
||||
</span>
|
||||
{% else %}
|
||||
<span>· {% translate 'currency effect' %} <i class="fa-solid fa-triangle-exclamation text-warning text-xs" data-tippy-content="{% translate 'Every date is converted with the same rate. Add historical exchange rates (or an automatic rate service) to see how much exchange rates moved your return.' %}"></i></span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
<div>
|
||||
<div class="text-3xl sm:text-4xl font-bold tabular-nums tracking-tight whitespace-nowrap">
|
||||
{% if perf.market_value is not None %}<c-amount.display :amount="perf.market_value" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>{% else %}-{% endif %}
|
||||
</div>
|
||||
{% if perf.priced %}
|
||||
<div class="sm:text-right text-sm text-base-content/60 tabular-nums">
|
||||
<div><c-amount.display :amount="perf.quantity" :prefix="a.prefix" :suffix="a.suffix" :decimal_places="a.decimal_places" divless></c-amount.display></div>
|
||||
<div>
|
||||
{% if perf.price is not None %}
|
||||
× <c-amount.display :amount="perf.price" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>
|
||||
{% if perf.price_date %}<span class="text-base-content/40"> · {{ perf.price_date|date:"SHORT_DATE_FORMAT" }}</span>{% endif %}
|
||||
{% else %}
|
||||
<span class="text-error">{% translate "No exchange rate available" %}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="text-sm tabular-nums mt-1 flex flex-wrap items-baseline gap-x-2">
|
||||
<span class="whitespace-nowrap"><c-amount.display :amount="perf.total_return" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" color="auto" divless></c-amount.display>
|
||||
{% include 'investments/fragments/_mwr.html' with mw=perf.money_weighted %}</span>
|
||||
<span class="text-base-content/50">{% translate 'all time' %}</span>
|
||||
</div>
|
||||
{% if home %}{% with h=home.currency %}
|
||||
<div class="text-sm tabular-nums mt-1 text-base-content/50">≈ <c-amount.display :amount="home.market_value" :prefix="h.prefix" :suffix="h.suffix" :decimal_places="h.decimal_places" divless></c-amount.display></div>
|
||||
{% endwith %}{% endif %}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@@ -217,69 +182,96 @@
|
||||
}));
|
||||
})();
|
||||
</script>
|
||||
|
||||
<dl class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-x-6 gap-y-4 border-t border-base-content/10 pt-4 text-sm tabular-nums">
|
||||
<div>
|
||||
<dt class="text-xs text-base-content/50">{% translate 'Invested' %}</dt>
|
||||
<dd><c-amount.display :amount="perf.cost_basis" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display></dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-base-content/50">{% if perf.priced %}{% translate 'Average cost' %}{% else %}{% translate 'Put in / taken out' %}{% endif %}</dt>
|
||||
<dd>
|
||||
{% if perf.priced %}
|
||||
{% if perf.average_cost is not None %}<c-amount.display :amount="perf.average_cost" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>{% else %}-{% endif %}
|
||||
{% else %}
|
||||
<c-amount.display :amount="perf.contributed" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>
|
||||
<span class="text-base-content/50">/</span>
|
||||
<c-amount.display :amount="perf.withdrawn" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>
|
||||
{% endif %}
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-base-content/50">{% if perf.priced %}{% translate 'Unrealized' %}{% else %}{% translate 'Earnings' %}{% endif %}</dt>
|
||||
<dd>
|
||||
{% if perf.unrealized is not None %}
|
||||
<c-amount.display :amount="perf.unrealized" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" color="auto" divless></c-amount.display>
|
||||
{% include 'investments/fragments/_percentage.html' with value=perf.unrealized_percentage css="text-xs" %}
|
||||
{% else %}-{% endif %}
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-base-content/50">{% translate 'Realized' %}</dt>
|
||||
<dd><c-amount.display :amount="perf.realized" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" color="auto" divless></c-amount.display></dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-base-content/50">{% translate 'Income' %}{% if income_entities %} · {{ income_entities|join:", " }}{% endif %}</dt>
|
||||
<dd><c-amount.display :amount="perf.income" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" color="auto" divless></c-amount.display></dd>
|
||||
</div>
|
||||
{% if perf.priced %}
|
||||
<div>
|
||||
<dt class="text-xs text-base-content/50">{% translate 'Put in / taken out' %}</dt>
|
||||
<dd>
|
||||
<c-amount.display :amount="perf.contributed" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>
|
||||
<span class="text-base-content/50">/</span>
|
||||
<c-amount.display :amount="perf.withdrawn" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>
|
||||
</dd>
|
||||
</div>
|
||||
{% endif %}
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 {% if income %}xl:grid-cols-3{% endif %} gap-4">
|
||||
<div class="card bg-base-100 card-border shadow {% if income %}xl:col-span-2{% endif %}">
|
||||
<div class="px-5 pt-4 pb-2 font-semibold">{% translate 'Movements' %}</div>
|
||||
{% if transactions %}
|
||||
<div class="overflow-x-auto">
|
||||
<table class="table text-sm">
|
||||
<tbody>
|
||||
{% if perf.estimated %}
|
||||
<div class="text-sm text-base-content/60 mb-4 flex gap-2 items-baseline">
|
||||
<i class="fa-solid fa-circle-info text-warning"></i>
|
||||
<span>{% translate 'Some units moved in or out without a linked payment, so they were valued at the market price of that day.' %}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-3 gap-4 items-start">
|
||||
<div class="flex flex-col gap-4 lg:order-last">
|
||||
<div class="card bg-base-100 card-border shadow">
|
||||
<div class="px-5 pt-4 font-semibold">{% translate 'Your position' %}</div>
|
||||
<dl class="px-5 pb-3 flex flex-col divide-y divide-base-content/10 text-sm tabular-nums">
|
||||
{% if perf.priced %}
|
||||
<div class="flex justify-between items-baseline gap-4 py-2.5">
|
||||
<dt class="text-base-content/60 min-w-0">{% translate 'Units' %}</dt>
|
||||
<dd class="text-end whitespace-nowrap"><c-amount.display :amount="perf.quantity" :prefix="a.prefix" :suffix="a.suffix" :decimal_places="a.decimal_places" divless></c-amount.display></dd>
|
||||
</div>
|
||||
<div class="flex justify-between items-baseline gap-4 py-2.5">
|
||||
<dt class="text-base-content/60 min-w-0">{% translate 'Price' %}</dt>
|
||||
<dd class="text-end whitespace-nowrap">{% if perf.price is not None %}<c-amount.display :amount="perf.price" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>{% if perf.price_date %}<div class="text-xs text-base-content/40">{{ perf.price_date|date:"SHORT_DATE_FORMAT" }}</div>{% endif %}{% else %}<span class="text-error">{% translate "No exchange rate available" %}</span>{% endif %}</dd>
|
||||
</div>
|
||||
<div class="flex justify-between items-baseline gap-4 py-2.5">
|
||||
<dt class="text-base-content/60 min-w-0">{% translate 'Average cost' %}</dt>
|
||||
<dd class="text-end whitespace-nowrap">{% if perf.average_cost is not None %}<c-amount.display :amount="perf.average_cost" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>{% else %}-{% endif %}</dd>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="flex justify-between items-baseline gap-4 py-2.5">
|
||||
<dt class="text-base-content/60 min-w-0">{% translate 'Invested' %}</dt>
|
||||
<dd class="text-end whitespace-nowrap"><c-amount.display :amount="perf.cost_basis" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display></dd>
|
||||
</div>
|
||||
<div class="flex justify-between items-baseline gap-4 py-2.5">
|
||||
<dt class="text-base-content/60 min-w-0">{% if perf.priced %}{% translate 'Unrealized' %}{% else %}{% translate 'Earnings' %}{% endif %}</dt>
|
||||
<dd class="text-end whitespace-nowrap">{% if perf.unrealized is not None %}<c-amount.display :amount="perf.unrealized" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" color="auto" divless></c-amount.display>{% else %}-{% endif %}</dd>
|
||||
</div>
|
||||
<div class="flex justify-between items-baseline gap-4 py-2.5">
|
||||
<dt class="text-base-content/60 min-w-0">{% translate 'Realized' %}</dt>
|
||||
<dd class="text-end whitespace-nowrap"><c-amount.display :amount="perf.realized" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" color="auto" divless></c-amount.display></dd>
|
||||
</div>
|
||||
<div class="flex justify-between items-baseline gap-4 py-2.5">
|
||||
<dt class="text-base-content/60 min-w-0">{% translate 'Income' %}</dt>
|
||||
<dd class="text-end whitespace-nowrap"><c-amount.display :amount="perf.income" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" color="auto" divless></c-amount.display></dd>
|
||||
</div>
|
||||
<div class="flex justify-between items-baseline gap-4 py-2.5">
|
||||
<dt class="text-base-content/60 min-w-0">{% translate 'Put in' %}</dt>
|
||||
<dd class="text-end whitespace-nowrap"><c-amount.display :amount="perf.contributed" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display></dd>
|
||||
</div>
|
||||
<div class="flex justify-between items-baseline gap-4 py-2.5">
|
||||
<dt class="text-base-content/60 min-w-0">{% translate 'Taken out' %}</dt>
|
||||
<dd class="text-end whitespace-nowrap"><c-amount.display :amount="perf.withdrawn" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display></dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
{% if home %}{% with h=home.currency %}
|
||||
<div class="card bg-base-100 card-border shadow">
|
||||
<div class="px-5 pt-4 font-semibold">{% blocktranslate with name=h.name %}In {{ name }}{% endblocktranslate %}</div>
|
||||
<dl class="px-5 pb-3 flex flex-col divide-y divide-base-content/10 text-sm tabular-nums">
|
||||
<div class="flex justify-between items-baseline gap-4 py-2.5">
|
||||
<dt class="text-base-content/60 min-w-0">{% translate 'Value' %}</dt>
|
||||
<dd class="text-end whitespace-nowrap"><c-amount.display :amount="home.market_value" :prefix="h.prefix" :suffix="h.suffix" :decimal_places="h.decimal_places" divless></c-amount.display></dd>
|
||||
</div>
|
||||
<div class="flex justify-between items-baseline gap-4 py-2.5">
|
||||
<dt class="text-base-content/60 min-w-0">{% translate 'Return' %}</dt>
|
||||
<dd class="text-end whitespace-nowrap"><c-amount.display :amount="home.total_return" :prefix="h.prefix" :suffix="h.suffix" :decimal_places="h.decimal_places" color="auto" divless></c-amount.display> <span class="text-xs">{% include 'investments/fragments/_mwr.html' with mw=home.money_weighted %}</span></dd>
|
||||
</div>
|
||||
<div class="flex justify-between items-baseline gap-4 py-2.5">
|
||||
<dt class="text-base-content/60 min-w-0">{% translate 'From exchange rates' %}</dt>
|
||||
<dd class="text-end whitespace-nowrap">{% if home.has_rate_history %}<c-amount.display :amount="home.currency_effect" :prefix="h.prefix" :suffix="h.suffix" :decimal_places="h.decimal_places" color="auto" divless></c-amount.display>{% else %}<span class="text-base-content/50 whitespace-normal">{% translate "Needs historical exchange rates" %}</span>{% endif %}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
{% endwith %}{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-4 lg:col-span-2">
|
||||
<div class="card bg-base-100 card-border shadow">
|
||||
<div class="px-5 pt-4 pb-2 font-semibold">{% translate 'Movements' %}</div>
|
||||
{% if transactions %}
|
||||
<div class="overflow-x-auto">
|
||||
<table class="table text-sm">
|
||||
<tbody>
|
||||
{% for tx in transactions %}
|
||||
{% with p=tx.linked_transaction %}
|
||||
<tr class="{% if not tx.is_paid %}opacity-50{% endif %}">
|
||||
<td class="whitespace-nowrap text-base-content/60 tabular-nums w-28">{{ tx.date|date:"SHORT_DATE_FORMAT" }}</td>
|
||||
<td>
|
||||
<div>{{ tx.description }}</div>
|
||||
<div class="text-xs text-base-content/50">
|
||||
<span class="tabular-nums">{{ tx.date|date:"SHORT_DATE_FORMAT" }}</span> ·
|
||||
{% if p %}
|
||||
{% if tx.type == 'IN' %}{% translate 'Bought / contributed' %}{% else %}{% translate 'Sold / withdrew' %}{% endif %}
|
||||
· {{ p.account.name }}
|
||||
@@ -302,42 +294,45 @@
|
||||
</td>
|
||||
<td class="w-8 px-1">
|
||||
<button class="btn btn-ghost btn-xs btn-square text-base-content/40 hover:text-base-content"
|
||||
aria-label="{% translate 'Edit' %}" data-tippy-content="{% translate 'Edit' %}"
|
||||
aria-label="{% translate 'Edit' %}"
|
||||
hx-get="{% if p %}{% url 'transaction_transfer_edit' transaction_id=tx.id %}{% else %}{% url 'transaction_edit' transaction_id=tx.id %}{% endif %}" hx-target="#generic-offcanvas"><i class="fa-solid fa-pencil"></i></button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<c-msg.empty title="{% translate 'No movements yet' %}" subtitle="{% translate 'Use the + button to buy or contribute' %}"></c-msg.empty>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if income %}
|
||||
<div class="card bg-base-100 card-border shadow">
|
||||
<div class="px-5 pt-4 pb-2 font-semibold">{% translate 'Income' %}</div>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="table text-sm">
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<c-msg.empty title="{% translate 'No movements yet' %}" subtitle="{% translate 'Use the + button to buy or contribute' %}"></c-msg.empty>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if income %}
|
||||
<div class="card bg-base-100 card-border shadow">
|
||||
<div class="px-5 pt-4 pb-2">
|
||||
<div class="font-semibold">{% translate 'Income' %}</div>
|
||||
{% if income_entities %}<div class="text-xs text-base-content/50">{{ income_entities|join:", " }}</div>{% endif %}
|
||||
</div>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="table text-sm">
|
||||
<tbody>
|
||||
{% for tx in income %}
|
||||
<tr class="{% if not tx.is_paid %}opacity-50{% endif %}">
|
||||
<td class="whitespace-nowrap text-base-content/60 tabular-nums">{{ tx.date|date:"SHORT_DATE_FORMAT" }}</td>
|
||||
<td>{{ tx.description }}<div class="text-xs text-base-content/50">{{ tx.account.name }}</div></td>
|
||||
<td>{{ tx.description }}<div class="text-xs text-base-content/50"><span class="tabular-nums">{{ tx.date|date:"SHORT_DATE_FORMAT" }}</span> · {{ tx.account.name }}</div></td>
|
||||
<td class="text-end tabular-nums whitespace-nowrap"><c-amount.display :amount="tx.amount" :prefix="tx.account.currency.prefix" :suffix="tx.account.currency.suffix" :decimal_places="tx.account.currency.decimal_places" color="green" divless></c-amount.display></td>
|
||||
<td class="w-8 px-1">
|
||||
<button class="btn btn-ghost btn-xs btn-square text-base-content/40 hover:text-base-content"
|
||||
aria-label="{% translate 'Edit' %}" data-tippy-content="{% translate 'Edit' %}"
|
||||
aria-label="{% translate 'Edit' %}"
|
||||
hx-get="{% url 'transaction_edit' transaction_id=tx.id %}" hx-target="#generic-offcanvas"><i class="fa-solid fa-pencil"></i></button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endwith %}
|
||||
@@ -10,8 +10,8 @@
|
||||
{% endspaceless %}
|
||||
</div>
|
||||
|
||||
{% if groups %}
|
||||
<div class="grid grid-cols-1 {% if totals|length > 1 %}lg:grid-cols-2{% endif %} gap-3 mb-6">
|
||||
{% if groupings.0.1 %}
|
||||
<div class="grid grid-cols-1 {% if totals|length > 1 %}lg:grid-cols-2{% endif %} gap-3 mb-8">
|
||||
{% for total in totals %}
|
||||
{% include 'investments/fragments/_totals.html' %}
|
||||
{% endfor %}
|
||||
@@ -20,73 +20,58 @@
|
||||
<div role="tablist" class="tabs tabs-border">
|
||||
<input type="radio" name="investment_tabs" role="tab" class="tab" aria-label="{% translate 'Holdings' %}" checked="checked"/>
|
||||
<div role="tabpanel" class="tab-content pt-4">
|
||||
{% for item in groups %}
|
||||
<div class="card bg-base-100 card-border shadow mb-4">
|
||||
<div class="flex flex-wrap justify-between items-baseline gap-2 px-5 pt-4 pb-2">
|
||||
<span class="font-semibold">{% if item.group %}{{ item.group.name }}{% else %}{% translate 'Ungrouped' %}{% endif %}</span>
|
||||
<div class="flex flex-wrap gap-4 text-sm">
|
||||
<div role="tablist" class="tabs tabs-box tabs-sm w-fit mb-4">
|
||||
<button type="button" role="tab" class="tab group-by-tab {% if group_by == 'group' %}tab-active{% endif %}"
|
||||
hx-get="{% url 'investments_group_by' %}?group_by=group" hx-swap="none"
|
||||
_="on click take .tab-active from .group-by-tab for me then add .hidden to .holdings-grouping then remove .hidden from #holdings-group">
|
||||
{% translate 'Account group' %}
|
||||
</button>
|
||||
<button type="button" role="tab" class="tab group-by-tab {% if group_by == 'investment_class' %}tab-active{% endif %}"
|
||||
hx-get="{% url 'investments_group_by' %}?group_by=investment_class" hx-swap="none"
|
||||
_="on click take .tab-active from .group-by-tab for me then add .hidden to .holdings-grouping then remove .hidden from #holdings-investment_class">
|
||||
{% translate 'Asset class' %}
|
||||
</button>
|
||||
</div>
|
||||
{% for attr, groups in groupings %}
|
||||
<div id="holdings-{{ attr }}" class="holdings-grouping card bg-base-100 card-border shadow {% if attr != group_by %}hidden{% endif %}">
|
||||
{% for item in groups %}
|
||||
<div class="flex flex-wrap justify-between items-baseline gap-x-4 gap-y-1 px-5 pt-5 pb-2 {% if not forloop.first %}border-t border-base-content/10 mt-2{% endif %}">
|
||||
<span class="text-xs font-semibold uppercase tracking-wide text-base-content/50 truncate min-w-0">{% if item.group %}{{ item.group.name }}{% elif attr == 'investment_class' %}{% translate 'Unclassified' %}{% else %}{% translate 'Ungrouped' %}{% endif %}</span>
|
||||
<div class="flex flex-wrap gap-x-4 text-sm text-base-content/60 tabular-nums whitespace-nowrap">
|
||||
{% for total in item.totals %}
|
||||
<div class="flex items-baseline gap-2 tabular-nums">
|
||||
<c-amount.display :amount="total.market_value" :prefix="total.currency.prefix" :suffix="total.currency.suffix" :decimal_places="total.currency.decimal_places" divless></c-amount.display>
|
||||
{% include 'investments/fragments/_mwr.html' with mw=total.money_weighted %}
|
||||
</div>
|
||||
<c-amount.display :amount="total.market_value" :prefix="total.currency.prefix" :suffix="total.currency.suffix" :decimal_places="total.currency.decimal_places" custom_class="font-normal" divless></c-amount.display>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="table table-fixed">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col class="w-36 hidden md:table-column">
|
||||
<col class="w-36 hidden sm:table-column">
|
||||
<col class="w-36">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr class="text-xs text-base-content/50">
|
||||
<th class="font-normal">{% translate 'Investment' %}</th>
|
||||
<th class="font-normal text-end hidden md:table-cell">{% translate 'Invested' %}</th>
|
||||
<th class="font-normal text-end hidden sm:table-cell">{% translate 'Value' %}</th>
|
||||
<th class="font-normal text-end"><span class="sm:hidden">{% translate 'Value' %}</span><span class="hidden sm:inline">{% translate 'Return' %}</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for perf in item.holdings %}
|
||||
{% with c=perf.currency a=perf.account.currency %}
|
||||
<tr class="cursor-pointer transition-colors duration-150 hover:bg-base-200/60"
|
||||
_="on click go to url '{% url 'investment_detail_index' account_id=perf.account.id %}'">
|
||||
<td>
|
||||
<div class="font-medium truncate">
|
||||
{{ perf.account.name }}
|
||||
{% if perf.estimated %}<i class="fa-solid fa-circle-exclamation text-warning text-xs" data-tippy-content="{% translate 'Some costs were estimated from market prices' %}"></i>{% endif %}
|
||||
</div>
|
||||
<ul>
|
||||
{% for perf in item.holdings %}
|
||||
{% with c=perf.currency a=perf.account.currency %}
|
||||
<li>
|
||||
<a href="{% url 'investment_detail_index' account_id=perf.account.id %}"
|
||||
class="flex items-center justify-between gap-4 px-5 py-3 no-underline text-base-content transition-colors duration-150 hover:bg-base-200/60">
|
||||
<div class="min-w-0">
|
||||
<div class="font-medium truncate">{{ perf.account.name }}</div>
|
||||
<div class="text-xs text-base-content/50 tabular-nums truncate">
|
||||
{% if perf.priced %}
|
||||
<c-amount.display :amount="perf.quantity" :prefix="a.prefix" :suffix="a.suffix" :decimal_places="a.decimal_places" divless></c-amount.display>
|
||||
{% if perf.price is not None %}× <c-amount.display :amount="perf.price" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>{% else %}· <span class="text-error">{% translate 'No exchange rate available' %}</span>{% endif %}
|
||||
<c-amount.display :amount="perf.quantity" :prefix="a.prefix" :suffix="a.suffix" :decimal_places="a.decimal_places" custom_class="font-normal" divless></c-amount.display>
|
||||
{% if perf.price is None %}· <span class="text-error">{% translate 'No exchange rate available' %}</span>{% endif %}
|
||||
{% else %}
|
||||
{% translate 'Tracked by value' %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-end tabular-nums whitespace-nowrap text-base-content/70 hidden md:table-cell">
|
||||
<c-amount.display :amount="perf.cost_basis" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>
|
||||
</td>
|
||||
<td class="text-end tabular-nums whitespace-nowrap hidden sm:table-cell">
|
||||
{% if perf.market_value is not None %}<c-amount.display :amount="perf.market_value" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>{% else %}-{% endif %}
|
||||
</td>
|
||||
<td class="text-end tabular-nums whitespace-nowrap">
|
||||
{# Phones show value + return %, wider screens split them into columns #}
|
||||
<div class="sm:hidden font-medium">{% if perf.market_value is not None %}<c-amount.display :amount="perf.market_value" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>{% else %}-{% endif %}</div>
|
||||
<div class="hidden sm:block"><c-amount.display :amount="perf.total_return" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" color="auto" divless></c-amount.display></div>
|
||||
</div>
|
||||
<div class="text-end tabular-nums whitespace-nowrap">
|
||||
<div class="font-medium">{% if perf.market_value is not None %}<c-amount.display :amount="perf.market_value" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display>{% else %}-{% endif %}</div>
|
||||
<div class="text-xs">{% include 'investments/fragments/_mwr.html' with mw=perf.money_weighted %}</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endfor %}
|
||||
<div class="pb-2"></div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<input type="radio" name="investment_tabs" role="tab" class="tab" aria-label="{% translate 'Charts' %}"
|
||||
|
||||
@@ -31,10 +31,9 @@
|
||||
<tr>
|
||||
<td class="font-medium">
|
||||
{{ row.class.name }}
|
||||
{% if row.off %}<i class="fa-solid fa-triangle-exclamation text-warning text-xs" data-tippy-content="{% translate 'Off target' %}"></i>{% endif %}
|
||||
</td>
|
||||
<td class="text-end tabular-nums whitespace-nowrap"><c-amount.display :amount="row.value" :prefix="c.prefix" :suffix="c.suffix" :decimal_places="c.decimal_places" divless></c-amount.display></td>
|
||||
<td class="text-end tabular-nums">{{ row.share|floatformat:1 }}%</td>
|
||||
<td class="text-end tabular-nums {% if row.off %}text-warning{% endif %}">{{ row.share|floatformat:1 }}%</td>
|
||||
<td class="text-end tabular-nums text-base-content/70">{{ row.target|floatformat:"-2" }}%</td>
|
||||
<td class="text-end tabular-nums whitespace-nowrap">
|
||||
{% if row.move > 0 %}
|
||||
|
||||
Reference in new issue
Block a user