mirror of
https://github.com/renee-png/acmcc.git
synced 2026-06-21 09:50:01 +00:00
Balance Sheet: fold posted Retained Earnings account into the prior-years line
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 <noreply@anthropic.com>
This commit is contained in:
@@ -1171,8 +1171,16 @@ function buildBalanceSheet(d: any, p?: any, useCompare?: boolean): StructuredRep
|
|||||||
// Equity — equity accounts + calculated RE / current-year earnings
|
// Equity — equity accounts + calculated RE / current-year earnings
|
||||||
rows.push({ kind: "section", label: "Equity" });
|
rows.push({ kind: "section", label: "Equity" });
|
||||||
const equityAccs = byType("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 });
|
// A real "Retained Earnings" equity account is postable via journal entries.
|
||||||
rows.push({ kind: "sub", label: "Retained Earnings (prior years)", amount: cur.rePrior, compare: cmp(prev?.rePrior) });
|
// 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) });
|
rows.push({ kind: "sub", label: "Net Income", amount: cur.cye, compare: cmp(prev?.cye) });
|
||||||
const totalE = sumBal(equityAccs) + cur.rePrior + cur.cye;
|
const totalE = sumBal(equityAccs) + cur.rePrior + cur.cye;
|
||||||
const totalEP = prev ? (sumBalP(equityAccs)! + prev.rePrior + prev.cye) : undefined;
|
const totalEP = prev ? (sumBalP(equityAccs)! + prev.rePrior + prev.cye) : undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user