test add vouchers and shared service
This commit is contained in:
32
pkg/voucher/service.go
Normal file
32
pkg/voucher/service.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package voucher
|
||||
|
||||
import "math"
|
||||
|
||||
type Rule struct {
|
||||
Type string `json:"type"`
|
||||
Value int64 `json:"value"`
|
||||
}
|
||||
|
||||
type Voucher struct {
|
||||
Code string `json:"code"`
|
||||
Value int64 `json:"discount"`
|
||||
TaxValue int64 `json:"taxValue"`
|
||||
TaxRate int `json:"taxRate"`
|
||||
rules []Rule `json:"rules"`
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
// Add fields here
|
||||
|
||||
}
|
||||
|
||||
func (s *Service) GetVoucher(code string) (*Voucher, error) {
|
||||
value := int64(math.Round(100 * math.Pow(10, 2)))
|
||||
return &Voucher{
|
||||
Code: code,
|
||||
Value: value,
|
||||
TaxValue: int64(float64(value) * 0.2),
|
||||
TaxRate: 2500,
|
||||
rules: nil,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user