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

- 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 4e96b5f54d
commit cd085108c1
53 files changed
+7872 -104

No files matched your search

+58 -9
View File
@@ -1,5 +1,6 @@
//! Ctrl+K: jump to anything. Pages, reports, accounts, entries (by text,
//! amount, or #id), vendors, and documents, ranked by a simple fuzzy match.
//! amount, or #id), fixed assets (by tag, serial, or description), vendors,
//! and documents, ranked by a simple fuzzy match.
use crate::books::Books;
use crate::fmt;
@@ -16,12 +17,13 @@ pub struct Palette {
focus: bool,
}
struct Item {
icon: &'static str,
title: String,
detail: String,
route: Route,
score: i32,
/// One search result.
pub struct Item {
pub icon: &'static str,
pub title: String,
pub detail: String,
pub route: Route,
pub score: i32,
}
impl Palette {
@@ -75,7 +77,7 @@ impl Palette {
let screen = ctx.content_rect().size();
ui.set_width(620.0_f32.min(screen.x - 48.0).max(200.0));
let edit = egui::TextEdit::singleline(&mut self.query)
.hint_text("Search entries, accounts, vendors, documents, reports…")
.hint_text("Search entries, accounts, assets, vendors, documents, reports…")
.font(theme::regular(16.0))
.frame(egui::Frame::NONE)
.desired_width(f32::INFINITY);
@@ -211,7 +213,19 @@ pub fn fuzzy(hay: &str, query: &str) -> Option<i32> {
best.into_iter().flatten().max()
}
fn search(b: &Books, query: &str) -> Vec<Item> {
/// What the palette lists for `query`, best first (at most 40).
///
/// ```text
/// INVARIANTS (fixed assets; everything else as it was):
/// 1. An asset whose tag equals the trimmed query, ignoring ASCII case,
/// scores 2000: above every other result (an entry's exact #id is
/// 1000).
/// 2. Otherwise an asset is listed when the query fuzzily matches its
/// tag, serial, and description; a query found whole in its tag or
/// serial (ignoring case) adds 500, in its description 50.
/// 3. Every asset result opens Route::Asset(its id).
/// ```
pub fn search(b: &Books, query: &str) -> Vec<Item> {
let q = query.trim();
let mut out: Vec<Item> = Vec::new();
let mut add = |icon: &'static str, title: String, detail: String, route: Route, hay: &str| {
@@ -281,6 +295,40 @@ fn search(b: &Books, query: &str) -> Vec<Item> {
});
}
}
let ql = q.to_lowercase();
for a in b.ledger.registered_assets() {
let tag = a.tag.as_deref().unwrap_or("");
let serial = a.serial.as_deref().unwrap_or("");
let hay = format!("{tag} {serial} {}", a.description);
let score = if !tag.is_empty() && tag.eq_ignore_ascii_case(q) {
Some(2000)
} else {
fuzzy(&hay, q).map(|s| {
let whole = |t: &str| !t.is_empty() && t.to_lowercase().contains(&ql);
s + if whole(tag) || whole(serial) {
500
} else if whole(&a.description) {
50
} else {
0
}
})
};
if let Some(score) = score {
let mut detail = vec!["Fixed asset".to_string()];
if !serial.is_empty() {
detail.push(format!("serial {serial}"));
}
detail.push(format!("in service {}", fmt::date(a.purchase_date)));
out.push(Item {
icon: icon::PACKAGE,
title: b.asset_label(a.id),
detail: detail.join(" · "),
route: Route::Asset(a.id),
score,
});
}
}
for v in b.ledger.list_vendors() {
if let Some(score) = fuzzy(&v.name, q) {
out.push(Item {
@@ -329,6 +377,7 @@ pub fn describe(b: &Books, r: &Route) -> String {
.find(|a| a.id == *id)
.map(|a| a.file_name.clone())
.unwrap_or_default(),
Route::Asset(id) => b.asset_label(*id),
Route::JournalEvent(seq) => format!("Event {seq}"),
_ => String::new(),
}