refactor(mcp): previews and totals refuse oversized sums instead of panicking

preview_lines_for (balance before + line), the disposal preview's debits,
the depreciation run's catch-up difference, the digest's account movement
and the payroll remittance total used raw + / - / .sum() on stored or
replayed figures; they now go through ledger_core::money's checked
helpers and return the tool's string error (TooLargeToCompute). Unchanged
for ordinary input.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Sonnet 5.5 committed 2026-11-08 12:23:11 -07:00
1 parent afc7c545da
commit e6104b49d6
4 files changed
+46 -27

No files matched your search

+6 -6
View File
@@ -114,12 +114,12 @@ impl BooksServer {
return Err(party_required("pass agency: the tax agency paid"));
}
// Total before remitting, for the response.
let total: Decimal = store
.ledger()
.payroll_tax_payables()
.iter()
.map(|(_, b)| *b)
.sum();
let total = ledger_core::money::sum_exact_of(
store.ledger().payroll_tax_payables(),
|(_, b)| b,
"the payroll taxes payable",
)
.map_err(|e| e.to_string())?;
let entry_id = store
.remit_payroll_taxes(parse_date(&p.date)?, cash)
.map_err(|e| e.to_string())?;