====== #179 — Reports → Trial balance shows "Nothing has been recorded on or before this date yet" at every as-at date, on books holding expen (Resolved) ====== [[wiki:project-x:bugs|← Back to bug list]] · [[https://mantis.matrixdn.net/view.php?id=179|View issue #179 in MantisBT]] ---- **Reported by:** Nour aboulhosn on 2026-08-06T12:04:42+01:00\\ **Assigned to:** Claude\\ **Resolved by:** Claude on 2026-08-06T14:57:18+01:00\\ **Severity:** major\\ **Priority:** high\\ **Reproducibility:** have not tried\\ **Category:** General **Description:** **Reports → Trial balance** — described in the app as "what an accountant asks for at a year end" — renders no accounts and no figures at all, only the message *"Nothing has been recorded on or before this date yet."* The books were not empty. At the time of testing the business held **8 expenses**, several sales and purchase invoices, recorded payments and completed cash transfers, all dated **6 Aug 2026**, while the dashboard simultaneously reported **Total collected $147.49** and **Total expenses $359.94**, with non-zero balances and correct In/Out tallies on both cash accounts. This is not an as-at boundary or off-by-one problem, the obvious first suspicion. The report was requested at `2026-08-05`, `2026-08-06`, `2026-08-07`, `2026-08-31`, `2026-12-31`, `2027-01-01` and `2030-01-01` — from the day before the data to years after it — and every one returned the same empty message. The parameter was taken from the page's own form (`name="as_at"`), and the heading correctly echoes the requested date back. Since the emptiness is total and date-independent, the fault is in how the report gathers rows rather than how it filters them by date. Worth checking first: whether the trial balance reads a separate ledger table that ordinary activity never writes to, and whether it is scoped to the correct business/owner id — a scoping mismatch produces exactly this symptom. It should be built from the same records the rest of the app reports on, with correct debit/credit treatment and balancing columns. **Steps to Reproduce:** 1. On an account with data, confirm the books are non-empty: the dashboard shows non-zero **Total collected** and **Total expenses**, **Expenses** lists records, and **Cash & accounts** shows non-zero balances. 2. Go to **Reports → Trial balance**. 3. Observe: no accounts, no debit/credit columns, no figures — only "Nothing has been recorded on or before this date yet." 4. Set **As at** to a date well after all the data (e.g. `2030-01-01`) and press **Apply**. The heading updates to "As at 1 Jan 2030"; the message is unchanged. 5. Repeat for `2026-08-05`, `2026-08-06`, `2026-08-07`, `2026-08-31`, `2026-12-31` — every date returns the same empty result. **Resolution:** Fixed — though not as a scoping bug, and the investigation is worth recording because the ticket's first suspicion was reasonable and wrong. WHAT Reports → Trial balance rendered "Nothing has been recorded on or before this date yet" on books holding expenses, invoices, payments and cash transfers, at every as-at date tried. DOES NOT REPRODUCE AS DESCRIBED On current code the statement renders correctly. Measured directly against real books: 6 rows, debit 2,802.75 = credit 2,802.75, at 2026-08-05, 2026-08-06, 2026-08-31 and 2030-01-01 alike; over HTTP, 8 table rows and no empty message. The gathering is correctly company-scoped and App\Billing\TrialBalance is doing its job. WHAT WAS ACTUALLY WRONG — and it produces exactly this symptom The statement can be legitimately empty on books that are not, and the screen gave the WRONG SENTENCE for that case. Two things drop rows, both by design: - a DRAFT invoice is neither a receivable nor income (it was issued to nobody), so it contributes nothing; - an expense attached to a BILL is a payment, not a second cost — the cost is already on the statement as Purchases, so counting it again under its own category would put the same spending in the debit column twice. Both were the ORDINARY state while naming a bill was compulsory, which is the era this was reported in. Measured by reproducing that state on real books: 6 rows as shipped, 5 with every expense on a bill, and **2 with every invoice also a draft** — heading exactly where the reporter ended up. So the report is a true description of a screen that answered "your books are empty" when the truth was "there is nothing to show as at this date, for these two reasons". FIX TrialBalance::asAt() now also reports whether the books hold anything at all, and the view chooses between two sentences. The second names both reasons, so the reader can act on it: "There is nothing to show as at this date. Invoices still marked Draft are not counted — mark them as sent — and spending recorded against a bill appears under Purchases rather than under its own category." VERIFIED real books, as at 2030: 6 rows -> the table real books, as at 2000: 0 rows, hasRecords=true -> "nothing to show" (the new sentence) a company with no records: 0 rows, hasRecords=false -> "nothing recorded yet" (the old one) If the original total-emptiness is ever seen again on current code, please attach the company id — the gathering itself is now measured as correct and I could not make it return nothing on books that hold anything. Full suite 364 tests green; lint clean; 88-request sweep, 0 problems. ===== Activity / Notes ===== * **2026-08-06T14:57:12+01:00 - Claude:** Fixed — though not as a scoping bug, and the investigation is worth recording because the ticket's first suspicion was reasonable and wrong. WHAT Reports → Trial balance rendered "Nothing has been recorded on or before this date yet" on books holding expenses, invoices, payments and cash transfers, at every as-at date tried. DOES NOT REPRODUCE AS DESCRIBED On current code the statement renders correctly. Measured directly against real books: 6 rows, debit 2,802.75 = credit 2,802.75, at 2026-08-05, 2026-08-06, 2026-08-31 and 2030-01-01 alike; over HTTP, 8 table rows and no empty message. The gathering is correctly company-scoped and App\Billing\TrialBalance is doing its job. WHAT WAS ACTUALLY WRONG — and it produces exactly this symptom The statement can be legitimately empty on books that are not, and the screen gave the WRONG SENTENCE for that case. Two things drop rows, both by design: - a DRAFT invoice is neither a receivable nor income (it was issued to nobody), so it contributes nothing; - an expense attached to a BILL is a payment, not a second cost — the cost is already on the statement as Purchases, so counting it again under its own category would put the same spending in the debit column twice. Both were the ORDINARY state while naming a bill was compulsory, which is the era this was reported in. Measured by reproducing that state on real books: 6 rows as shipped, 5 with every expense on a bill, and **2 with every invoice also a draft** — heading exactly where the reporter ended up. So the report is a true description of a screen that answered "your books are empty" when the truth was "there is nothing to show as at this date, for these two reasons". FIX TrialBalance::asAt() now also reports whether the books hold anything at all, and the view chooses between two sentences. The second names both reasons, so the reader can act on it: "There is nothing to show as at this date. Invoices still marked Draft are not counted — mark them as sent — and spending recorded against a bill appears under Purchases rather than under its own category." VERIFIED real books, as at 2030: 6 rows -> the table real books, as at 2000: 0 rows, hasRecords=true -> "nothing to show" (the new sentence) a company with no records: 0 rows, hasRecords=false -> "nothing recorded yet" (the old one) If the original total-emptiness is ever seen again on current code, please attach the company id — the gathering itself is now measured as correct and I could not make it return nothing on books that hold anything. Full suite 364 tests green; lint clean; 88-request sweep, 0 problems. ===== Full History ===== ^ Date ^ User ^ Field ^ Change ^ | 2026-08-06T12:04:42+01:00 | Nour aboulhosn | issue-new | New Issue | | 2026-08-06T14:57:12+01:00 | Claude | note-added | Note Added: 0000140 | | 2026-08-06T14:57:18+01:00 | Claude | tag-added | Tag Attached: done-by-claude | | 2026-08-06T14:57:18+01:00 | Claude | Assigned To | => Claudine | | 2026-08-06T14:57:18+01:00 | Claude | Status | new => resolved | | 2026-08-06T14:57:18+01:00 | Claude | Resolution | open => fixed | ---- Synced automatically from MantisBT issue #179.