-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmoss.go
30 lines (27 loc) · 888 Bytes
/
moss.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
package vat
import (
"time"
)
// GetApplicableTaxAtDate returns taxRate and if reverseCharge is applicable
// You should check the vatNumber with IsValidVAT(vatNumber) before
// passing a vatNumber to this function.
func GetApplicableTaxAtDate(countryCode, vatNumber string, date time.Time) (taxRate float64, reverseCharge bool, err error) {
if vatNumber != "" {
// eu business
return 0, true, nil
} else {
// person from EU or rest of world?
rate, ok := StandardRateAtDate(countryCode, date)
if ok {
// person from eu
return rate, false, nil
} else {
// person from rest of world
return 0, false, nil
}
}
}
// GetApplicableTax is a convenience func for GetApplicableTaxAtDate(...)
func GetApplicableTax(countryCode, vatNumber string) (taxRate float64, reverseCharge bool, err error) {
return GetApplicableTaxAtDate(countryCode, vatNumber, time.Now())
}