feat: show every amount in one currency, chosen in the header, $ toggles it

A selector in the header and the palette's Currency group pick the
currency, the primary one by default; the choice persists between pages
and $ switches it on and off. Rates come from Firefly's exchange rates,
then from the owner's own transactions with a foreign amount, walking
through other currencies when there is no direct pair. Amount converts
with a ≈ and keeps the original in its title; Money sums several
currencies into one converted amount.
This commit is contained in:
hh committed 2026-10-16 18:15:53 +00:00
1 parent 3c1d8a4867
commit 2231c08eee
6 files changed
+315 -44

No files matched your search

+5 -6
View File
@@ -2,9 +2,9 @@ import { api } from "#lib/api/client.js";
import { all } from "#lib/api/lists.js";
import type { ExchangeRate, Page, TransactionGroup } from "#lib/api/types.js";
import { formatMoney, toNumber } from "#lib/format.js";
import { display } from "#lib/money/display.svelte.js";
import { session } from "#lib/session.svelte.js";
const KEY = "ffui.dashboard.in-primary";
const OWN_SAMPLE = 100;
const HOUR_MS = 3_600_000;
@@ -25,13 +25,12 @@ export function median(values: number[]): number {
}
class InPrimary {
on = $state(
typeof localStorage !== "undefined" && localStorage.getItem(KEY) === "1"
);
get on() {
return display.on && display.code === session.primary?.code;
}
toggle() {
this.on = !this.on;
localStorage.setItem(KEY, this.on ? "1" : "0");
display.toggle();
}
}