merge: golden files for the date-range P&L, the balance sheet and trial balance as of a date, and the general ledger (branch t3/golden-pl-balance-trial-gl, c5824c4f; reviewed and recomputed independently)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Opus 5.5 committed 2026-11-07 10:05:13 -07:00
commit 805633ef7b
9 files changed
+873

No files matched your search

@@ -0,0 +1,74 @@
# Golden worksheet — balance sheet as of a date
Report: `balance_sheet_as_of(&ledger, 2026-01-31)`.
Golden: `crates/ledger-core/tests/golden/balance_sheet_as_of.json`.
Test: `golden_balance_sheet_as_of` in
`crates/ledger-core/tests/golden_reports.rs`.
## Fixture
The shared extended copy of `fixture_company()`; see
`profit-and-loss-period.md` for the full table and why it was extended.
Entries 1–5 are the original fixture, 6 is a multi-leg purchase, 7 is the
January close, 8 is a February entry after the as-of date:
| # | Date | Description | Lines |
|---|------|-------------|-------|
| 1 | 2026-01-02 | Owner investment | Dr 1000 Cash 10,000.00; Cr 3000 Owner's Equity 10,000.00 |
| 2 | 2026-01-05 | Buy equipment | Dr 1500 Equipment 2,500.00; Cr 1000 Cash 2,500.00 |
| 3 | 2026-01-10 | Invoice client | Dr 1200 Accounts Receivable 4,000.00; Cr 4000 Service Revenue 4,000.00 |
| 4 | 2026-01-15 | January rent | Dr 6000 Rent Expense 800.00; Cr 1000 Cash 800.00 |
| 5 | 2026-01-20 | Client payment | Dr 1000 Cash 1,500.00; Cr 1200 Accounts Receivable 1,500.00 |
| 6 | 2026-01-25 | Buy more equipment | Dr 1500 Equipment 1,500.00; Cr 1000 Cash 1,000.00; Cr 2000 Accounts Payable 500.00 |
| 7 | 2026-01-31 | Close period 2026-01 (generated) | Dr 4000 Service Revenue 4,000.00; Cr 6000 Rent Expense 800.00; Cr 3999 Retained Earnings 3,200.00 |
| 8 | 2026-02-05 | February service | Dr 1200 Accounts Receivable 600.00; Cr 4000 Service Revenue 600.00 |
Accounts: 1000 Cash (Asset), 1200 Accounts Receivable (Asset), 1500
Equipment (Asset), 2000 Accounts Payable (Liability), 3000 Owner's Equity
(Equity), 4000 Service Revenue (Revenue), 6000 Rent Expense (Expense), 3999
Retained Earnings (Equity, created by the close).
## Hand computation
As of 2026-01-31, inclusive: entries 1–7 count, entry 8 (2026-02-05) does
not. Closing entries count on a balance sheet: after a close the earnings
sit in retained earnings.
Asset accounts, normal side debit, amount = debits − credits:
- 1000 Cash: debits 10,000 + 1,500 = 11,500; credits 2,500 + 800 + 1,000 =
4,300; 11,500 − 4,300 = **7,200.00**.
- 1200 Accounts Receivable: debits 4,000; credits 1,500; 4,000 − 1,500 =
**2,500.00**.
- 1500 Equipment: debits 2,500 + 1,500 = 4,000; credits 0; **4,000.00**.
- `total_assets` = 7,200 + 2,500 + 4,000 = **13,700.00**.
Liability accounts, normal side credit, amount = credits − debits:
- 2000 Accounts Payable: credits 500; debits 0; **500.00**.
- `total_liabilities` = **500.00**.
Equity accounts, normal side credit, amount = credits − debits:
- 3000 Owner's Equity: credits 10,000; debits 0; **10,000.00**.
- 3999 Retained Earnings: credits 3,200; debits 0; **3,200.00**.
Current earnings (revenue minus expenses through the as-of date, not yet
closed):
- 4000 Service Revenue: credit 4,000 (entry 3) and the close's debit 4,000
(entry 7) → movement 0, no line.
- 6000 Rent Expense: debit 800 (entry 4) and the close's credit 800 (entry
7) → movement 0, no line.
- `current_earnings` = **0.00**.
Totals:
- `total_equity` = 10,000 + 3,200 + 0 = **13,200.00**.
- Accounting equation: assets 13,700 = liabilities 500 + equity 13,200.
Balanced exactly.
**Entry 8 is left out.** If it were included (wrong for this as-of date),
AR would be 3,100, revenue/current earnings 600, total assets 14,300 and
total equity 13,800 — balanced but dated 2026-02-05. The golden pins the
January-only figures.
+133
View File
@@ -0,0 +1,133 @@
# Golden worksheet — general ledger by account
Report: `general_ledger(&ledger, 2026-01-01, 2026-01-31)`.
Golden: `crates/ledger-core/tests/golden/general_ledger.json`.
Test: `golden_general_ledger` in
`crates/ledger-core/tests/golden_reports.rs`.
## Fixture
The shared extended copy of `fixture_company()`; see
`profit-and-loss-period.md` for the full table and why it was extended.
Entries 1–5 are the original fixture, 6 is a multi-leg purchase, 7 is the
January close, 8 is a February entry after the period end:
| # | Date | Description | Lines |
|---|------|-------------|-------|
| 1 | 2026-01-02 | Owner investment | Dr 1000 Cash 10,000.00; Cr 3000 Owner's Equity 10,000.00 |
| 2 | 2026-01-05 | Buy equipment | Dr 1500 Equipment 2,500.00; Cr 1000 Cash 2,500.00 |
| 3 | 2026-01-10 | Invoice client | Dr 1200 Accounts Receivable 4,000.00; Cr 4000 Service Revenue 4,000.00 |
| 4 | 2026-01-15 | January rent | Dr 6000 Rent Expense 800.00; Cr 1000 Cash 800.00 |
| 5 | 2026-01-20 | Client payment | Dr 1000 Cash 1,500.00; Cr 1200 Accounts Receivable 1,500.00 |
| 6 | 2026-01-25 | Buy more equipment | Dr 1500 Equipment 1,500.00; Cr 1000 Cash 1,000.00; Cr 2000 Accounts Payable 500.00 |
| 7 | 2026-01-31 | Close period 2026-01 (generated) | Dr 4000 Service Revenue 4,000.00; Cr 6000 Rent Expense 800.00; Cr 3999 Retained Earnings 3,200.00 |
| 8 | 2026-02-05 | February service | Dr 1200 Accounts Receivable 600.00; Cr 4000 Service Revenue 600.00 |
Accounts: 1000 Cash (Asset), 1200 Accounts Receivable (Asset), 1500
Equipment (Asset), 2000 Accounts Payable (Liability), 3000 Owner's Equity
(Equity), 4000 Service Revenue (Revenue), 6000 Rent Expense (Expense), 3999
Retained Earnings (Equity, created by the close). Entry ids are assigned in
posting order, 1–8; the close creates account 3999 without consuming an
entry id, and entry 8 is the February entry.
## Hand computation
The period is 2026-01-01 through 2026-01-31, both inclusive. Nothing is
dated before the period, so every beginning balance is 0. Entries 1–7 are
in the period and **entry 8 is after it and excluded**. The closing entry
7 is a posting like any other (the general ledger is not a P&L).
Splits (QuickBooks convention): the one account on the entry's opposite
side, else `-Split-` when that side has several accounts. Running balances
are on each account's normal side (assets and expenses debit, the rest
credit). Accounts are listed in code order.
### 1000 Cash — Asset, beginning 0
| Date | Entry | Description | Split | Debit | Credit | Balance |
|---|---|---|---|---|---|---|
| 2026-01-02 | 1 | Owner investment | 3000 Owner's Equity | 10,000.00 | 0 | 10,000.00 |
| 2026-01-05 | 2 | Buy equipment | 1500 Equipment | 0 | 2,500.00 | 7,500.00 |
| 2026-01-15 | 4 | January rent | 6000 Rent Expense | 0 | 800.00 | 6,700.00 |
| 2026-01-20 | 5 | Client payment | 1200 Accounts Receivable | 1,500.00 | 0 | 8,200.00 |
| 2026-01-25 | 6 | Buy more equipment | 1500 Equipment | 0 | 1,000.00 | 7,200.00 |
Debits 10,000 + 1,500 = 11,500; credits 2,500 + 800 + 1,000 = 4,300;
ending 11,500 − 4,300 = **7,200.00**.
### 1200 Accounts Receivable — Asset, beginning 0
| Date | Entry | Description | Split | Debit | Credit | Balance |
|---|---|---|---|---|---|---|
| 2026-01-10 | 3 | Invoice client | 4000 Service Revenue | 4,000.00 | 0 | 4,000.00 |
| 2026-01-20 | 5 | Client payment | 1000 Cash | 0 | 1,500.00 | 2,500.00 |
Debits 4,000; credits 1,500; ending **2,500.00**. (Entry 8's 600 debit is
dated 2026-02-05 and is excluded; including it would add a third posting
and an ending of 3,100.)
### 1500 Equipment — Asset, beginning 0
| Date | Entry | Description | Split | Debit | Credit | Balance |
|---|---|---|---|---|---|---|
| 2026-01-05 | 2 | Buy equipment | 1000 Cash | 2,500.00 | 0 | 2,500.00 |
| 2026-01-25 | 6 | Buy more equipment | -Split- | 1,500.00 | 0 | 4,000.00 |
Entry 6's Debit has **two** accounts on the opposite (credit) side, 1000
Cash and 2000 Accounts Payable, so its split is `-Split-`. Debits 4,000;
credits 0; ending **4,000.00**.
### 2000 Accounts Payable — Liability, beginning 0
| Date | Entry | Description | Split | Debit | Credit | Balance |
|---|---|---|---|---|---|---|
| 2026-01-25 | 6 | Buy more equipment | 1500 Equipment | 0 | 500.00 | 500.00 |
Debits 0; credits 500; ending **500.00**.
### 3000 Owner's Equity — Equity, beginning 0
| Date | Entry | Description | Split | Debit | Credit | Balance |
|---|---|---|---|---|---|---|
| 2026-01-02 | 1 | Owner investment | 1000 Cash | 0 | 10,000.00 | 10,000.00 |
Debits 0; credits 10,000; ending **10,000.00**.
### 3999 Retained Earnings — Equity, beginning 0
| Date | Entry | Description | Split | Debit | Credit | Balance |
|---|---|---|---|---|---|---|
| 2026-01-31 | 7 | Close period 2026-01 | 4000 Service Revenue | 0 | 3,200.00 | 3,200.00 |
The close's Credit has only 4000 Service Revenue on the opposite (debit)
side, so its split is that one account. Debits 0; credits 3,200; ending
**3,200.00**.
### 4000 Service Revenue — Revenue, beginning 0
| Date | Entry | Description | Split | Debit | Credit | Balance |
|---|---|---|---|---|---|---|
| 2026-01-10 | 3 | Invoice client | 1200 Accounts Receivable | 0 | 4,000.00 | 4,000.00 |
| 2026-01-31 | 7 | Close period 2026-01 | -Split- | 4,000.00 | 0 | 0.00 |
The close's Debit has two accounts on the opposite (credit) side, 6000 Rent
Expense and 3999 Retained Earnings, so its split is `-Split-`. Debits
4,000; credits 4,000; ending **0.00** (the account is still listed because
it has postings in the period).
### 6000 Rent Expense — Expense, beginning 0
| Date | Entry | Description | Split | Debit | Credit | Balance |
|---|---|---|---|---|---|---|
| 2026-01-15 | 4 | January rent | 1000 Cash | 800.00 | 0 | 800.00 |
| 2026-01-31 | 7 | Close period 2026-01 | 4000 Service Revenue | 0 | 800.00 | 0.00 |
Debits 800; credits 800; ending **0.00** (listed for its postings).
## Cross-check
Each ending balance equals the 2026-01-31 trial balance in
`trial-balance-as-of.md`: cash 7,200, receivables 2,500, equipment 4,000,
payable 500, owner's equity 10,000, retained earnings 3,200, revenue 0,
rent 0. The running balances are consistent at every step, and entry 8
(2026-02-05) never appears.
@@ -0,0 +1,66 @@
# Golden worksheet — profit and loss for a date range
Report: `profit_and_loss_for_period(&ledger, 2026-01-01, 2026-01-31, None)`.
Golden: `crates/ledger-core/tests/golden/profit_and_loss_period.json`.
Test: `golden_profit_and_loss_period` in
`crates/ledger-core/tests/golden_reports.rs`.
## Fixture
The fixture is an **extended copy** of `fixture_company()` in
`tests/invariants.rs` (the hand-verified January 2026 fixture), because the
original has neither a closing entry nor an entry dated after an as-of date
and no multi-leg entry (needed for the general-ledger split). The six
original entries are unchanged; entries 6–8 are the extension:
| # | Date | Description | Lines |
|---|------|-------------|-------|
| 1 | 2026-01-02 | Owner investment | Dr 1000 Cash 10,000.00; Cr 3000 Owner's Equity 10,000.00 |
| 2 | 2026-01-05 | Buy equipment | Dr 1500 Equipment 2,500.00; Cr 1000 Cash 2,500.00 |
| 3 | 2026-01-10 | Invoice client | Dr 1200 Accounts Receivable 4,000.00; Cr 4000 Service Revenue 4,000.00 |
| 4 | 2026-01-15 | January rent | Dr 6000 Rent Expense 800.00; Cr 1000 Cash 800.00 |
| 5 | 2026-01-20 | Client payment | Dr 1000 Cash 1,500.00; Cr 1200 Accounts Receivable 1,500.00 |
| 6 | 2026-01-25 | Buy more equipment | Dr 1500 Equipment 1,500.00; Cr 1000 Cash 1,000.00; Cr 2000 Accounts Payable 500.00 |
| 7 | 2026-01-31 | Close period 2026-01 (generated by `close_period`) | Dr 4000 Service Revenue 4,000.00; Cr 6000 Rent Expense 800.00; Cr 3999 Retained Earnings 3,200.00 |
| 8 | 2026-02-05 | February service | Dr 1200 Accounts Receivable 600.00; Cr 4000 Service Revenue 600.00 |
Every entry balances: 1–5 are two-line pairs; 6 is 1,500 = 1,000 + 500; 7
is 4,000 = 800 + 3,200; 8 is 600 = 600.
Accounts: 1000 Cash (Asset), 1200 Accounts Receivable (Asset), 1500
Equipment (Asset), 2000 Accounts Payable (Liability), 3000 Owner's Equity
(Equity), 4000 Service Revenue (Revenue), 6000 Rent Expense (Expense), and
3999 Retained Earnings (Equity, created by the close).
## Hand computation
The range is 2026-01-01 through 2026-01-31, both inclusive.
- **Closing entry 7 is inside the range but excluded.** A close moves
earnings into retained earnings; it neither earns revenue nor spends
money (rules.md B-14/B-11). Counting it would make the month break even.
- **Entry 8 (2026-02-05) is outside the range and excluded.**
Revenue accounts, normal side credit, amount = credits − debits:
- 4000 Service Revenue: entry 3 credits 4,000; entry 7 is the close
(excluded); entry 8 is February (excluded). 4,000 − 0 = **4,000.00**.
Expense accounts, normal side debit, amount = debits − credits:
- 6000 Rent Expense: entry 4 debits 800; entry 7 is the close (excluded).
800 − 0 = **800.00**.
Totals:
- `total_revenue` = **4,000.00**
- `total_expenses` = **800.00**
- net income = 4,000 − 800 = **3,200.00**
Cross-check against the close: entry 7 credits Retained Earnings exactly
3,200, which is January's revenue minus expenses. The P&L for the closed
month therefore reports the same earnings the close moved.
The fixture therefore demonstrates both exclusions the parity row asks
for: a closing entry inside the range is not counted, and a later-period
entry is not counted.
@@ -0,0 +1,67 @@
# Golden worksheet — trial balance as of a date
Report: `trial_balance_as_of(&ledger, 2026-01-31)`.
Golden: `crates/ledger-core/tests/golden/trial_balance_as_of.json`.
Test: `golden_trial_balance_as_of` in
`crates/ledger-core/tests/golden_reports.rs`.
## Fixture
The shared extended copy of `fixture_company()`; see
`profit-and-loss-period.md` for the full table and why it was extended.
Entries 1–5 are the original fixture, 6 is a multi-leg purchase, 7 is the
January close, 8 is a February entry after the as-of date:
| # | Date | Description | Lines |
|---|------|-------------|-------|
| 1 | 2026-01-02 | Owner investment | Dr 1000 Cash 10,000.00; Cr 3000 Owner's Equity 10,000.00 |
| 2 | 2026-01-05 | Buy equipment | Dr 1500 Equipment 2,500.00; Cr 1000 Cash 2,500.00 |
| 3 | 2026-01-10 | Invoice client | Dr 1200 Accounts Receivable 4,000.00; Cr 4000 Service Revenue 4,000.00 |
| 4 | 2026-01-15 | January rent | Dr 6000 Rent Expense 800.00; Cr 1000 Cash 800.00 |
| 5 | 2026-01-20 | Client payment | Dr 1000 Cash 1,500.00; Cr 1200 Accounts Receivable 1,500.00 |
| 6 | 2026-01-25 | Buy more equipment | Dr 1500 Equipment 1,500.00; Cr 1000 Cash 1,000.00; Cr 2000 Accounts Payable 500.00 |
| 7 | 2026-01-31 | Close period 2026-01 (generated) | Dr 4000 Service Revenue 4,000.00; Cr 6000 Rent Expense 800.00; Cr 3999 Retained Earnings 3,200.00 |
| 8 | 2026-02-05 | February service | Dr 1200 Accounts Receivable 600.00; Cr 4000 Service Revenue 600.00 |
Accounts: 1000 Cash (Asset), 1200 Accounts Receivable (Asset), 1500
Equipment (Asset), 2000 Accounts Payable (Liability), 3000 Owner's Equity
(Equity), 4000 Service Revenue (Revenue), 6000 Rent Expense (Expense), 3999
Retained Earnings (Equity, created by the close).
## Hand computation
As of 2026-01-31, inclusive: entries 1–7 count, entry 8 (2026-02-05) does
not. A trial balance shows each account's signed movement: debit positive,
credit negative, then in one column on the side it falls (never negative).
Per account over entries 1–7:
- **1000 Cash:** debits 10,000 (e1) + 1,500 (e5) = 11,500; credits 2,500
(e2) + 800 (e4) + 1,000 (e6) = 4,300; net debit 11,500 − 4,300 =
**debit 7,200.00**.
- **1200 Accounts Receivable:** debits 4,000 (e3); credits 1,500 (e5); net
**debit 2,500.00**.
- **1500 Equipment:** debits 2,500 (e2) + 1,500 (e6) = 4,000; credits 0;
**debit 4,000.00**.
- **2000 Accounts Payable:** credits 500 (e6); debits 0; **credit 500.00**.
- **3000 Owner's Equity:** credits 10,000 (e1); debits 0; **credit
10,000.00**.
- **3999 Retained Earnings:** credits 3,200 (e7); debits 0; **credit
3,200.00**.
- **4000 Service Revenue:** credits 4,000 (e3), debits 4,000 (close e7);
net 0 — the invariant says a zero balance is not listed.
- **6000 Rent Expense:** debits 800 (e4), credits 800 (close e7); net 0 —
not listed.
Lines are in code order: 1000, 1200, 1500, 2000, 3000, 3999.
Totals:
- `total_debits` = 7,200 + 2,500 + 4,000 = **13,700.00**.
- `total_credits` = 500 + 10,000 + 3,200 = **13,700.00**.
- Balanced exactly.
**Entry 8 is left out.** If included it would add 600 to AR (3,100) and
600 to revenue (credit 600), shifting both columns by 600; the golden pins
the post-closing January trial balance after the close, with the February
entry absent.