all the refactor
Build and Publish / BuildAndDeployAmd64 (push) Failing after 5s
Build and Publish / BuildAndDeployArm64 (push) Failing after 6s

This commit is contained in:
2026-06-28 17:51:52 +02:00
parent 7db0d236c7
commit aa8b2bdedc
84 changed files with 4328 additions and 2344 deletions
+9 -6
View File
@@ -1,6 +1,7 @@
package promotions
import (
"math"
"time"
"git.k6n.net/mats/go-cart-actor/pkg/cart"
@@ -77,7 +78,9 @@ func (req EvaluateRequest) toCart(tp cart.TaxProvider) *cart.CartGrain {
if qty == 0 {
qty = 1
}
vat := it.VatRate
// it.VatRate is the request rate in raw percent (external input); convert
// to the platform basis-point scale at this boundary.
vat := int(math.Round(float64(it.VatRate) * 100))
if vat == 0 {
vat = defaultVatRate(tp)
}
@@ -102,13 +105,13 @@ func (req EvaluateRequest) toCart(tp cart.TaxProvider) *cart.CartGrain {
return g
}
// defaultVatRate returns the default VAT rate (as a float32 for NewPriceFromIncVat)
// from the provider, or 25 if none is configured.
func defaultVatRate(tp cart.TaxProvider) float32 {
// defaultVatRate returns the default VAT rate in basis points (2500 = 25%) from
// the provider, or 2500 if none is configured.
func defaultVatRate(tp cart.TaxProvider) int {
if tp == nil {
return 25
return 2500
}
return float32(tp.DefaultTaxRate(""))
return tp.DefaultTaxRate("")
}
// contextOptions maps the optional customer/time fields onto context options.