all the refactor
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"git.k6n.net/mats/go-cart-actor/pkg/flow"
|
||||
"git.k6n.net/mats/go-cart-actor/pkg/order"
|
||||
messages "git.k6n.net/mats/go-cart-actor/proto/order"
|
||||
"git.k6n.net/mats/platform/money"
|
||||
)
|
||||
|
||||
// fromCheckoutReq is the payload the checkout service sends to create an order
|
||||
@@ -164,7 +165,7 @@ func buildFromCheckoutPlaceOrder(id order.OrderId, req *fromCheckoutReq) *messag
|
||||
var total, totalTax int64
|
||||
for _, l := range req.Lines {
|
||||
lineTotal := l.UnitPrice * int64(l.Quantity)
|
||||
lineTax := order.ComputeTax(lineTotal, int(l.TaxRate))
|
||||
lineTax := order.ComputeTax(money.Cents(lineTotal), int(l.TaxRate)).Int64()
|
||||
total += lineTotal
|
||||
totalTax += lineTax
|
||||
po.Lines = append(po.Lines, &messages.OrderLine{
|
||||
@@ -176,6 +177,7 @@ func buildFromCheckoutPlaceOrder(id order.OrderId, req *fromCheckoutReq) *messag
|
||||
TaxRate: l.TaxRate,
|
||||
TotalAmount: lineTotal,
|
||||
TotalTax: lineTax,
|
||||
Location: l.Location,
|
||||
})
|
||||
}
|
||||
po.TotalAmount = total
|
||||
|
||||
Reference in New Issue
Block a user