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 ↗

4da9158

fix: round VAT per line and sum the lines

Logged just now.

Its hash and diff arrive with /rk for this task.

1 file+5−01 commit

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}