Only use two decimals for amounts

This commit is contained in:
Quentin Boyer 2023-11-13 23:30:35 +01:00
parent d8983ea679
commit 7e17fb12c9

View file

@ -223,7 +223,7 @@ where
.iter()
.map(|(name, &value)| row![
text(name).size(TEXT_EMPH1),
text(&format!("{value}")),
text(&format!("{value:.2}")),
horizontal_space(Length::Fill),
component(EditFixed::new(value, name, |v| FixedAmountsMessage::DoAdd(
name.to_string(),
@ -237,7 +237,7 @@ where
.collect()
),
horizontal_rule(LIST_RULE),
text(&format!("Total: {}", self.items.values().sum::<f64>())).size(TEXT_EMPH2)
text(&format!("Total: {:.2}", self.items.values().sum::<f64>())).size(TEXT_EMPH2)
]
.align_items(Alignment::Center);
@ -474,7 +474,7 @@ where
col.push(
row![
horizontal_space(Length::Fill),
text(&format!(" = {value}")),
text(&format!(" = {value:.2}")),
]
.into(),
);
@ -487,7 +487,7 @@ where
),
horizontal_rule(LIST_RULE),
text(&format!(
"Total: {} €",
"Total: {:.2} €",
self.items.values().flat_map(|(_, v)| v).sum::<f64>()
))
.size(TEXT_EMPH2)
@ -1178,7 +1178,7 @@ impl Application for Glaurung {
let def = rule::StyleSheet::appearance(theme, &theme::Rule::Default);
rule::Appearance { width: 3, ..def }
}),
text(&format!("Total spendings: {total_spendings}",)).size(TEXT_EMPH2),
text(&format!("Total spendings: {total_spendings:.2}",)).size(TEXT_EMPH2),
text("Earnings").size(TEXT_H1),
row![
text(&self.config.person_1).size(TEXT_EMPH1),
@ -1198,9 +1198,9 @@ impl Application for Glaurung {
})
]
.align_items(iced::Alignment::Center),
text(&format!("Total earnings: {total_earnings}",)).size(TEXT_EMPH2),
text(&format!("Total earnings: {total_earnings:.2}",)).size(TEXT_EMPH2),
text("Outputs").size(TEXT_H1),
text(&format!("Main account: {main_account}")).size(TEXT_EMPH2),
text(&format!("Main account: {main_account:.2}")).size(TEXT_EMPH2),
component(FixedAmounts {
items: &self.edit.savings,
title: "Savings",