Complete refactor to new grpc control plane and only http proxy for carts #4
@@ -70,6 +70,7 @@ type CartGrain struct {
|
|||||||
TotalPrice int64 `json:"totalPrice"`
|
TotalPrice int64 `json:"totalPrice"`
|
||||||
TotalTax int64 `json:"totalTax"`
|
TotalTax int64 `json:"totalTax"`
|
||||||
TotalDiscount int64 `json:"totalDiscount"`
|
TotalDiscount int64 `json:"totalDiscount"`
|
||||||
|
TotalDiscountTax int64 `json:"totalDiscountTax"`
|
||||||
Deliveries []*CartDelivery `json:"deliveries,omitempty"`
|
Deliveries []*CartDelivery `json:"deliveries,omitempty"`
|
||||||
Processing bool `json:"processing"`
|
Processing bool `json:"processing"`
|
||||||
PaymentInProgress bool `json:"paymentInProgress"`
|
PaymentInProgress bool `json:"paymentInProgress"`
|
||||||
@@ -248,6 +249,7 @@ func (c *CartGrain) UpdateTotals() {
|
|||||||
c.TotalPrice = 0
|
c.TotalPrice = 0
|
||||||
c.TotalTax = 0
|
c.TotalTax = 0
|
||||||
c.TotalDiscount = 0
|
c.TotalDiscount = 0
|
||||||
|
c.TotalDiscountTax = 0
|
||||||
for _, item := range c.Items {
|
for _, item := range c.Items {
|
||||||
rowTotal := item.Price * int64(item.Quantity)
|
rowTotal := item.Price * int64(item.Quantity)
|
||||||
rowTax := int64(item.Tax) * int64(item.Quantity)
|
rowTax := int64(item.Tax) * int64(item.Quantity)
|
||||||
@@ -257,10 +259,15 @@ func (c *CartGrain) UpdateTotals() {
|
|||||||
c.TotalTax += rowTax
|
c.TotalTax += rowTax
|
||||||
itemDiff := max(0, item.OrgPrice-item.Price)
|
itemDiff := max(0, item.OrgPrice-item.Price)
|
||||||
c.TotalDiscount += itemDiff * int64(item.Quantity)
|
c.TotalDiscount += itemDiff * int64(item.Quantity)
|
||||||
|
c.TotalDiscountTax += GetTaxAmount(c.TotalDiscount, 2500)
|
||||||
}
|
}
|
||||||
for _, delivery := range c.Deliveries {
|
for _, delivery := range c.Deliveries {
|
||||||
c.TotalPrice += delivery.Price
|
c.TotalPrice += delivery.Price
|
||||||
c.TotalTax += GetTaxAmount(delivery.Price, 2500)
|
c.TotalTax += GetTaxAmount(delivery.Price, 2500)
|
||||||
}
|
}
|
||||||
|
for _, voucher := range c.Vouchers {
|
||||||
|
c.TotalPrice -= voucher.Value
|
||||||
|
c.TotalTax -= voucher.TaxValue
|
||||||
|
c.TotalDiscountTax += voucher.TaxValue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user