test: totals past exact arithmetic are refused, never a panic
ledger-core/tests/exact_totals.rs: the engine's sum/add/sub helpers, arap's document_total, audit::check_articulation (current_earnings + closed was a raw + that panicked for a public caller's MAX figures) and the frozen close splits' try_ twins refuse at Decimal::MAX with TooLargeToCompute, and give the infallible rules' exact result for ordinary input. ledger-store/tests/exact_totals.rs: an invoice or a bill of enormous lines is refused and journals nothing. (A posted entry's lines are capped when it posts, restored or new, so report sums over posted lines cannot reach the edge; documents are the figures that can.) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5230585e53
commit
5ae26f1288
5 files changed
+199
-14
No files matched your search
@@ -3850,7 +3850,11 @@ impl Ledger {
|
||||
let parts = if posts {
|
||||
regime.allocate(
|
||||
&key,
|
||||
crate::money::add_exact(regime.closed, net, "the members' closed earnings")?,
|
||||
crate::money::add_exact(
|
||||
regime.closed,
|
||||
net,
|
||||
"the members' closed earnings",
|
||||
)?,
|
||||
®ime.given,
|
||||
self.base_currency.allocation_places(),
|
||||
)?
|
||||
@@ -6406,7 +6410,8 @@ impl Ledger {
|
||||
return Err(LedgerError::TooLargeToCompute(format!("{doc}'s figures")));
|
||||
}
|
||||
};
|
||||
let owed = crate::money::sum_exact(after[..=i].iter().copied(), &format!("{doc}'s figures"))?;
|
||||
let owed =
|
||||
crate::money::sum_exact(after[..=i].iter().copied(), &format!("{doc}'s figures"))?;
|
||||
let on = grid[i];
|
||||
let payments: Vec<String> = self
|
||||
.standing_payments(doc)
|
||||
@@ -8425,11 +8430,8 @@ impl Ledger {
|
||||
.ok_or(LedgerError::UnknownAccount(cash_account))?;
|
||||
self.check_controls(&PAYROLL)?;
|
||||
let payables = self.payroll_tax_payables();
|
||||
let total = crate::money::sum_exact_of(
|
||||
&payables,
|
||||
|(_, b)| *b,
|
||||
"the payroll taxes payable",
|
||||
)?;
|
||||
let total =
|
||||
crate::money::sum_exact_of(&payables, |(_, b)| *b, "the payroll taxes payable")?;
|
||||
if total.is_zero() {
|
||||
return Err(LedgerError::NothingToRemit);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user