module JP::IncomeTax

Constants

MOD

Public Instance Methods

calc_kouran(pay_amount, pay_date, partner = false, dependent = 0) click to toggle source
# File lib/luca_salary/jp-national-tax/income_tax.rb, line 10
def calc_kouran(pay_amount, pay_date, partner = false, dependent = 0)
  responsible_module(pay_date)
    .send(:monthly_kouran, pay_amount, partner, dependent)
    .to_i
end
responsible_module(date = nil) click to toggle source
# File lib/luca_salary/jp-national-tax/income_tax.rb, line 16
def responsible_module(date = nil)
  if date.nil?
    raise UndefinedDateError
  elsif date.class.name == "String"
    date = Date.parse(date)
  end

  rules = MOD.map{|mod| [mod.send(:effective_date), mod] }.filter{|a| date >= a[0]}

  if rules.length > 0
    rules.sort_by{|a| a[0]}.reverse!.first[1]
  else
    raise NoValidModuleError 
  end
end