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
+7 -4
View File
@@ -7,6 +7,8 @@ import (
"strconv"
"strings"
"unicode"
"git.k6n.net/mats/platform/money"
)
/*
@@ -74,7 +76,7 @@ const (
type ruleCondition struct {
Kind RuleKind
StringVals []string // For sku / category multi-value list
MinValue *int64 // For numeric threshold rules
MinValue *money.Cents // For numeric threshold rules (minor units)
// Operator reserved for future (e.g., >, >=, ==). Currently always ">=" for numeric kinds.
Operator string
}
@@ -90,13 +92,13 @@ type RuleSet struct {
type Item struct {
Sku string
Category string
UnitPrice int64 // Inc VAT (single unit)
UnitPrice money.Cents // Inc VAT (single unit)
}
// EvalContext bundles cart-like data necessary for evaluation.
type EvalContext struct {
Items []Item
CartTotalInc int64
CartTotalInc money.Cents
}
// Applies returns true if all rule conditions pass for the context.
@@ -268,9 +270,10 @@ func parseNumericRule(frag string) (ruleCondition, error) {
return ruleCondition{}, fmt.Errorf("negative threshold %d", value)
}
mv := money.Cents(value)
return ruleCondition{
Kind: kind,
MinValue: &value,
MinValue: &mv,
Operator: ">=",
}, nil
}
+1 -1
View File
@@ -102,7 +102,7 @@ func TestParseRules_Invalid(t *testing.T) {
}
func TestRuleSet_Applies(t *testing.T) {
rs := MustParseRules("sku=ABC123|XYZ999; category=Shoes|min_total>=10000; min_item_price>=3000")
rs := MustParseRules("sku=ABC123|XYZ999; category=Shoes; min_total>=10000; min_item_price>=3000")
ctx := EvalContext{
Items: []Item{
+8 -7
View File
@@ -7,18 +7,19 @@ import (
"os"
messages "git.k6n.net/mats/go-cart-actor/proto/cart"
"git.k6n.net/mats/platform/money"
)
type Rule struct {
Type string `json:"type"`
Value int64 `json:"value"`
Type string `json:"type"`
Value money.Cents `json:"value"`
}
type Voucher struct {
Code string `json:"code"`
Value int64 `json:"value"`
Rules string `json:"rules"`
Description string `json:"description,omitempty"`
Code string `json:"code"`
Value money.Cents `json:"value"`
Rules string `json:"rules"`
Description string `json:"description,omitempty"`
}
type Service struct {
@@ -42,7 +43,7 @@ func (s *Service) GetVoucher(code string) (*messages.AddVoucher, error) {
return &messages.AddVoucher{
Code: code,
Value: v.Value,
Value: v.Value.Int64(), // proto boundary: AddVoucher.Value is int64
Description: v.Description,
VoucherRules: []string{
v.Rules,