/
system-tax.go
51 lines (43 loc) · 1.1 KB
/
system-tax.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package services
import (
"context"
"github.com/driver005/gateway/interfaces"
"github.com/driver005/gateway/types"
"github.com/driver005/gateway/utils"
)
type SystemTaxService struct {
ctx context.Context
r Registry
}
func NewSystemTaxService(r Registry) *SystemTaxService {
return &SystemTaxService{
context.Background(),
r,
}
}
func (s *SystemTaxService) SetContext(context context.Context) *SystemTaxService {
s.ctx = context
return s
}
func (s *SystemProviderService) GetTaxLines(itemLines []interfaces.ItemTaxCalculationLine, shippingLines []interfaces.ShippingTaxCalculationLine, context interfaces.TaxCalculationContext) ([]types.ProviderTaxLine, *utils.ApplictaionError) {
var model []types.ProviderTaxLine
for _, item := range itemLines {
for _, r := range item.Rates {
model = append(model, types.ProviderTaxLine{
Rate: r.Rate,
Name: r.Name,
Code: r.Code,
})
}
}
for _, item := range shippingLines {
for _, r := range item.Rates {
model = append(model, types.ProviderTaxLine{
Rate: r.Rate,
Name: r.Name,
Code: r.Code,
})
}
}
return model, nil
}