Class: Luca::Jp::Chihouzei

Inherits:
LucaBook::State
  • Object
show all
Includes:
Common, Util, LucaSupport::View
Defined in:
lib/luca/jp/chihouzei.rb

Instance Method Summary collapse

Methods included from Util

beppyo2_config, config, eltax_config, etax_date, form_rdf, gaikyo_config, gengou, it_part_config, prepaid_tax, refund_tax, render_attr, tokyo23?, uchiwake_account_config, wareki, 中間還付税額, 期首期末残高, 納付税額, 純資産期中増減

Methods included from Common

レポート種別, 一般区分の税額, 一般寄付金の損金算入限度額, 中小企業の軽減税率対象を超える所得, 中小企業の軽減税率対象所得, 中小企業の軽減税額, 中間還付税額, 事業所数による分割課税標準, 事業税の分割課税標準, 別表四所得調整, 地方法人税額, 地方消費税中間納付額, 地方税資本金等の額, 均等割, 寄付金の損金不算入額, 当期控除計, 当期繰越損失, 従業員数による分割課税標準, 所得400万以下, 所得800万以下, 所得800万超, 所得割400万以下, 所得割800万以下, 所得割800万超, 所得割税率400万以下, 所得割税率800万以下, 所得割税率800万超, 所得金額, 期末資本金, 期首繰越損失, 未納事業税期中増減, 法人税割, 法人税割税率, 消費税中間納付額, 消費税課税売上高, 特別法人事業税, 税額計算, 納付税額, 翌期繰越損失, 資本金等の額, 軽減税率不適用法人

Instance Method Details

#export_json(report_cfg, ext_config: nil) ⇒ Object



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/luca/jp/chihouzei.rb', line 112

def export_json(report_cfg, ext_config: nil)
  records = kani(report_cfg, export: true, ext_config: ext_config)
  label = @report_category == 'city' ? '市町村住民税' : '都道府県住民税'
  {}.tap do |item|
    item['date'] = @end_date
    item['debit'] = []
    item['credit'] = []
    unless @report_category == 'city'
      records[:jigyouzei].each do |k, dat|
        if dat[:chukan] > 0
          item['credit'] << { 'label' => karibarai_label(k, @report_category), 'amount' => dat[:chukan] }
        end
        if dat[:chukan] > dat[:zeigaku]
          item['debit'] << { 'label' => '未収地方事業税', 'amount' => dat[:chukan] - dat[:zeigaku] }
        else
          item['credit'] << { 'label' => '未払地方事業税', 'amount' => dat[:zeigaku] - dat[:chukan] }
        end
        item['debit'] << { 'label' => '地方事業税', 'amount' => dat[:zeigaku] } if dat[:zeigaku] > 0
      end
    end
    records[:juminzei].each do |k, dat|
      if dat[:chukan] > 0
        item['credit'] << { 'label' => karibarai_label(k, @report_category), 'amount' => dat[:chukan] }
      end
      if dat[:chukan] > dat[:zeigaku]
        item['debit'] << { 'label' => "未収#{label}", 'amount' => dat[:chukan] - dat[:zeigaku] }
      else
        item['credit'] << { 'label' => "未払#{label}", 'amount' => dat[:zeigaku] - dat[:chukan] }
      end
      item['debit'] << { 'label' => label, 'amount' => dat[:zeigaku] } if dat[:zeigaku] > 0
    end
    item['x-customer'] = records[:customer] unless records[:customer].nil?
    item['x-editor'] = 'LucaJp'
  end
end

#kani(report_cfg, export: false, ext_config: nil) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/luca/jp/chihouzei.rb', line 20

