try new vouchers
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user