Module: JP::IncomeTax
- Defined in:
- lib/luca_salary/jp-national-tax/income_tax.rb,
lib/luca_salary/jp-national-tax/income-tax/income_kouran_2020.rb
Defined Under Namespace
Modules: Kouran2020
Constant Summary collapse
- MOD =
[Kouran2020]
Class Method Summary collapse
- .calc_kouran(pay_amount, pay_date, partner = false, dependent = 0) ⇒ Object
- .responsible_module(date = nil) ⇒ Object
Class Method Details
.calc_kouran(pay_amount, pay_date, partner = false, dependent = 0) ⇒ Object
10 11 12 13 14 |
# 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) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# 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 |