def kani(report_cfg, export: false, ext_config: nil)
  set_pl(4)
  set_bs(4)
  @issue_date = Date.today
  @software = 'LucaJp'
  @jimusho_name = report_cfg['jimusho_name']
  @report_category = report_cfg['type']
  @employee = report_cfg['employee'] || 1
  @office_count = report_cfg['office_count'] || 1
  # 自治体ごとの税率カスタマイズ
  @houjinzeiwari_rate = report_cfg['houjinzeiwari']
  @shotoku399 = report_cfg['shotoku399']
  @shotoku401 = report_cfg['shotoku401']
  @shotoku801 = report_cfg['shotoku801']

  別表四所得調整(ext_config)
  @税額 = 税額計算
  jichitai = @report_category == 'city' ? :shimin : :kenmin
  @均等割 = report_cfg['kintouwari'] || @税額.dig(jichitai, :kintou)
  @確定法人税割 = @税額.dig(jichitai, :houjinzei)
  @地方特別法人事業税中間納付 = prepaid_tax('1854', @jimusho_name)
  @所得割中間納付 = prepaid_tax('1855', @jimusho_name)
  @法人税割中間納付 = prepaid_tax(
    @report_category == 'city' ? '185D' : '1859',
    @jimusho_name
  )
  @均等割中間納付 = prepaid_tax(
    @report_category == 'city' ? '185E' : '185A',
    @jimusho_name
  )
  @所得割 = @税額.dig(:kenmin, :shotoku)
  if export
    {
      customer: @jimusho_name,
      juminzei: {
        kinto: {
          zeigaku: @均等割,
          chukan: @均等割中間納付
        },
        houjinzei: {
          zeigaku: @確定法人税割,
          chukan: @法人税割中間納付
        }
      }
    }.tap do |record|
      if @report_category != 'city'
        record[:jigyouzei] = {
          shotoku: {
            zeigaku: @所得割,
            chukan: @所得割中間納付
          },
          tokubetsu: {
            zeigaku: @税額.dig(:kenmin, :tokubetsu),
            chukan: @地方特別法人事業税中間納付
          },
        }
      end
    end
  else
    @company = CGI.escapeHTML(config.dig('company', 'name'))
    @form_vers = proc_version
    @jichitai_code = report_cfg['jichitai_code']
    @jimusho_code = report_cfg['jimusho_code']
    @kanri_bango = report_cfg['x_houjin_bango']
    @app_version = report_cfg['app_version']
    @address = report_cfg['address'] || it_part_config('nozeisha_adr')
    @jigyosho_name = report_cfg['name'] || '本店'
    @procedure_code = 'R0102100'
    @procedure_name = '法人都道府県民税・事業税・特別法人事業税又は地方法人特別税 確定申告'
    @form_sec = case @report_category
                when 'prefecture'
                  ["R0102AA#{@form_vers['R0102AA']}", 別表九フォーム]
                    .compact.map{ |c| form_attr(c) }.join('')
                when '23ku'
                  ["R0102AA#{@form_vers['R0102AA']}", "R0102AG#{@form_vers['R0102AG']}", 別表九フォーム]
                    .compact.map{ |c| form_attr(c) }.join('')
                when 'city'
                  ["R0504AA180"].compact.map{ |c| form_attr(c) }.join('')
                end
    @user_inf = render_erb(search_template('eltax-userinf.xml.erb'))
    @form_data = case @report_category
                 when 'prefecture'
                   [第六号, 別表九].compact.join("\n")
                 when '23ku'
                   [第六号, 別表四三, 別表九].compact.join("\n")
                 when 'city'
                   [第二十号].compact.join("\n")
                 end
    render_erb(search_template('eltax.xml.erb'))
  end
end

#別表九Object



170
171
172
173
174
# File 'lib/luca/jp/chihouzei.rb', line 170

def 別表九
  return nil if @繰越損失管理.records.length == 0

  render_erb(search_template('el-no6-9.xml.erb'))
end

#別表九フォームObject



164
165
166
167
168
# File 'lib/luca/jp/chihouzei.rb', line 164

def 別表九フォーム
  return nil if @繰越損失管理.records.length == 0

  "R0102AM#{@form_vers['R0102AM']}"
end

#別表四三Object



154
155
156
157
# File 'lib/luca/jp/chihouzei.rb', line 154

def 別表四三
  @office_23ku = config.dig('jp', 'eltax', 'office_23ku')
  render_erb(search_template('el-no6-43.xml.erb'))
end

#第二十号Object



159
160
161
162
# File 'lib/luca/jp/chihouzei.rb', line 159

def 第二十号
  @資本金準備金 = readable(['911', '9131'].map { |cd| @bs_data.dig(cd) }.compact.sum)
  render_erb(search_template('el-no20.xml.erb'))
end

#第六号Object



148
149
150
151
152
# File 'lib/luca/jp/chihouzei.rb', line 148

def 第六号
  @資本金準備金 = readable(['911', '9131'].map { |cd| @bs_data.dig(cd) }.compact.sum)
  STDERR.puts "第六号様式: 「決算確定の日」などの追記が必要。「国外関連者」の確認が必要"
  render_erb(search_template('el-no6.xml.erb'))
end