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:
1 parent
05c4b16385
commit
be9bb02e1b
3 files changed
+129
-1
No files matched your search
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"as_of": "2026-01-31",
|
||||
"assets": [
|
||||
{
|
||||
"code": "1000",
|
||||
"name": "Cash",
|
||||
"amount": "7200"
|
||||
},
|
||||
{
|
||||
"code": "1200",
|
||||
"name": "Accounts Receivable",
|
||||
"amount": "2500"
|
||||
},
|
||||
{
|
||||
"code": "1500",
|
||||
"name": "Equipment",
|
||||
"amount": "4000"
|
||||
}
|
||||
],
|
||||
"liabilities": [
|
||||
{
|
||||
"code": "2000",
|
||||
"name": "Accounts Payable",
|
||||
"amount": "500"
|
||||
}
|
||||
],
|
||||
"equity": [
|
||||
{
|
||||
"code": "3000",
|
||||
"name": "Owner's Equity",
|
||||
"amount": "10000"
|
||||
},
|
||||
{
|
||||
"code": "3999",
|
||||
"name": "Retained Earnings",
|
||||
"amount": "3200"
|
||||
}
|
||||
],
|
||||
"current_earnings": "0",
|
||||
"total_assets": "13700",
|
||||
"total_liabilities": "500",
|
||||
"total_equity": "13200"
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
Reference in new issue
Block a user