Fixed assets, fully featured: tags, serials, acquisition links, label sheets, the fixed asset register, and an Assets section in the viewer; fix a flaky verify
check / check (push) Waiting to run

- core: asset tags (generated PREFIX-0001 or the human's own; unique ignoring case; never reused by another asset) and serial numbers (rules.md B-24); a journaled link from an asset to the entry that acquired it (posted, unreversed, debiting the cost account); fixed_asset_register(as_of), reconciled to the GL (unposted depreciation, unregistered cost)
- store: asset.tagged, asset.serial_set, asset.acquisition_linked journaled, replayed, projected (schema v9); differs_from now also compares control roles and tag history
- config: [books] asset_tag_prefix, default the company's initials without legal-form words
- import: Avery 5160/8160 label sheets with QR codes (geometry vendored from Avery, docs/spec/sources/avery-5160.md); the register as XLSX and PDF
- mcp: register_asset tags (and links) automatically; books.label_asset, books.asset_labels; asset tools take a tag; books.show asset / assets page / register report; export fixed_asset_register (json, csv, xlsx, pdf) and in the CPA package
- viewer: Assets page (register, reconciliation), asset page (identity, schedule posted vs not, entries, documents), Fixed asset register report, global search by tag/serial/description, journal text, needs-attention items
- fix: verify compared snapshot amounts as strings; a zero total summed in hash-map order could print "0" or "0.00", so agreeing books failed verify at random. Now by value (regression test)
- tests: spec-blind suites for tags, register, prefix, store, MCP; label and register PDF/XLSX tests; viewer tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GWVo7x3UHw5kwCUaWxiejX
This commit is contained in:
swaitsandClaude Opus 5.5 committed 2026-10-15 12:18:00 -06:00
1 parent 767fd469cd
commit ee7e205f5c
53 files changed
+7872 -104

No files matched your search

+64
View File
@@ -417,3 +417,67 @@ fn disposal_on_the_purchase_date_is_allowed() {
Err(ledger_core::LedgerError::DisposalBeforePurchase(_))
));
}
/// An asset links to the posted entry that acquired it, if that entry
/// debits its cost account and isn't a reversal or reversed; a correction
/// (reverse, repost) links the replacement. Refusals change nothing.
#[test]
fn acquisition_links_only_to_a_live_entry_debiting_the_cost_account() {
use ledger_core::{LedgerError, Side};
let (mut ledger, cost, accum, expense) = test_ledger();
let capital = ledger
.add_account("3000", "Capital", AccountType::Equity, None, false)
.unwrap();
let id = van_asset(&mut ledger, 1650, cost, accum, expense);
let post = |l: &mut Ledger, dr: u64, cr: u64| {
let e = l.create_entry(date(2026, 1, 15), "contribution");
l.add_line(e, dr, Side::Debit, usd("1650")).unwrap();
l.add_line(e, cr, Side::Credit, usd("1650")).unwrap();
l.post_entry(e).unwrap();
e
};
let original = post(&mut ledger, cost, capital);
let wrong = post(&mut ledger, expense, capital);
let draft = ledger.create_entry(date(2026, 1, 15), "draft");
let refused = |l: &mut Ledger, entry: u64| {
let before = l.clone();
let err = l.set_asset_acquisition(id, entry).unwrap_err();
assert_eq!(*l, before);
err
};
assert!(matches!(
refused(&mut ledger, wrong),
LedgerError::AcquisitionEntryMismatch { .. }
));
assert!(matches!(
refused(&mut ledger, draft),
LedgerError::AcquisitionEntryMismatch { .. }
));
assert!(matches!(
refused(&mut ledger, 999),
LedgerError::UnknownEntry(999)
));
assert!(matches!(
ledger.set_asset_acquisition(99, original),
Err(LedgerError::UnknownAsset(99))
));
ledger.set_asset_acquisition(id, original).unwrap();
assert_eq!(ledger.get_asset(id).unwrap().acquired_by, Some(original));
// Corrected: reversed, reposted. Neither the original nor its
// reversal can be the link; the replacement can.
let reversal = ledger
.reverse_entry(original, date(2026, 1, 16), "joint, not one member's")
.unwrap();
let replacement = post(&mut ledger, cost, capital);
assert!(matches!(
refused(&mut ledger, original),
LedgerError::AcquisitionEntryMismatch { .. }
));
assert!(matches!(
refused(&mut ledger, reversal),
LedgerError::AcquisitionEntryMismatch { .. }
));
ledger.set_asset_acquisition(id, replacement).unwrap();
assert_eq!(ledger.get_asset(id).unwrap().acquired_by, Some(replacement));
}