Module: TaxJp::ConsumptionTax

Included in:
TaxJp
Defined in:
lib/tax_jp/consumption_tax.rb

Constant Summary collapse

@@consumption_taxes =
TaxJp::Utils.load_yaml('消費税.yml')

Instance Method Summary collapse

Instance Method Details

#rate_on(date, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/tax_jp/consumption_tax.rb', line 5

def rate_on(date, options = {})
  if date.is_a?(String)
    date = Date.parse(date)
  end

  ret = 0
  @@consumption_taxes.reverse_each do |start_date, rate|
    ret = rate
    break if date >= start_date
  end
  
  if options[:percent]
    ret *= 100
  end
  
  ret
end