test(core): golden file for the balance sheet as of a date

Add a golden for balance_sheet_as_of on 2026-01-31 over the shared
extended January fixture. Closing entries count on a balance sheet, so
the January close's 3,200 to retained earnings is in; the Feb 5 entry is
after the as-of date and is out.

Hand recomputation (plan/golden-worksheets/balance-sheet-as-of.md):
asset balances are debits minus credits -- cash 10,000 + 1,500 - 2,500 -
800 - 1,000 = 7,200, receivables 4,000 - 1,500 = 2,500, equipment 2,500 +
1,500 = 4,000, total assets 13,700. Liabilities: payable 500. Equity:
owner's equity 10,000 plus retained earnings 3,200. Current earnings is
zero because the close zeroed revenue (4,000 credit and 4,000 debit) and
rent (800 debit and 800 credit). Total equity 13,200, and 13,700 = 500 +
13,200. The Feb 5 entry would have shown AR 3,100 and current earnings
600; the golden pins the January figures instead.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
This commit is contained in:
swaitsandDeepSeek V4.1 Flash committed 2026-11-07 09:59:36 -07:00
1 parent 05c4b16385
commit be9bb02e1b
3 files changed
+129 -1

No files matched your search

+12 -1
View File
@@ -11,7 +11,7 @@
//! `plan/golden-worksheets/`; see the worksheet named in each test.
use chrono::NaiveDate;
use ledger_core::reports::profit_and_loss_for_period;
use ledger_core::reports::{balance_sheet_as_of, profit_and_loss_for_period};
use ledger_core::{AccountId, AccountType, Currency, Ledger, Money, Side};
use rust_decimal::Decimal;
@@ -153,3 +153,14 @@ fn golden_profit_and_loss_period() {
serde_json::from_str(include_str!("golden/profit_and_loss_period.json")).unwrap();
assert_eq!(got, want);
}
/// By-hand worksheet: `plan/golden-worksheets/balance-sheet-as-of.md`.
#[test]
fn golden_balance_sheet_as_of() {
let ledger = golden_company();
let report = balance_sheet_as_of(&ledger, date(31)).unwrap();
let got = serde_json::to_value(&report).unwrap();
let want: serde_json::Value =
serde_json::from_str(include_str!("golden/balance_sheet_as_of.json")).unwrap();
assert_eq!(got, want);
}