Saved

Acme LogisticsNorthwind[ ] step · ` back
4/6
2/3
2/3
2/5
Skip to the editor

[LED-1] Fix the VAT rounding

101 ↗PR #107 ↗

Changes logged for this task

Everything the sessions changed for this task

Each file as the logged commits left it. Every hunk names the commit that made it: open one to read that change on its own.

2 files+9−02 commits

Mcrates/billing/src/vat.rs +5 −0
@@ -10,3 +10,8 @@ pub fn vat_for(line: &Line, rate_percent: u32) -> i64 {
10pub fn vat_total(lines: &[Line], rate_percent: u32) -> i64 {10pub fn vat_total(lines: &[Line], rate_percent: u32) -> i64 {
11 lines.iter().map(|line| vat_for(line, rate_percent)).sum()11 lines.iter().map(|line| vat_for(line, rate_percent)).sum()
12}12}
13
14/// A zero rate has no VAT.
15pub fn is_exempt(rate_percent: u32) -> bool {
16 rate_percent == 0
17}
Acrates/billing/tests/vat_total.rs +4 −0
@@ -0,0 +1,4 @@
1#[test]
2fn rounds_per_line() {
3 assert_eq!(vat_total_of_twelve_lines(), 288);
4}