Skip to content

Commit

Permalink
Making sure advance amounts are scaled down for zero
Browse files Browse the repository at this point in the history
  • Loading branch information
samlown committed Oct 9, 2023
1 parent 9816635 commit 6be384b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions bill/payment.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func (p *Payment) totalAdvance(zero num.Amount) *num.Amount {
for _, a := range p.Advances {
sum = sum.MatchPrecision(a.Amount)
sum = sum.Add(a.Amount)
a.Amount = a.Amount.Rescale(zero.Exp())
}
return &sum
}
2 changes: 1 addition & 1 deletion bill/payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestPaymentCalculations(t *testing.T) {
p.calculateAdvances(zero, total)
a := p.totalAdvance(zero)

assert.Equal(t, "20.85", p.Advances[0].Amount.String())
assert.Equal(t, "20.845", a.String())

})
}

0 comments on commit 6be384b

Please sign in to comment.