all the refactor
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.k6n.net/mats/go-cart-actor/pkg/cart"
|
||||
"git.k6n.net/mats/platform/money"
|
||||
)
|
||||
|
||||
// --- Helpers ---------------------------------------------------------------
|
||||
@@ -63,13 +64,13 @@ func makeCart(totalOverride int64, items []struct {
|
||||
}) *cart.CartGrain {
|
||||
g := cart.NewCartGrain(1, time.Now())
|
||||
for _, it := range items {
|
||||
p := cart.NewPriceFromIncVat(it.priceInc, 0.25)
|
||||
p := cart.NewPriceFromIncVat(it.priceInc, 2500) // 25% in basis points
|
||||
g.Items = append(g.Items, &cart.CartItem{
|
||||
Id: uint32(len(g.Items) + 1),
|
||||
Sku: it.sku,
|
||||
Price: *p,
|
||||
TotalPrice: cart.Price{
|
||||
IncVat: p.IncVat * int64(it.qty),
|
||||
IncVat: p.IncVat.Mul(int64(it.qty)),
|
||||
VatRates: p.VatRates,
|
||||
},
|
||||
Quantity: it.qty,
|
||||
@@ -81,7 +82,7 @@ func makeCart(totalOverride int64, items []struct {
|
||||
// Recalculate totals
|
||||
g.UpdateTotals()
|
||||
if totalOverride >= 0 {
|
||||
g.TotalPrice.IncVat = totalOverride
|
||||
g.TotalPrice.IncVat = money.Cents(totalOverride)
|
||||
}
|
||||
return g
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user