General Journal: per-row balance, wider date, remove collapse
- Added per-account running balance column: each row shows the account's balance after this specific row's delta is applied. Balance accounts (Asset/Debt) start from dawn-of-time prior balance; result accounts (Income/Cost) start from fiscal year start. - Removed collapse/expand on transaction headers — they're just headers, not collapsible parents. Eliminates whitespace issue. - Widened date column to 145px with whiteSpace: nowrap to prevent date wrapping across lines. - Simplified component by removing all collapse state and animation code. Made-with: Cursor
This commit is contained in:
@@ -171,6 +171,22 @@ public static class InspectLedgerEndpoints
|
||||
}
|
||||
}
|
||||
|
||||
// Compute per-account running balances (prior balance + each row's delta)
|
||||
var runningBalances = new Dictionary<int, long>();
|
||||
var balanceStart = new DateTime(1, 1, 1);
|
||||
var profitLossStart = new DateTime(from.Year, 1, 1);
|
||||
|
||||
foreach (var acct in allAccounts)
|
||||
{
|
||||
var isBalanceAccount = acct.AccountType == UsingCash.Common.Enums.FinancialAccountType.Asset
|
||||
|| acct.AccountType == UsingCash.Common.Enums.FinancialAccountType.Debt;
|
||||
var priorStart = isBalanceAccount ? balanceStart : profitLossStart;
|
||||
if (priorStart < from)
|
||||
runningBalances[acct.FinancialAccountId] = await repo.GetAccountBalanceCents(acct.FinancialAccountId, from);
|
||||
else
|
||||
runningBalances[acct.FinancialAccountId] = 0;
|
||||
}
|
||||
|
||||
var grouped = allRows
|
||||
.GroupBy(r => r.Row.FinancialTransactionId)
|
||||
.Where(g => txCache.ContainsKey(g.Key))
|
||||
@@ -187,16 +203,24 @@ public static class InspectLedgerEndpoints
|
||||
description = tx.Comment,
|
||||
blockchainHash = tx.BlockchainHash,
|
||||
hasDocumentation = tx.HasDocumentation,
|
||||
rows = g.Select(r => new
|
||||
rows = g.Select(r =>
|
||||
{
|
||||
rowId = r.Row.FinancialTransactionRowId,
|
||||
accountId = r.AccountId,
|
||||
accountName = AccountPath(r.AccountId),
|
||||
accountType = accountMap.TryGetValue(r.AccountId, out var a) ? a.AccountType.ToString() : "",
|
||||
debitCents = r.Row.AmountCents > 0 ? r.Row.AmountCents : 0,
|
||||
creditCents = r.Row.AmountCents < 0 ? -r.Row.AmountCents : 0,
|
||||
foreignCurrencyCode = r.Row.ForeignCurrencyCode,
|
||||
foreignCurrencyAmountCents = r.Row.ForeignCurrencyAmountCents,
|
||||
if (!runningBalances.ContainsKey(r.AccountId))
|
||||
runningBalances[r.AccountId] = 0;
|
||||
runningBalances[r.AccountId] += r.Row.AmountCents;
|
||||
|
||||
return new
|
||||
{
|
||||
rowId = r.Row.FinancialTransactionRowId,
|
||||
accountId = r.AccountId,
|
||||
accountName = AccountPath(r.AccountId),
|
||||
accountType = accountMap.TryGetValue(r.AccountId, out var a) ? a.AccountType.ToString() : "",
|
||||
debitCents = r.Row.AmountCents > 0 ? r.Row.AmountCents : 0,
|
||||
creditCents = r.Row.AmountCents < 0 ? -r.Row.AmountCents : 0,
|
||||
balanceCents = runningBalances[r.AccountId],
|
||||
foreignCurrencyCode = r.Row.ForeignCurrencyCode,
|
||||
foreignCurrencyAmountCents = r.Row.ForeignCurrencyAmountCents,
|
||||
};
|
||||
}).ToList(),
|
||||
};
|
||||
}).ToList();
|
||||
|
||||
Reference in New Issue
Block a user