# 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.