Rename to Avrundningsfel, add Öresutjämning row, round total
Summary now shows: - Product rows - Avrundningsfel (rounding error) - Totalt (rounded to nearest integer) - Öresutjämning (difference from transactions to rounded total)
This commit is contained in:
@@ -86,6 +86,7 @@ struct Summary {
|
||||
total_volume: String,
|
||||
grand_total: String,
|
||||
products: Vec<ProductSummary>,
|
||||
avrundningsfel: String,
|
||||
oresutjamning: String,
|
||||
}
|
||||
|
||||
@@ -192,12 +193,15 @@ impl PreparedCustomer {
|
||||
.map(|p| p.amount.parse::<f64>().unwrap())
|
||||
.sum();
|
||||
|
||||
let oresutjamning = total_from_transactions - grand_total;
|
||||
let rounded_grand_total = grand_total.round();
|
||||
let avrundningsfel = grand_total - rounded_grand_total;
|
||||
let oresutjamning = total_from_transactions - rounded_grand_total;
|
||||
|
||||
let summary = Summary {
|
||||
total_volume: fmt(total_volume),
|
||||
grand_total: fmt(grand_total),
|
||||
grand_total: fmt(rounded_grand_total),
|
||||
products,
|
||||
avrundningsfel: fmt(avrundningsfel),
|
||||
oresutjamning: fmt(oresutjamning),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user