correct the discount sums
This commit is contained in:
@@ -249,7 +249,7 @@ func (c *CartGrain) UpdateTotals() {
|
||||
c.TotalDiscount = NewPrice()
|
||||
|
||||
for _, item := range c.Items {
|
||||
rowTotal := MultiplyPrice(item.Price, int64(item.Quantity))
|
||||
rowTotal := MultiplyPrice(*item.OrgPrice, int64(item.Quantity))
|
||||
|
||||
if item.OrgPrice != nil {
|
||||
diff := NewPrice()
|
||||
|
||||
@@ -34,8 +34,8 @@ func TestCartGrainUpdateTotalsBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
// Discount: current implementation computes (OrgPrice - Price) ignoring quantity -> 1500-1250=250
|
||||
if c.TotalDiscount.IncVat != 250 {
|
||||
t.Fatalf("TotalDiscount expected 250 got %d", c.TotalDiscount.IncVat)
|
||||
if c.TotalDiscount.IncVat != 500 {
|
||||
t.Fatalf("TotalDiscount expected 500 got %d", c.TotalDiscount.IncVat)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user