From 19fc5a9553632f28780197f74867eaacd6a818d3 Mon Sep 17 00:00:00 2001 From: matst80 Date: Tue, 11 Nov 2025 09:40:12 +0100 Subject: [PATCH] correct the discount sums --- pkg/cart/cart-grain.go | 2 +- pkg/cart/cart_grain_totals_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/cart/cart-grain.go b/pkg/cart/cart-grain.go index 5c5816b..f9c0e3d 100644 --- a/pkg/cart/cart-grain.go +++ b/pkg/cart/cart-grain.go @@ -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() diff --git a/pkg/cart/cart_grain_totals_test.go b/pkg/cart/cart_grain_totals_test.go index 135a6a7..b05b069 100644 --- a/pkg/cart/cart_grain_totals_test.go +++ b/pkg/cart/cart_grain_totals_test.go @@ -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) } }