fix(viewer): percentages are Decimal, never f64
fmt::pct_change divided money amounts in f64 (a money path, AGENTS.md rule 1) and fmt::compact shortened amounts through f64; both are now Decimal via kernel::percent_of and round_display. profit::pct, the reports change and share columns follow the one percent rule: no percent of a zero or negative base (shown as nothing or an em dash). Every pages round_dp call goes through round_display; books' cent truncations keep their toward-zero leftover policy through kernel::round_places. Co-Authored-By: Muse Wonder 1.0
This commit is contained in:
1 parent
a414462be7
commit
a7d0c7f2d3
8 files changed
+166
-54
No files matched your search
@@ -190,7 +190,7 @@ fn runway(ui: &mut Ui, b: &Books) {
|
||||
ui.label(RichText::new("The figures are too large to compute.").color(p.muted));
|
||||
return;
|
||||
};
|
||||
let net = net.round_dp(2);
|
||||
let net = fmt::round_display(net, 2);
|
||||
let big = |ui: &mut Ui, label: &str, value: String, color| {
|
||||
ui.vertical(|ui| {
|
||||
ui.label(
|
||||
@@ -224,7 +224,11 @@ fn runway(ui: &mut Ui, b: &Books) {
|
||||
if net < Decimal::ZERO {
|
||||
// Checked: a sub-cent average (lines an earlier version
|
||||
// booked) makes a runway past any calendar.
|
||||
let months_left = b.kpis.cash.checked_div(-net).map(|m| m.round_dp(1));
|
||||
let months_left = b
|
||||
.kpis
|
||||
.cash
|
||||
.checked_div(-net)
|
||||
.map(|m| fmt::round_display(m, 1));
|
||||
let out = months_left
|
||||
.and_then(|m| m.checked_mul(Decimal::from(30)))
|
||||
.and_then(|d| u64::try_from(d).ok())
|
||||
|
||||
Reference in new issue
Block a user