File tree 1 file changed +7
-12
lines changed
lib/vertex_client/responses
1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change @@ -29,25 +29,20 @@ def product_for_line_item(product)
29
29
30
30
# see lib/vertex_client/rates.rb for hard-coded fallback rates
31
31
def tax_amount ( price , country , state )
32
- if known_us_state? ( country , state )
32
+ if domestic? ( country ) && state . present? && RATES [ 'US' ] . has_key? ( state )
33
+ # state is in the United States and we have an explicit fallback
33
34
price * BigDecimal ( RATES [ 'US' ] [ state ] )
34
- elsif known_non_us_country? ( country )
35
+ elsif !domestic? ( country ) && country . present? && RATES . has_key? ( country )
36
+ # we have an explicit fallback for the country
35
37
price * BigDecimal ( RATES [ country ] )
36
38
else
37
39
BigDecimal ( '0.0' )
38
40
end
39
41
end
40
42
41
- # state is in the United States and we have an explicit fallback
42
- def known_us_state? ( country , state )
43
- return false if country . present? && country != 'US'
44
-
45
- state . present? && RATES [ 'US' ] . has_key? ( state )
46
- end
47
-
48
- # we have an explicit fallback for the country
49
- def known_non_us_country? ( country )
50
- country . present? && country != 'US' && RATES . has_key? ( country )
43
+ def domestic? ( country )
44
+ # we assume a country-less customer is from the US
45
+ country . nil? || country == 'US'
51
46
end
52
47
53
48
def tax_for_line_item ( line_item )
You can’t perform that action at this time.
0 commit comments