refactor(display): one rounding for presentation
Move format_amount's rounding half (half away from zero, never a negative zero) into ledger-import::format::round_display, through the kernel's round_places. format_amount, amount_parts, the PDF percent column, xlsx's exact_f64 and ledger-package's text padding all call it, so a display change never changes a booked figure. Co-Authored-By: Muse Wonder 1.0
This commit is contained in:
1 parent
4da1c5b30f
commit
a414462be7
6 files changed
+81
-5
No files matched your search
@@ -442,7 +442,7 @@ fn exact_text(d: Decimal) -> String {
|
||||
/// cents, at most 15 significant digits. None otherwise.
|
||||
fn exact_f64(d: Decimal) -> Option<f64> {
|
||||
use rust_decimal::prelude::ToPrimitive;
|
||||
let cents = d.round_dp(2);
|
||||
let cents = crate::format::round_display(d, 2);
|
||||
if cents != d || cents.abs() > Decimal::new(999_999_999_999_999, 2) {
|
||||
return None;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user