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,
|
total_volume: String,
|
||||||
grand_total: String,
|
grand_total: String,
|
||||||
products: Vec<ProductSummary>,
|
products: Vec<ProductSummary>,
|
||||||
|
avrundningsfel: String,
|
||||||
oresutjamning: String,
|
oresutjamning: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,12 +193,15 @@ impl PreparedCustomer {
|
|||||||
.map(|p| p.amount.parse::<f64>().unwrap())
|
.map(|p| p.amount.parse::<f64>().unwrap())
|
||||||
.sum();
|
.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 {
|
let summary = Summary {
|
||||||
total_volume: fmt(total_volume),
|
total_volume: fmt(total_volume),
|
||||||
grand_total: fmt(grand_total),
|
grand_total: fmt(rounded_grand_total),
|
||||||
products,
|
products,
|
||||||
|
avrundningsfel: fmt(avrundningsfel),
|
||||||
oresutjamning: fmt(oresutjamning),
|
oresutjamning: fmt(oresutjamning),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -165,6 +165,12 @@
|
|||||||
<td>{{ product.amount }} Kr</td>
|
<td>{{ product.amount }} Kr</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
<tr>
|
||||||
|
<td>Avrundningsfel</td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td>{{ customer.summary.avrundningsfel }} Kr</td>
|
||||||
|
</tr>
|
||||||
<tr class="grand-total-row">
|
<tr class="grand-total-row">
|
||||||
<td>Totalt</td>
|
<td>Totalt</td>
|
||||||
<td>{{ customer.summary.total_volume }}</td>
|
<td>{{ customer.summary.total_volume }}</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user