File tree Expand file tree Collapse file tree 1 file changed +7
-12
lines changed
lib/vertex_client/responses Expand file tree Collapse file tree 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)
2929
3030 # see lib/vertex_client/rates.rb for hard-coded fallback rates
3131 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
3334 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
3537 price * BigDecimal ( RATES [ country ] )
3638 else
3739 BigDecimal ( '0.0' )
3840 end
3941 end
4042
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'
5146 end
5247
5348 def tax_for_line_item ( line_item )
You can’t perform that action at this time.
0 commit comments