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:
1 parent
94466d9be9
commit
617a4700e2
61 files changed
+1427
-798
No files matched your search
@@ -16,6 +16,7 @@
|
||||
type ViewRange,
|
||||
} from "#lib/dates.js";
|
||||
import { toNumber } from "#lib/format.js";
|
||||
import { display } from "#lib/money/display.svelte.js";
|
||||
import { period, periodLabel } from "#lib/period.svelte.js";
|
||||
|
||||
const COUNT = 12;
|
||||
@@ -50,6 +51,7 @@
|
||||
}));
|
||||
|
||||
interface Flow {
|
||||
approx?: boolean;
|
||||
code: string;
|
||||
earned: number;
|
||||
spent: number;
|
||||
@@ -76,12 +78,34 @@
|
||||
}
|
||||
return map;
|
||||
});
|
||||
const merged = $derived.by(() => {
|
||||
if (!display.active) {
|
||||
return null;
|
||||
}
|
||||
const map = new Map<string, Flow[]>();
|
||||
for (const [key, list] of byStart) {
|
||||
const flow: Flow = { code: display.code, earned: 0, spent: 0 };
|
||||
for (const f of list) {
|
||||
const rate = display.rate(f.code);
|
||||
if (rate === null) {
|
||||
return null;
|
||||
}
|
||||
flow.earned += f.earned * rate;
|
||||
flow.spent += f.spent * rate;
|
||||
flow.approx ||= f.code !== display.code;
|
||||
}
|
||||
map.set(key, [flow]);
|
||||
}
|
||||
return map;
|
||||
});
|
||||
const shown = $derived(merged ?? byStart);
|
||||
const main = $derived(merged ? display.code : code);
|
||||
const scale = $derived(
|
||||
Math.max(
|
||||
1,
|
||||
...[...byStart.values()].flatMap((list) =>
|
||||
...[...shown.values()].flatMap((list) =>
|
||||
list
|
||||
.filter((f) => f.code === code)
|
||||
.filter((f) => f.code === main)
|
||||
.map((f) => Math.max(f.earned, f.spent))
|
||||
)
|
||||
)
|
||||
@@ -95,7 +119,7 @@
|
||||
class="-mr-px grid grid-cols-1 overflow-hidden @xs:grid-cols-2 @lg:grid-cols-3 @2xl:grid-cols-4 @4xl:grid-cols-6"
|
||||
>
|
||||
{#each blocks as block (block.start)}
|
||||
{@const list = (byStart.get(block.start) ?? []).filter(
|
||||
{@const list = (shown.get(block.start) ?? []).filter(
|
||||
(f) => f.earned || f.spent
|
||||
)}
|
||||
<li class="border-cladd-outline/60 border-r border-b">
|
||||
@@ -117,17 +141,20 @@
|
||||
{/if}
|
||||
{#each list as flow (flow.code)}
|
||||
{@const fmt = money(currency(flow.code))}
|
||||
{@const mark = flow.approx ? "≈" : ""}
|
||||
<span
|
||||
class="num flex flex-wrap justify-between gap-x-2 text-[12px]"
|
||||
>
|
||||
{#if flow.earned}
|
||||
<span class="text-income">+{fmt(flow.earned)}</span>
|
||||
<span class="text-income">{mark}+{fmt(flow.earned)}</span>
|
||||
{/if}
|
||||
{#if flow.spent}
|
||||
<span class="ml-auto text-expense">−{fmt(flow.spent)}</span>
|
||||
<span class="ml-auto text-expense"
|
||||
>{mark}−{fmt(flow.spent)}</span
|
||||
>
|
||||
{/if}
|
||||
</span>
|
||||
{#if flow.code === code}
|
||||
{#if flow.code === main}
|
||||
<span aria-hidden="true" class="flex h-1 gap-0.5">
|
||||
<span class="flex flex-1 justify-end">
|
||||
<span
|
||||
|
||||
Reference in new issue
Block a user