Complete refactor to new grpc control plane and only http proxy for carts #4

Merged
mats merged 75 commits from refactor/http-proxy into main 2025-10-14 22:31:28 +02:00
Showing only changes of commit 7a79efbb9f - Show all commits

View File

@@ -70,6 +70,7 @@ type CartGrain struct {
TotalPrice int64 `json:"totalPrice"`
TotalTax int64 `json:"totalTax"`
TotalDiscount int64 `json:"totalDiscount"`
TotalDiscountTax int64 `json:"totalDiscountTax"`
Deliveries []*CartDelivery `json:"deliveries,omitempty"`
Processing bool `json:"processing"`
PaymentInProgress bool `json:"paymentInProgress"`
@@ -248,6 +249,7 @@ func (c *CartGrain) UpdateTotals() {
c.TotalPrice = 0
c.TotalTax = 0
c.TotalDiscount = 0
c.TotalDiscountTax = 0
for _, item := range c.Items {
rowTotal := item.Price * int64(item.Quantity)
rowTax := int64(item.Tax) * int64(item.Quantity)
@@ -257,10 +259,15 @@ func (c *CartGrain) UpdateTotals() {
c.TotalTax += rowTax
itemDiff := max(0, item.OrgPrice-item.Price)
c.TotalDiscount += itemDiff * int64(item.Quantity)
c.TotalDiscountTax += GetTaxAmount(c.TotalDiscount, 2500)
}
for _, delivery := range c.Deliveries {
c.TotalPrice += delivery.Price
c.TotalTax += GetTaxAmount(delivery.Price, 2500)
}
for _, voucher := range c.Vouchers {
c.TotalPrice -= voucher.Value
c.TotalTax -= voucher.TaxValue
c.TotalDiscountTax += voucher.TaxValue
}
}