Class: Workarea::Tax::Rate
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
.search(query) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
|
# File 'app/models/workarea/tax/rate.rb', line 32
def self.search(query)
return all unless query.present?
regex = /^#{::Regexp.quote(query)}/i
country = Country[query]
clauses = [{ region: regex }, { postal_code: regex }]
clauses << { country: country } if country.present?
any_of(clauses)
end
|
Instance Method Details
#percentage ⇒ Object
56
57
58
59
60
61
|
# File 'app/models/workarea/tax/rate.rb', line 56
def percentage
percentage_field = super
return percentage_field unless percentage_field.zero?
country_percentage + region_percentage + postal_code_percentage
end
|
#valid? ⇒ Boolean
48
49
50
51
52
53
54
|
# File 'app/models/workarea/tax/rate.rb', line 48
def valid?(*)
super.tap do
self.region = nil if region.blank?
self.postal_code = nil if postal_code.blank?
self.percentage ||= 0
end
end
|