test(core): golden file for the general ledger by account
Add a golden for general_ledger over [2026-01-01, 2026-01-31] on the shared extended January fixture, with running balances, each posting's split, per-account totals, and entry ids. The close is a posting like any other here; the Feb 5 entry is after the period end and is out. Hand recomputation (plan/golden-worksheets/general-ledger.md): cash has five postings (begin 0, debits 11,500, credits 4,300, ending 7,200); receivables 4,000 - 1,500 = 2,500; equipment 2,500 + 1,500 = 4,000; payable 500; owner's equity 10,000; retained earnings 3,200; service revenue 4,000 credit then the close's 4,000 debit, ending 0; rent 800 debit then the close's 800 credit, ending 0. Entry 6's equipment debit has two accounts on the credit side (cash and payable), so its split is "-Split-"; the same for entry 7's revenue debit (rent and retained earnings) and for the close's two other lines the split is the single account 4000 Service Revenue. Every ending balance ties to the as-of trial balance. Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
This commit is contained in:
1 parent
73e1210248
commit
c5824c4fa2
3 files changed
+385
-1
No files matched your search
@@ -11,7 +11,9 @@
|
||||
//! `plan/golden-worksheets/`; see the worksheet named in each test.
|
||||
|
||||
use chrono::NaiveDate;
|
||||
use ledger_core::reports::{balance_sheet_as_of, profit_and_loss_for_period, trial_balance_as_of};
|
||||
use ledger_core::reports::{
|
||||
balance_sheet_as_of, general_ledger, profit_and_loss_for_period, trial_balance_as_of,
|
||||
};
|
||||
use ledger_core::{AccountId, AccountType, Currency, Ledger, Money, Side};
|
||||
use rust_decimal::Decimal;
|
||||
|
||||
@@ -175,3 +177,14 @@ fn golden_trial_balance_as_of() {
|
||||
serde_json::from_str(include_str!("golden/trial_balance_as_of.json")).unwrap();
|
||||
assert_eq!(got, want);
|
||||
}
|
||||
|
||||
/// By-hand worksheet: `plan/golden-worksheets/general-ledger.md`.
|
||||
#[test]
|
||||
fn golden_general_ledger() {
|
||||
let ledger = golden_company();
|
||||
let report = general_ledger(&ledger, date(1), date(31)).unwrap();
|
||||
let got = serde_json::to_value(&report).unwrap();
|
||||
let want: serde_json::Value =
|
||||
serde_json::from_str(include_str!("golden/general_ledger.json")).unwrap();
|
||||
assert_eq!(got, want);
|
||||
}
|
||||
Reference in new issue
Block a user