class LucaSalary::Jp
Public Class Methods
country_path()
click to toggle source
need for local dictionary loading
# File lib/luca_salary/jp.rb, line 15 def self.country_path __dir__ end
new(dir_path, config = nil, date = nil)
click to toggle source
# File lib/luca_salary/jp.rb, line 8 def initialize(dir_path, config = nil, date = nil) @pjdir = dir_path @date = date @insurance = InsuranceJP.new(@pjdir, config.dig('jp', 'area'), date) end
partner_deduction(income)
click to toggle source
# File lib/luca_salary/jp.rb, line 51 def self.partner_deduction(income) if income <= 9_000_000 380_000 elsif income <= 9_500_000 260_000 elsif income <= 10_000_000 130_000 else 0 end end
year_total(payment, date)
click to toggle source
# File lib/luca_salary/jp.rb, line 34 def self.year_total(payment, date) payment.tap do |p| p['911'] = JpNationalTax::IncomeTax.basic_deduction(p['1'], date) p['916'] = partner_deduction(p['1']) p['912'] = (p['201'] || 0) + (p['202'] || 0) p['901'] = JpNationalTax::IncomeTax.year_salary_taxable(p['1'], date) p['941'] = p['901'] - p['911'] - p['912'] - p['916'] p['961'] = JpNationalTax::IncomeTax.year_tax(p['941'], date) diff = p['961'] - p['203'] if diff.positive? p['3A1'] = diff else p['4A1'] = diff * -1 end end end
Public Instance Methods
calc_payment(profile)
click to toggle source
# File lib/luca_salary/jp.rb, line 19 def calc_payment(profile) {}.tap do |h| select_code(profile, '1').each { |k, v| h[k] = v } h['201'] = @insurance.health_insurance_salary(insurance_rank(profile)) h['202'] = @insurance.pension_salary(pension_rank(profile)) tax_base = sum_code(h, '1', income_tax_exception) - h['201'] - h['202'] h['203'] = JpNationalTax::IncomeTax.calc_kouran(tax_base, Date.today, true) h['211'] = resident_tax(profile) select_code(profile, '3').each { |k, v| h[k] = v } select_code(profile, '4').each { |k, v| h[k] = v } h.merge!(amount_by_code(h)) h['id'] = profile.dig('id') end end
income_tax_exception()
click to toggle source
# File lib/luca_salary/jp.rb, line 63 def income_tax_exception %w[116 118 119 11A 11B] end
insurance_rank(dat)
click to toggle source
# File lib/luca_salary/jp.rb, line 67 def insurance_rank(dat) dat.dig('insurance', 'rank') end
pension_rank(dat)
click to toggle source
# File lib/luca_salary/jp.rb, line 71 def pension_rank(dat) dat.dig('pension', 'rank') end
resident_tax(dat)
click to toggle source
# File lib/luca_salary/jp.rb, line 75 def resident_tax(dat) attr = @date.month == 6 ? 'extra' : 'ordinal' dat.dig('resident', attr) end