Class: LucaSalary::JpPayreport

Inherits:
Base
  • Object
show all
Defined in:
lib/luca_salary/jp_payreport.rb

Class Method Summary collapse

Class Method Details

.export(year) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/luca_salary/jp_payreport.rb', line 10

def self.export(year)
  if !system("uconv --version > /dev/null")
    exit 1 # 半角カナ必須
  end

  slips = LucaSalary::Total.new(year).slips
  company = set_company(year.to_i)
  CSV.generate() do |csv|
    slips.each do |s|
      csv << 給与支払報告明細行(LucaSupport::Code.readable(s), company, year.to_i)
    end
  end
end

.set_company(year) ⇒ Object

TODO: extract effective field



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/luca_salary/jp_payreport.rb', line 25

def self.set_company(year)
  {}.tap do |h|
    h['name'] = LucaSupport::CONST.config.dig('company', 'name')
    h['address'] = LucaSupport::CONST.config.dig('company', 'address')
    h['address2'] = LucaSupport::CONST.config.dig('company', 'address2')
    h['tel'] = LucaSupport::CONST.config.dig('company', 'tel')
    h['tax_id'] = LucaSupport::CONST.config.dig('company', 'tax_id')

    raise "会社名、住所の設定は必須" if h['name'].nil? or h['address'].nil?
  end
end