refactor(mcp): Decimal arithmetic goes through the kernel (K-U12)
The raw-decimal-arith detector counted 19 places in ledger-mcp before and counts 0 after. No figure changes. Sides become signs through money::on_side and money::signed_amount (server delta, report movement, the P&L-by-class normal-side figure, which collapses two matches into one call); sums and differences of books figures through add_in_range and sub_in_range; the checked sums in helpers and documents through Amount::checked_add with their error handling untouched. The count of withdrawn attachments (a usize, not a Decimal) is the length of the flattened withdraw lists instead of an Iterator::sum of their lengths: the same number. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
5ef5f47ebf
commit
1d612d25b8
7 files changed
+34
-36
No files matched your search
@@ -1343,11 +1343,7 @@ fn preview_lines_for(
|
||||
.account_balance(*account_id)
|
||||
.map_err(|e| e.to_string())?;
|
||||
let normal = account.account_type.normal_side();
|
||||
let delta = if *side == normal {
|
||||
amount.amount
|
||||
} else {
|
||||
-amount.amount
|
||||
};
|
||||
let delta = ledger_core::money::on_side(normal, *side, amount.amount);
|
||||
let after =
|
||||
ledger_core::money::add_exact(before, delta, "the account's balance after the line")
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
Reference in new issue
Block a user