feat: every page follows the one-currency mode

Totals, info boxes, section headers, group subtotals, shares and the
per-currency charts on the dashboard, transactions, search, accounts,
merchants, statement, budgets, categories, tags, groups, piggy banks,
reports and the category, tag, budget and merchant pages sum into one
converted amount when the mode is on; charts split by currency merge
into one lane. Inputs, reconciliation and the Foreign column stay exact.

Money moved to or from a debt, loan or mortgage no longer counts as
income or spending in the transaction list boxes; it shows as From
debts and To debts. The running balance of an incoming foreign-currency
transfer shows in the account's currency.
This commit is contained in:
hh committed 2026-10-16 18:49:16 +00:00
1 parent 94466d9be9
commit 617a4700e2
61 files changed
+1427 -798

No files matched your search

@@ -1,8 +1,10 @@
<script lang="ts">
import type { Split } from "#lib/api/types.js";
import Amount from "#lib/components/Amount.svelte";
import Box from "#lib/components/Box.svelte";
import Money from "#lib/components/Money.svelte";
import { display } from "#lib/money/display.svelte.js";
import {
debtMove,
type Group,
type Signed,
sumByCurrency,
@@ -10,9 +12,11 @@
const TOP = 5;
const TOTALS = [
["withdrawal", "Spent"],
["deposit", "Earned"],
["transfer", "Transferred"],
["Spent", "auto", (s: Split) => s.type === "withdrawal" && !debtMove(s)],
["Earned", "auto", (s: Split) => s.type === "deposit" && !debtMove(s)],
["Transferred", "transfer", (s: Split) => s.type === "transfer"],
["From debts", "transfer", (s: Split) => debtMove(s) === "in"],
["To debts", "transfer", (s: Split) => debtMove(s) === "out"],
] as const;
interface Entry {
@@ -28,16 +32,24 @@
}: { groups: Group[]; type: string; loading?: boolean } = $props();
const splits = $derived(groups.flatMap((g) => g.attributes.transactions));
const flows = $derived(splits.filter((s) => !debtMove(s)));
const totals = $derived(
TOTALS.map(([kind, label]) => ({
TOTALS.map(([label, tone, test]) => ({
label,
sums: sumByCurrency(splits.filter((s) => s.type === kind)),
sums: sumByCurrency(splits.filter(test)),
tone,
})).filter((row) => row.sums.length > 0)
);
const toneOf = (sums: Signed[]) =>
sums.every((sum) => sum.tone === "transfer") ? "transfer" : "auto";
const size = (entry: Entry) =>
Math.max(...entry.sums.map((sum) => Math.abs(sum.amount)));
Math.abs(
display.total(entry.sums)?.amount ??
Math.max(...entry.sums.map((sum) => Math.abs(sum.amount)))
);
function aggregate(
list: Split[],
@@ -65,7 +77,7 @@
const blocks = $derived([
{
title: "Categories",
...aggregate(splits, (s) =>
...aggregate(flows, (s) =>
s.category_id
? [s.category_name ?? "", `/categories/show/${s.category_id}`]
: ["(no category)", undefined]
@@ -74,7 +86,7 @@
type === "withdrawal"
? {
title: "Budgets",
...aggregate(splits, (s) =>
...aggregate(flows, (s) =>
s.budget_id
? [s.budget_name ?? "", `/budgets/show/${s.budget_id}`]
: ["(no budget)", undefined]
@@ -82,14 +94,14 @@
}
: {
title: "Source accounts",
...aggregate(splits, (s) => [
...aggregate(flows, (s) => [
s.source_name ?? "(cash)",
s.source_id ? `/accounts/show/${s.source_id}` : undefined,
]),
},
{
title: "Destination accounts",
...aggregate(splits, (s) => [
...aggregate(flows, (s) => [
s.destination_name ?? "(cash)",
s.destination_id ? `/accounts/show/${s.destination_id}` : undefined,
]),
@@ -97,18 +109,6 @@
]);
</script>
{#snippet amount(
value: Signed
)}
<Amount
amount={value.amount}
code={value.code}
decimals={value.decimals}
symbol={value.symbol}
tone={value.tone === "transfer" ? "transfer" : "auto"}
/>
{/snippet}
<div class="mb-4 grid gap-3 md:grid-cols-2 xl:grid-cols-4">
<Box body="px-3 py-2" title="Overview">
{#if loading && groups.length === 0}
@@ -120,9 +120,7 @@
{#each totals as row (row.label)}
<dt class="text-cladd-fg-soft">{row.label}</dt>
<dd class="flex flex-col items-end">
{#each row.sums as sum (sum.code)}
{@render amount(sum)}
{/each}
<Money parts={row.sums} tone={row.tone} />
</dd>
{/each}
</dl>
@@ -143,9 +141,7 @@
<span class="truncate text-cladd-fg-soft">{entry.name}</span>
{/if}
<span class="flex flex-col items-end">
{#each entry.sums as sum (sum.code)}
{@render amount(sum)}
{/each}
<Money parts={entry.sums} tone={toneOf(entry.sums)} />
</span>
</li>
{:else}