probably fix discounts
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user