From 2ef34eadffc44d9eb5478d388a2b5818a439c235 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 9 Apr 2026 13:39:13 +0200 Subject: [PATCH] Merge date+desc columns for account rows, fix Account Ledger balances MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit General Journal: account rows now use colSpan=2 to merge the Date and Description columns, so the badge+account name starts under the transaction date rather than being deeply indented under the description. Creates a more natural visual hierarchy. Account Ledger: fixed prior balance calculation for result accounts (Income/Cost) — now computed from fiscal year start to period start, matching the General Journal fix. Balance accounts (Asset/Debt) still use all-time cumulative. Made-with: Cursor --- .../src/pages/inspect/GeneralJournalTab.tsx | 5 ++--- .../Endpoints/InspectLedgerEndpoints.cs | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/frontend/src/pages/inspect/GeneralJournalTab.tsx b/frontend/src/pages/inspect/GeneralJournalTab.tsx index 2789a9d2..14f3b479 100644 --- a/frontend/src/pages/inspect/GeneralJournalTab.tsx +++ b/frontend/src/pages/inspect/GeneralJournalTab.tsx @@ -139,12 +139,11 @@ export default function GeneralJournalTab() { , - // Transaction row entries + // Transaction row entries — date+description merged into one cell ...tx.rows.map(row => ( - - + (); long priorBalance = 0; + var profitLossStart = new DateTime(from.Year, 1, 1); + var accountTypeMap = allAccounts.ToDictionary(a => a.FinancialAccountId, a => a.AccountType); foreach (var acctId in accountIds) { - priorBalance += await repo.GetAccountBalanceCents(acctId, from); + var isBalanceAccount = accountTypeMap.TryGetValue(acctId, out var acctType) + && (acctType == UsingCash.Common.Enums.FinancialAccountType.Asset + || acctType == UsingCash.Common.Enums.FinancialAccountType.Debt); + + if (isBalanceAccount) + { + priorBalance += await repo.GetAccountBalanceCents(acctId, from); + } + else if (profitLossStart < from) + { + var priorRows = await repo.GetRowsForAccountInRange(acctId, profitLossStart, from); + priorBalance += priorRows.Sum(r => r.AmountCents); + } + var rows = await repo.GetRowsForAccountInRange(acctId, from, to); allRows.AddRange(rows.Select(r => (r, acctId))); }