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

+13 -3
View File
@@ -4,6 +4,7 @@ import type { Account, Item, Split, TransactionGroup } from "#lib/api/types.js";
import { contains, type Range, today } from "#lib/dates.js";
import { period } from "#lib/period.svelte.js";
import { monthOf } from "#lib/reports/board.js";
import { displayCode, displayFlows } from "#lib/reports/display.js";
import { buckets, type Flow } from "#lib/reports/flows.js";
import { ledgerQuery, ledgerWindow, ownFlows } from "#lib/reports/ledger.js";
import { pages } from "#lib/reports/queries.js";
@@ -96,10 +97,19 @@ export class DimensionModel {
return keptOf(from, this.spec.keep, this.range);
});
groups = $derived(this.inPeriod.groups);
flows = $derived.by(() => flowsOf(this.base, this.accounts.data ?? []));
periodFlows = $derived.by(() =>
rawFlows = $derived.by(() => flowsOf(this.base, this.accounts.data ?? []));
rawPeriod = $derived.by(() =>
flowsOf(this.inPeriod, this.accounts.data ?? [])
);
into = $derived.by(() =>
displayCode(
new Set(
[...this.rawFlows, ...this.rawPeriod].map((flow) => flow.currency)
)
)
);
flows = $derived(displayFlows(this.rawFlows, this.into));
periodFlows = $derived(displayFlows(this.rawPeriod, this.into));
dir = $derived(dirOf(this.flows.length > 0 ? this.flows : this.periodFlows));
main = $derived(this.flows.filter((flow) => flow.dir === this.dir));
periodMain = $derived(
@@ -130,7 +140,7 @@ export class DimensionModel {
weight = $derived(
weigh(
[...this.main, ...this.periodMain],
session.primary?.code ?? "",
this.into ?? session.primary?.code ?? "",
impliedRates(this.raw)
)
);
+28
View File
@@ -7,6 +7,7 @@ import {
} from "#lib/components/charts/chart.js";
import { contains, daysBetween, type Range } from "#lib/dates.js";
import { monthOf, shortMonth } from "#lib/reports/board.js";
import { inDisplay } from "#lib/reports/display.js";
import { type Flow, group, type Totals } from "#lib/reports/flows.js";
import type { Rate } from "#lib/reports/rates.js";
import { money } from "#lib/reports/report.svelte.js";
@@ -230,6 +231,33 @@ export function withLimits(lanes: Lane[], limits: Item<BudgetLimit>[]): Lane[] {
}));
}
export function limitsIn(
limits: Item<BudgetLimit>[],
into: string | null
): Item<BudgetLimit>[] {
if (!into) {
return limits;
}
const merged = new Map<string, Item<BudgetLimit>>();
for (const limit of limits) {
const a = limit.attributes;
const shown = inDisplay(Number(a.amount), a.currency_code ?? "", into);
const key = [shown.code, a.start, a.end].join("|");
const found = merged.get(key);
const amount = shown.amount + Number(found?.attributes.amount ?? 0);
const base = found ?? limit;
merged.set(key, {
...base,
attributes: {
...base.attributes,
amount: String(amount),
currency_code: shown.code,
},
});
}
return [...merged.values()];
}
const limitRangeOf = (limit: Item<BudgetLimit>): Range => ({
end: (limit.attributes.end ?? "").slice(0, 10),
start: (limit.attributes.start ?? "").slice(0, 10),