From 88dab48cfe3c58bff1731d941b5cc1d9031f8ab3 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 9 Apr 2026 13:26:01 +0200 Subject: [PATCH] Fix General Journal: balance calculation, date width, badge alignment - Fixed result account (Income/Cost) running balance: now computed from fiscal year start to period start, not from dawn of time. Balance accounts (Asset/Debt) still use all-time cumulative as before. - Narrowed date column from 145px to 130px - Right-aligned account type badge (pr: 4px) so it acts as a bullet point for the account name (pl: 4px), creating visual continuity between badge and account name across the column boundary Made-with: Cursor --- .../src/pages/inspect/GeneralJournalTab.tsx | 6 +++--- .../Endpoints/InspectLedgerEndpoints.cs | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/frontend/src/pages/inspect/GeneralJournalTab.tsx b/frontend/src/pages/inspect/GeneralJournalTab.tsx index 069cd81e..c047836f 100644 --- a/frontend/src/pages/inspect/GeneralJournalTab.tsx +++ b/frontend/src/pages/inspect/GeneralJournalTab.tsx @@ -92,7 +92,7 @@ export default function GeneralJournalTab() { - + @@ -143,7 +143,7 @@ export default function GeneralJournalTab() { ...tx.rows.map(row => ( - + - + {row.accountName} diff --git a/src/UsingCash.Api/Endpoints/InspectLedgerEndpoints.cs b/src/UsingCash.Api/Endpoints/InspectLedgerEndpoints.cs index c1ff38a4..53bbfa97 100644 --- a/src/UsingCash.Api/Endpoints/InspectLedgerEndpoints.cs +++ b/src/UsingCash.Api/Endpoints/InspectLedgerEndpoints.cs @@ -180,11 +180,24 @@ public static class InspectLedgerEndpoints { var isBalanceAccount = acct.AccountType == UsingCash.Common.Enums.FinancialAccountType.Asset || acct.AccountType == UsingCash.Common.Enums.FinancialAccountType.Debt; - var priorStart = isBalanceAccount ? balanceStart : profitLossStart; - if (priorStart < from) + + if (isBalanceAccount) + { runningBalances[acct.FinancialAccountId] = await repo.GetAccountBalanceCents(acct.FinancialAccountId, from); + } else - runningBalances[acct.FinancialAccountId] = 0; + { + // Result accounts: balance from fiscal year start to period start + if (profitLossStart < from) + { + var rows = await repo.GetRowsForAccountInRange(acct.FinancialAccountId, profitLossStart, from); + runningBalances[acct.FinancialAccountId] = rows.Sum(r => r.AmountCents); + } + else + { + runningBalances[acct.FinancialAccountId] = 0; + } + } } var grouped = allRows