config, mcp, gui: specs from sources, spec-blind suites, and the bugs they found
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
ledger-config: parse gets a sourced spec. A fiscal year starts on the first of a month (IRS Pub. 538); tax_classification is read by whole words (Treas. Reg. 301.7701-3, Schedule C instructions; "business corp" no longer reads as an S corp, "corporation or S corporation" is refused); duplicate or blank members and shared capital accounts are refused; a negative or non-grammatical receipt threshold is refused; codes trimmed. tests/spec_config.rs (65 spec-blind tests, 14 properties), fuzz target fuzz_config_parse (weekly). Mutation: 55 of 55 viable caught (from 25/38). The receipt policy moves to ledger-config, with one loader (effective_receipt_policy) and one decimal grammar, so the server and the viewer enforce and show the same rule (the viewer had its own: only expense-like debits, a silent $25 default, and no config.json). ledger-mcp: a module spec (MCP 2025-06-18 tools, JSON-RPC 2.0, the operating contract). Amounts in are exactly -?digits[.digits]; a number that is one account's code and another's id (vendors, classes alike) is refused, not guessed; the threshold is validated at startup. Fixed: add_line with a bad class journaled the line before refusing; profit_and_loss_by_class ignored `class`; aging buckets said "0". A wire in front of rmcp answers malformed JSON with -32700 and invalid requests with -32600 and their id (rmcp dropped the first, omitted the id). tests/spec_mcp.rs (26 spec-blind tests: every tool's result against its own outputSchema, a random-call state machine checking the journal is untouched by every refusal, amount grammar, previews, the receipt policy). ledger-gui: money, accounting, and dollars never round (they rounded to cents, banker's style); export file names avoid Windows device names, trailing dots and spaces, empty names, and 255-byte overflow; specs on attention, history, fuzzy search, and axis ticks. ledger-core: the lifetime profit_and_loss is renamed unclosed_earnings (docs/testing.md #3). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GWVo7x3UHw5kwCUaWxiejX
This commit is contained in:
1 parent
5b8910a1cd
commit
3f20df9700
42 files changed
+4636
-363
No files matched your search
@@ -34,7 +34,7 @@ pub struct EntryInfo {
|
||||
pub vendor: Option<String>,
|
||||
pub reversal_of: Option<EntryId>,
|
||||
pub reversed_by: Option<EntryId>,
|
||||
/// Spending over the receipt threshold with no receipt.
|
||||
/// Covered by the receipt policy (the server's rule) and has no receipt.
|
||||
pub missing_receipt: bool,
|
||||
/// Net effect on cash accounts: positive in, negative out, zero if the
|
||||
/// entry doesn't touch cash.
|
||||
@@ -162,11 +162,13 @@ impl Books {
|
||||
let ledger = snap.ledger().clone();
|
||||
let attachments = snap.attachments(None).map_err(|e| e.to_string())?;
|
||||
let journal = snap.journal().to_vec();
|
||||
let receipt_threshold = settings
|
||||
.receipt_threshold
|
||||
.as_deref()
|
||||
.and_then(|t| t.parse().ok())
|
||||
.unwrap_or(Decimal::new(25, 0));
|
||||
// The server's own rule (config.json, else wanderbooks.toml), so
|
||||
// the viewer flags exactly what the server would refuse.
|
||||
let policy = ledger_config::effective_receipt_policy(
|
||||
&snap.data_dir().join("config.json"),
|
||||
&settings,
|
||||
)?;
|
||||
let receipt_threshold = policy.threshold();
|
||||
let cash_accounts = cash_accounts(&ledger, &settings);
|
||||
let codes = |cs: &[String]| -> Vec<AccountId> {
|
||||
cs.iter()
|
||||
@@ -238,23 +240,14 @@ impl Books {
|
||||
.entry_vendor(id)
|
||||
.and_then(|v| ledger.get_vendor(v))
|
||||
.map(|v| v.name.clone());
|
||||
// Receipts prove spending: hand-made entries (and recurring
|
||||
// drafts) that debit an expense or buy an asset from outside.
|
||||
// Invoices, payments, transfers, draws, closes, and schedules
|
||||
// carry their own evidence.
|
||||
let spends = e.lines().iter().any(|l| {
|
||||
l.side == Side::Debit
|
||||
&& ledger.chart().get(l.account).is_some_and(|a| {
|
||||
a.account_type == AccountType::Expense
|
||||
|| (a.account_type == AccountType::Asset
|
||||
&& !cash_accounts.contains(&a.id)
|
||||
&& !a.name.to_lowercase().contains("receivable"))
|
||||
})
|
||||
});
|
||||
// The receipt policy covers what is posted by hand (journal
|
||||
// entries and recurring drafts); invoices, payments, closes,
|
||||
// depreciation, and schedules carry their own evidence, and a
|
||||
// reversal leans on its original's.
|
||||
let missing_receipt = matches!(origin, "Journal entry" | "Recurring")
|
||||
&& spends
|
||||
&& e.reversal_of().is_none()
|
||||
&& rec.is_empty()
|
||||
&& amount > receipt_threshold;
|
||||
&& policy.receipt_required(&ledger, e);
|
||||
let cash_effect: Decimal = e
|
||||
.lines()
|
||||
.iter()
|
||||
|
||||
Reference in new issue
Block a user