try new vouchers
All checks were successful
Build and Publish / Metadata (push) Successful in 9s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 1m14s
Build and Publish / BuildAndDeployArm64 (push) Successful in 3m57s

This commit is contained in:
matst80
2025-10-14 22:14:22 +02:00
parent f0b6a733f1
commit a7cbdcd0da
6 changed files with 632 additions and 18 deletions

View File

@@ -2,7 +2,8 @@ package voucher
import (
"errors"
"math"
"git.tornberg.me/go-cart-actor/pkg/messages"
)
type Rule struct {
@@ -25,16 +26,14 @@ type Service struct {
var ErrInvalidCode = errors.New("invalid vouchercode")
func (s *Service) GetVoucher(code string) (*Voucher, error) {
value := int64(math.Round(100 * math.Pow(10, 2)))
func (s *Service) GetVoucher(code string) (*messages.AddVoucher, error) {
if code == "" {
return nil, ErrInvalidCode
}
return &Voucher{
Code: code,
Value: value,
TaxValue: int64(float64(value) * 0.2),
TaxRate: 2500,
rules: nil,
value := int64(250_00)
return &messages.AddVoucher{
Code: code,
Value: value,
VoucherRules: make([]*messages.VoucherRule, 0),
}, nil
}