git.sr.ht/~pingoo/stdx@v0.0.0-20240218134121-094174641f6e/money/vat/moss.go (about) 1 package vat 2 3 import ( 4 "time" 5 ) 6 7 // GetApplicableTaxAtDate returns taxRate and if reverseCharge is applicable 8 // You should check the vatNumber with IsValidVAT(vatNumber) before 9 // passing a vatNumber to this function. 10 func GetApplicableTaxAtDate(countryCode, vatNumber string, date time.Time) (taxRate float64, reverseCharge bool, err error) { 11 if vatNumber != "" { 12 // eu business 13 return 0, true, nil 14 } else { 15 // person from EU or rest of world? 16 rate, ok := StandardRateAtDate(countryCode, date) 17 if ok { 18 // person from eu 19 return rate, false, nil 20 } else { 21 // person from rest of world 22 return 0, false, nil 23 } 24 } 25 } 26 27 // GetApplicableTax is a convenience func for GetApplicableTaxAtDate(...) 28 func GetApplicableTax(countryCode, vatNumber string) (taxRate float64, reverseCharge bool, err error) { 29 return GetApplicableTaxAtDate(countryCode, vatNumber, time.Now()) 30 }