Add trial-balance (GL health) indicator to Chart of Accounts
Surfaces the audit #2 check in the UI: a badge at the top of the Chart of Accounts page shows "Trial balance: Balanced" or "off by $X (excess debits/credits)". Computed in AccountsController.Index from already-loaded accounts: debit-normal (Asset/COGS/Expense) minus credit-normal (Liability/Equity/Revenue) CurrentBalance, which nets to ~0 for balanced books. Helps companies spot one-sided postings / opening-balance gaps. Help KB + Settings article updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -69,6 +69,14 @@ public class AccountsController : Controller
|
||||
// Default-account pickers (Revenue / COGS / Inventory) — see SaveDefaultAccounts.
|
||||
await PopulateDefaultAccountViewDataAsync(companyId, accounts);
|
||||
|
||||
// GL health: trial-balance net. Debit-normal (Asset/COGS/Expense) minus credit-normal
|
||||
// (Liability/Equity/Revenue) should net to ~0 for balanced books. A non-zero value flags
|
||||
// drift or one-sided postings (often opening balances entered without an offsetting entry).
|
||||
ViewBag.TrialBalanceNet = accounts.Sum(a =>
|
||||
(a.AccountType == AccountType.Asset || a.AccountType == AccountType.CostOfGoods
|
||||
|| a.AccountType == AccountType.Expense)
|
||||
? a.CurrentBalance : -a.CurrentBalance);
|
||||
|
||||
return View(grouped);
|
||||
}
|
||||
|
||||
|
||||
@@ -678,6 +678,9 @@ public static class HelpKnowledgeBase
|
||||
**Step 5 — Set up your Chart of Accounts (for billing/AP)**
|
||||
If you use the Bills and accounting features, go to [Chart of Accounts](/Accounts) and confirm the seeded accounts fit your setup. The wizard seeds a standard set automatically.
|
||||
|
||||
**Trial balance indicator (Chart of Accounts)**
|
||||
The Chart of Accounts page shows a Trial Balance badge: "Balanced" when total debits equal total credits, otherwise how far off the books are (excess debits/credits). A non-zero value usually means opening balances were entered without an offsetting entry, or a one-sided posting. Run Recalculate Balances first; if it persists, review opening balances.
|
||||
|
||||
**Default accounts (Chart of Accounts → Set Defaults)**
|
||||
On the Chart of Accounts page, the "Default Accounts" card lets you choose a default Revenue, COGS, and Inventory account for your company. These are used automatically when an item or invoice line doesn't specify one: invoice lines fall back to your default Revenue account (then to account 4000 if none is set), and new inventory and catalog items are pre-filled with your default COGS/Inventory accounts. Leave any blank to keep the current behavior. Note: setting BOTH a COGS and an Inventory Asset default makes new items post inventory-consumption COGS (perpetual inventory) — leave them blank if you expense materials when you purchase them.
|
||||
|
||||
|
||||
@@ -36,7 +36,33 @@
|
||||
};
|
||||
}
|
||||
|
||||
<div class="d-flex justify-content-end mb-4">
|
||||
@{
|
||||
var tbNet = (decimal)(ViewBag.TrialBalanceNet ?? 0m);
|
||||
var tbBalanced = Math.Abs(tbNet) < 0.01m;
|
||||
}
|
||||
<div class="d-flex justify-content-between align-items-center mb-4 flex-wrap gap-2">
|
||||
@if (Model.Any())
|
||||
{
|
||||
<div>
|
||||
@if (tbBalanced)
|
||||
{
|
||||
<span class="badge bg-success-subtle text-success-emphasis border border-success-subtle py-2 px-3">
|
||||
<i class="bi bi-check-circle me-1"></i>Trial balance: Balanced
|
||||
</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="badge bg-warning-subtle text-warning-emphasis border border-warning-subtle py-2 px-3"
|
||||
title="Total debits minus total credits. A non-zero value usually means opening balances were entered without an offsetting entry, or a one-sided posting. Run Recalculate Balances; if it persists, review opening balances.">
|
||||
<i class="bi bi-exclamation-triangle me-1"></i>Trial balance off by @tbNet.ToString("C") (@(tbNet > 0 ? "excess debits" : "excess credits"))
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div></div>
|
||||
}
|
||||
<div class="d-flex gap-2">
|
||||
<form id="recalcBalancesForm" asp-action="RecalculateBalances" method="post">
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
@@ -262,6 +262,15 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3 class="h6 fw-semibold mt-3 mb-2">Trial Balance Indicator</h3>
|
||||
<p>
|
||||
The top of the Chart of Accounts page shows a <strong>Trial balance</strong> badge. When total
|
||||
debits equal total credits it reads <em>Balanced</em>; otherwise it shows how far off the books
|
||||
are (excess debits or credits). A non-zero value usually means opening balances were entered
|
||||
without an offsetting entry, or a one-sided posting occurred. Run <strong>Recalculate Balances</strong>
|
||||
first; if it persists, review your opening balances or ask your accountant.
|
||||
</p>
|
||||
|
||||
<div class="alert alert-permanent alert-warning d-flex gap-2 mb-0" role="alert">
|
||||
<i class="bi bi-exclamation-triangle-fill flex-shrink-0 mt-1"></i>
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user