probably fix discounts
All checks were successful
Build and Publish / Metadata (push) Successful in 9s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 1m18s
Build and Publish / BuildAndDeployArm64 (push) Successful in 4m35s

This commit is contained in:
matst80
2025-10-18 15:42:30 +02:00
parent e127251a60
commit 662b381a34

View File

@@ -249,19 +249,22 @@ func (c *CartGrain) UpdateTotals() {
for _, item := range c.Items { for _, item := range c.Items {
rowTotal := MultiplyPrice(item.Price, int64(item.Quantity)) rowTotal := MultiplyPrice(item.Price, int64(item.Quantity))
item.TotalPrice = *rowTotal
c.TotalPrice.Add(*rowTotal)
if item.OrgPrice != nil { if item.OrgPrice != nil {
diff := NewPrice() diff := NewPrice()
diff.Add(*item.OrgPrice) diff.Add(*item.OrgPrice)
diff.Subtract(item.Price) diff.Subtract(item.Price)
diff.Multiply(int64(item.Quantity))
rowTotal.Subtract(*diff)
item.Discount = diff
if diff.IncVat > 0 { if diff.IncVat > 0 {
c.TotalDiscount.Add(*diff) c.TotalDiscount.Add(*diff)
} }
} }
item.TotalPrice = *rowTotal
c.TotalPrice.Add(*rowTotal)
} }
for _, delivery := range c.Deliveries { for _, delivery := range c.Deliveries {
c.TotalPrice.Add(delivery.Price) c.TotalPrice.Add(delivery.Price)