From 9cdf303553a2c7722e7847b24d4a2d18395d85a1 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Mon, 20 Apr 2026 08:48:11 +0200 Subject: [PATCH 1/2] improved filter in account view Signed-off-by: Stephan Richter --- frontend/src/routes/accounting/account.svelte | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/frontend/src/routes/accounting/account.svelte b/frontend/src/routes/accounting/account.svelte index 6781f810..54f58237 100644 --- a/frontend/src/routes/accounting/account.svelte +++ b/frontend/src/routes/accounting/account.svelte @@ -11,13 +11,15 @@ let account = $state(null); let filter = $state([]); let transactions = $state([]); + let filtered = $derived(transactions.filter(t => checker(t.tags,filter))); let users = {}; - let sums = {}; + let sums = $derived.by(calcSums); function calcSums(){ + let sums = {}; sums[0] = 0; for (let user of Object.values(users)) sums[user.id] = 0; - for (let transaction of transactions) { + for (let transaction of filtered) { for (let user of Object.values(users)){ if (user.id == transaction.destination.id) sums[user.id] += transaction.amount; if (user.id == transaction.source.id) sums[user.id] -= transaction.amount; @@ -25,18 +27,30 @@ if (!transaction.destination.id) sums[0] += transaction.amount; if (!transaction.source.id) sums[0] -= transaction.amount; } + return sums; } function addToFilter(tag){ - filter.push(tag); + filter.push(tag.toLowerCase()); } function checker(taglist, filter){ - return filter.every(tag => taglist.includes(tag)); + // TODO: make case-insensitive + for (var f of filter){ + var included = false; + for (var t of taglist){ + if (t.toLowerCase() == f) { + included = true; + break; + } + } + if (!included) return false; + } + return true; } function dropTag(tag){ - filter = filter.filter(x => x != tag); + filter = filter.filter(x => x != tag.toLowerCase()); } async function load(){ @@ -48,7 +62,6 @@ transactions = json.transactions; users = json.user_list; account = json.account; - calcSums(); } else error(res); } @@ -90,12 +103,10 @@ - {#each transactions as transaction, i} - {#if checker(transaction.tags,filter)} + {#each filtered as transaction, i} - {/if} {/each} - +
{t('sums')} @@ -110,6 +121,7 @@
{sums[0].toFixed(2)} {account.currency} + From 8c0011d7ffe35ac8488bef2a479c26f6c3328467 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Mon, 20 Apr 2026 21:51:12 +0200 Subject: [PATCH 2/2] fixd calculation of sums for filtered transactions Signed-off-by: Stephan Richter --- frontend/src/routes/accounting/account.svelte | 6 +----- web/src/main/resources/web/css/default-color.css | 3 ++- web/src/main/resources/web/css/default.css | 6 ++++++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/frontend/src/routes/accounting/account.svelte b/frontend/src/routes/accounting/account.svelte index 54f58237..a45032cf 100644 --- a/frontend/src/routes/accounting/account.svelte +++ b/frontend/src/routes/accounting/account.svelte @@ -35,14 +35,10 @@ } function checker(taglist, filter){ - // TODO: make case-insensitive for (var f of filter){ var included = false; for (var t of taglist){ - if (t.toLowerCase() == f) { - included = true; - break; - } + if (t.toLowerCase() == f && (included = true)) break; } if (!included) return false; } diff --git a/web/src/main/resources/web/css/default-color.css b/web/src/main/resources/web/css/default-color.css index 621b7377..9ad642e2 100644 --- a/web/src/main/resources/web/css/default-color.css +++ b/web/src/main/resources/web/css/default-color.css @@ -62,11 +62,12 @@ tr:hover .taglist .tag button { background: orange; color: black; } - +.account .sums, .archive{ background: black; } +.account .sums:hover, .archive.hover{ background: orange; color: black; diff --git a/web/src/main/resources/web/css/default.css b/web/src/main/resources/web/css/default.css index 40d2dfc1..b32d9411 100644 --- a/web/src/main/resources/web/css/default.css +++ b/web/src/main/resources/web/css/default.css @@ -365,6 +365,12 @@ textarea{ display: inherit; } +.account .sums{ + position: sticky; + bottom: 0; + z-index: 100; +} + .taglist .editor > span{ display: inline-block; min-width: 150px;