Class: Workarea::Tax::Category
Class Method Summary
collapse
Instance Method Summary
collapse
#releasable?
add_worker, assert_valid_config!, async, caching_classes?, disable, enable, inline, #run_callbacks, workers, workers_list
#embedded_children
Class Method Details
.find_by_code(code) ⇒ Object
18
19
20
21
22
|
# File 'app/models/workarea/tax/category.rb', line 18
def self.find_by_code(code)
Rails.cache.fetch("tax_rate_#{code}", expires_in: Workarea.config.cache_expirations.tax_rate_by_code) do
find_by(code: code) rescue nil
end
end
|
Instance Method Details
#find_rate(price, country, region, postal_code) ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'app/models/workarea/tax/category.rb', line 24
def find_rate(price, country, region, postal_code)
RateLookup.find_best_rate(
price: price,
country: country,
region: region,
postal_code: postal_code,
category: self
)
end
|
#tiered? ⇒ Boolean
34
35
36
37
38
39
|
# File 'app/models/workarea/tax/category.rb', line 34
def tiered?
@tiered ||= rates.or(
{ :'tier_min.cents'.exists => true },
{ :'tier_max.cents'.exists => true }
).exists?
end
|