Fix multiply item price by quantity (#378)

This commit is contained in:
keziasulami 2020-10-14 02:25:06 +07:00 committed by GitHub
parent 491576dfa0
commit 65b5da1a9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -233,7 +233,8 @@ func (cs *checkoutService) PlaceOrder(ctx context.Context, req *pb.PlaceOrderReq
Nanos: 0} Nanos: 0}
total = money.Must(money.Sum(total, *prep.shippingCostLocalized)) total = money.Must(money.Sum(total, *prep.shippingCostLocalized))
for _, it := range prep.orderItems { for _, it := range prep.orderItems {
total = money.Must(money.Sum(total, *it.Cost)) multPrice := money.MultiplySlow(*it.Cost, uint32(it.GetItem().GetQuantity()))
total = money.Must(money.Sum(total, multPrice))
} }
txID, err := cs.chargeCard(ctx, &total, req.CreditCard) txID, err := cs.chargeCard(ctx, &total, req.CreditCard)

View file

@ -333,7 +333,8 @@ func (fe *frontendServer) placeOrderHandler(w http.ResponseWriter, r *http.Reque
totalPaid := *order.GetOrder().GetShippingCost() totalPaid := *order.GetOrder().GetShippingCost()
for _, v := range order.GetOrder().GetItems() { for _, v := range order.GetOrder().GetItems() {
totalPaid = money.Must(money.Sum(totalPaid, *v.GetCost())) multPrice := money.MultiplySlow(*v.GetCost(), uint32(v.GetItem().GetQuantity()))
totalPaid = money.Must(money.Sum(totalPaid, multPrice))
} }
currencies, err := fe.getCurrencies(r.Context()) currencies, err := fe.getCurrencies(r.Context())