From 5aa03d1cd6b85f8a498b0495699bcbbd3f1798b8 Mon Sep 17 00:00:00 2001 From: renee-png Date: Mon, 8 Jun 2026 13:26:13 -0400 Subject: [PATCH] Balance Sheet: fold posted Retained Earnings account into the prior-years line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A real "Retained Earnings" equity account is postable via journal entries, but the balance sheet listed it separately from the calculated "Retained Earnings (prior years)" line, so JE adjustments looked like they had no effect there. Now the posted RE-account balance is added into the "Retained Earnings (prior years)" line (and removed from the generic equity list). Total Equity is unchanged — it already included that account. Co-Authored-By: Claude Opus 4.8 --- src/pages/accounting/AccountingReportsPage.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pages/accounting/AccountingReportsPage.tsx b/src/pages/accounting/AccountingReportsPage.tsx index 37d86d6..abc8635 100644 --- a/src/pages/accounting/AccountingReportsPage.tsx +++ b/src/pages/accounting/AccountingReportsPage.tsx @@ -1171,8 +1171,16 @@ function buildBalanceSheet(d: any, p?: any, useCompare?: boolean): StructuredRep // Equity — equity accounts + calculated RE / current-year earnings rows.push({ kind: "section", label: "Equity" }); const equityAccs = byType("equity"); - for (const a of equityAccs) rows.push({ kind: "sub", label: a.name, code: a.code ?? undefined, amount: balOf(a), compare: cmp(balOfP(a)), accountId: a.id }); - rows.push({ kind: "sub", label: "Retained Earnings (prior years)", amount: cur.rePrior, compare: cmp(prev?.rePrior) }); + // A real "Retained Earnings" equity account is postable via journal entries. + // Fold its posted balance into the calculated "Retained Earnings (prior years)" + // line so manual JE adjustments show there instead of as a separate line. + const reAccts = equityAccs.filter((a) => /retained\s+earnings/i.test(String(a.name || ""))); + const reIds = new Set(reAccts.map((a) => a.id)); + const otherEquity = equityAccs.filter((a) => !reIds.has(a.id)); + for (const a of otherEquity) rows.push({ kind: "sub", label: a.name, code: a.code ?? undefined, amount: balOf(a), compare: cmp(balOfP(a)), accountId: a.id }); + const rePosted = reAccts.reduce((s, a) => s + balOf(a), 0); + const rePostedP = prev ? reAccts.reduce((s, a) => s + (prev.glByAcct.get(a.id) ?? 0), 0) : undefined; + rows.push({ kind: "sub", label: "Retained Earnings (prior years)", amount: cur.rePrior + rePosted, compare: cmp(prev ? prev.rePrior + (rePostedP ?? 0) : undefined) }); rows.push({ kind: "sub", label: "Net Income", amount: cur.cye, compare: cmp(prev?.cye) }); const totalE = sumBal(equityAccs) + cur.rePrior + cur.cye; const totalEP = prev ? (sumBalP(equityAccs)! + prev.rePrior + prev.cye) : undefined;