luca-jp 0.2.4 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b52a931f2268427904135b52cac066411eeb52256c0c136b30862a4ea0d4771e
4
- data.tar.gz: c83a16ff2ae64a8199ce8768da53d0cc2987f2b1ee6955de47a6b5718aa14bbb
3
+ metadata.gz: 14025702bd2ec1fc0f9758ae982c09b437af41b531834d71de1b6b881cdc1e76
4
+ data.tar.gz: 8c265c52dd25ea94c4dff01886f0afcc6dd187612b0e61856eab8c50c520ed2f
5
5
  SHA512:
6
- metadata.gz: 85bad06f6af2920dda348d1a61b4521d16a143937dc710e6ea3dca650a65fd5ca1911beb0dd377c97d17eefab7c5e058490f7129339b7834ff476639b6d0f6e5
7
- data.tar.gz: '048199e0f592eddc0a987ccb43d7b517955fb783db4484f00ed4d5cfa86e0b2ef1d2c577c7e3acec1e1c0f7ea888b0a42c840131152ba91c618544fb9ce753a6'
6
+ metadata.gz: ea5d03e02adeae4b9257a055fe528a77cd2dcc2627df0379d063e9e88ae55b8f03ad8298dcd78334522d490c600d75012b8ad5b2d74c56b07e1b2a24bc06cf80
7
+ data.tar.gz: 989dd502799f53c48ba1655518b4def4b15e0737f5e8ec5fd9169bbf18e18022950c1409e9ea95b25db6c2bf4d9351beb37ad0a24dd65b7713ac3e6c0194617e
data/exe/luca-jp CHANGED
@@ -6,25 +6,30 @@ require 'luca/jp'
6
6
  class LucaCmd
7
7
  def self.syouhizei(args, params)
8
8
  if params[:export]
9
- Luca::Jp::Syouhizei.range(*args).export_json
9
+ Luca::Jp::Syouhizei.range(*auto_range(args, params)).export_json
10
10
  else
11
- puts Luca::Jp::Syouhizei.range(*args).kani
11
+ puts Luca::Jp::Syouhizei.range(*auto_range(args, params)).kani
12
12
  end
13
13
  end
14
14
 
15
15
  def self.houjinzei(args, params)
16
16
  if params[:export]
17
- Luca::Jp::Aoiro.range(*args).export_json
17
+ Luca::Jp::Aoiro.range(*auto_range(args, params)).export_json
18
18
  else
19
- puts Luca::Jp::Aoiro.range(*args).kani
19
+ puts Luca::Jp::Aoiro.range(*auto_range(args, params)).kani
20
20
  end
21
21
  end
22
22
 
23
23
  def self.chihouzei(args, params)
24
24
  if params[:export]
25
- Luca::Jp::Chihouzei.range(*args).export_json
25
+ accounts = Luca::Jp::Util.eltax_config('reports').map do |report|
26
+ Luca::Jp::Chihouzei.range(*auto_range(args, params)).export_json(report)
27
+ end
28
+ puts JSON.dump(accounts)
26
29
  else
27
- puts Luca::Jp::Chihouzei.range(*args).kani
30
+ Luca::Jp::Util.eltax_config('reports').each do |report|
31
+ File.open("chihouzei-#{report['jichitai_code']}#{report['jimusho_code']}.xml", 'w') { |f| f.puts(Luca::Jp::Chihouzei.range(*auto_range(args, params)).kani(report))}
32
+ end
28
33
  end
29
34
  end
30
35
 
@@ -32,30 +37,48 @@ class LucaCmd
32
37
  date = "#{args[0]}-#{args[1]}-1"
33
38
  Luca::Jp::Urikake.new(date).report(params[:total])
34
39
  end
40
+
41
+ def self.auto_range(args, params)
42
+ case args.length
43
+ when 4
44
+ args
45
+ when 2
46
+ date = Date.new(args[0].to_i, args[1].to_i)
47
+ r = LucaBook::Util.current_fy(date, to: date)
48
+ [r[0].year, r[0].month, r[1].year, r[1].month]
49
+ when 0
50
+ date = params[:lastyear] ? Date.today.prev_year : Date.today
51
+ r = LucaBook::Util.current_fy(date)
52
+ [r[0].year, r[0].month, r[1].year, r[1].month]
53
+ end
54
+ end
35
55
  end
36
56
 
37
57
  cmd = ARGV.shift
38
58
  params = {}
39
59
 
40
60
  case cmd
41
- when /hou?jinzei/
61
+ when 'h', /hou?jinzei/
42
62
  OptionParser.new do |opt|
43
- opt.banner = 'Usage: luca-jp houjinzei [options] yyyy mm yyyy mm'
63
+ opt.banner = 'Usage: luca-jp h|houjinzei [options] [yyyy mm yyyy mm]'
44
64
  opt.on('--export', 'export json') { |_v| params[:export] = true }
65
+ opt.on('--lastyear', 'report on last Financial year') { |_v| params[:lastyear] = true }
45
66
  args = opt.parse!(ARGV)
46
67
  LucaCmd.houjinzei(args, params)
47
68
  end
48
- when /s[yh]ou?hizei/
69
+ when 's', /s[yh]ou?hizei/
49
70
  OptionParser.new do |opt|
50
- opt.banner = 'Usage: luca-jp syouhizei [options] yyyy mm yyyy mm'
71
+ opt.banner = 'Usage: luca-jp s|syouhizei [options] [yyyy mm yyyy mm]'
51
72
  opt.on('--export', 'export json') { |_v| params[:export] = true }
73
+ opt.on('--lastyear', 'report on last Financial year') { |_v| params[:lastyear] = true }
52
74
  args = opt.parse!(ARGV)
53
75
  LucaCmd.syouhizei(args, params)
54
76
  end
55
- when /chihou?zei/
77
+ when 'c', /chihou?zei/
56
78
  OptionParser.new do |opt|
57
- opt.banner = 'Usage: luca-jp chihouzei [options] yyyy mm yyyy mm'
79
+ opt.banner = 'Usage: luca-jp c|chihouzei [options] [yyyy mm yyyy mm]'
58
80
  opt.on('--export', 'export json') { |_v| params[:export] = true }
81
+ opt.on('--lastyear', 'report on last Financial year') { |_v| params[:lastyear] = true }
59
82
  args = opt.parse!(ARGV)
60
83
  LucaCmd.chihouzei(args, params)
61
84
  end
@@ -66,4 +89,13 @@ when /urikake/
66
89
  args = opt.parse!(ARGV)
67
90
  LucaCmd.urikake(args, params)
68
91
  end
92
+ else
93
+ puts 'Proper subcommand needed.'
94
+ puts
95
+ puts 'Usage: luca-jp <subcommand>'
96
+ puts ' h[oujinzei]: 法人税の計算'
97
+ puts ' s[youhizei]: 消費税の計算'
98
+ puts ' c[hihouzei]: 地方税の計算'
99
+ puts ' urikake: 勘定科目内訳明細書の売掛金リスト(CSV)'
100
+ exit 1
69
101
  end
data/lib/luca/jp/aoiro.rb CHANGED
@@ -27,6 +27,7 @@ module Luca
27
27
  @issue_date = Date.today
28
28
  @company = CGI.escapeHTML(config.dig('company', 'name'))
29
29
  @software = 'LucaJp'
30
+ @shinkoku_kbn = '30' # 確定申告
30
31
 
31
32
  @税額 = 税額計算
32
33
  @確定法人税額 = @税額.dig(:houjin, :kokuzei)
@@ -51,7 +52,8 @@ module Luca
51
52
  else
52
53
  @procedure_code = 'RHO0012'
53
54
  @procedure_name = '内国法人の確定申告(青色)'
54
- @version = '20.0.2'
55
+ @form_vers = proc_version
56
+ @version = @form_vers['proc']
55
57
  @都道府県民税法人税割中間納付 = prepaid_tax('1859')
56
58
  @都道府県民税均等割中間納付 = prepaid_tax('185A')
57
59
  @都道府県民税中間納付 = @都道府県民税法人税割中間納付 + @都道府県民税均等割中間納付
@@ -116,6 +118,7 @@ module Luca
116
118
  end
117
119
 
118
120
  def 別表一
121
+ STDERR.puts "別表一: 「決算確定の日」などの追記が必要"
119
122
  render_erb(search_template('beppyo1.xml.erb'))
120
123
  end
121
124
 
@@ -132,22 +135,32 @@ module Luca
132
135
  @当期純損益 = readable(@pl_data.dig('HA'))
133
136
  @法人税等 = readable(@pl_data.dig('H0'))
134
137
  _, @納付事業税 = 未納事業税期中増減
135
- @別表四調整所得 = @当期純損益 + @法人税等 - @納付事業税
138
+ @当期還付事業税 = 還付事業税
139
+ @翌期還付事業税 = 中間還付税額(確定事業税, @事業税中間納付)
140
+ @別表四調整所得 = @当期純損益 + @法人税等 - @納付事業税 - @翌期還付事業税 + @当期還付事業税
136
141
 
137
142
  @当期還付法人税 = refund_tax('1502')
138
143
  @当期還付都道府県住民税 = refund_tax('1503')
139
- @翌期還付都道府県住民税 = 中間還付税額(@税額.dig(:kenmin, :kintou), @都道府県民税均等割中間納付) + 中間還付税額(@税額.dig(:kenmin, :houjinzei), @都道府県民税法人税割中間納付)
144
+ @翌期還付都道府県住民税 = readable(@bs_data['1503'])
140
145
  @当期還付市民税 = refund_tax('1505')
141
- @翌期還付市民税 = 中間還付税額(@税額.dig(:shimin, :kintou), @市民税均等割中間納付) + 中間還付税額(@税額.dig(:shimin, :houjinzei), @市民税法人税割中間納付)
142
- @当期還付事業税 = 還付事業税
146
+ @翌期還付市民税 = readable(@bs_data['1505']) || 0
143
147
  @事業税期首残高 = 期首未納事業税 > 0 ? 期首未納事業税 : (@当期還付事業税 * -1)
144
- @翌期還付事業税 = 中間還付税額(確定事業税, @事業税中間納付)
145
148
  @仮払税金 = @翌期還付法人税 + @翌期還付都道府県住民税 + @翌期還付事業税 + @翌期還付市民税
146
149
 
147
150
  render_erb(search_template('beppyo4.xml.erb'))
148
151
  end
149
152
 
150
153
  def 別表五一
154
+ @期首資本金 = readable(@start_balance.dig('911'))
155
+ @資本金期中減, @資本金期中増 = 純資産期中増減('911')
156
+ @期首資本準備金, @期末資本準備金 = 期首期末残高('9131')
157
+ @資本準備金期中減, @資本準備金期中増 = 純資産期中増減('9131')
158
+ @期首その他資本剰余金, @期末その他資本剰余金 = 期首期末残高('9132')
159
+ @その他資本剰余金期中減, @その他資本剰余金期中増 = 純資産期中増減('9132')
160
+ @期首自己株式, @期末自己株式 = 期首期末残高('916')
161
+ # 自己株式は負の純資産。借方集計は負の増加として認識
162
+ @自己株式期中増, @自己株式期中減 = 純資産期中増減('916').map { |t| t * -1 }
163
+ @資本金等の額期中減, @資本金等の額期中増 = 資本金等の額期中増減
151
164
  render_erb(search_template('beppyo51.xml.erb'))
152
165
  end
153
166
 
@@ -221,7 +234,7 @@ module Luca
221
234
  @代表者報酬 = gaikyo('C11')
222
235
  @代表者借入 = gaikyo('5121')
223
236
  @概況仕入 = gaikyo('B11') + gaikyo('B12')
224
- @概況外注費 = gaikyo('C10')
237
+ @概況外注費 = gaikyo('C1O')
225
238
  @概況人件費 = gaikyo('C11') + gaikyo('C12') + gaikyo('C13')
226
239
  render_erb(search_template('gaikyo.xml.erb'))
227
240
  end
@@ -307,7 +320,12 @@ module Luca
307
320
  return nil if beppyo2_config('total_shares').nil?
308
321
  return nil if beppyo2_config('owners').nil?
309
322
 
310
- (別表二上位株数 * 100.0 / beppyo2_config('total_shares')).round(1)
323
+ total = if beppyo2_config('own_shares').nil?
324
+ beppyo2_config('total_shares')
325
+ else
326
+ beppyo2_config('total_shares') - beppyo2_config('own_shares')
327
+ end
328
+ (別表二上位株数 * 100.0 / total).round(1)
311
329
  end
312
330
 
313
331
  def 別表二上位議決権数
@@ -320,7 +338,12 @@ module Luca
320
338
  return nil if beppyo2_config('total_votes').nil?
321
339
  return nil if beppyo2_config('owners').nil?
322
340
 
323
- (別表二上位議決権数 * 100.0 / beppyo2_config('total_votes')).round(1)
341
+ total = if beppyo2_config('no_votes').nil?
342
+ beppyo2_config('total_votes')
343
+ else
344
+ beppyo2_config('total_votes') - beppyo2_config('no_votes')
345
+ end
346
+ (別表二上位議決権数 * 100.0 / total).round(1)
324
347
  end
325
348
 
326
349
  # TODO: 特定同族会社の判定
@@ -444,7 +467,7 @@ module Luca
444
467
  end
445
468
 
446
469
  def 確定都道府県住民税
447
- @税額.dig(:kenmin, :kintou) + @税額.dig(:kenmin, :houjinzei)
470
+ readable(@pl_data['H112']) || 0
448
471
  end
449
472
 
450
473
  def 期首未納都道府県民税
@@ -452,7 +475,7 @@ module Luca
452
475
  end
453
476
 
454
477
  def 期末未納都道府県民税
455
- 納付税額(@税額.dig(:kenmin, :kintou), @都道府県民税均等割中間納付) + 納付税額(@税額.dig(:kenmin, :houjinzei), @都道府県民税法人税割中間納付)
478
+ readable(@bs_data['5153']) || 0
456
479
  end
457
480
 
458
481
  def 未納都道府県民税期中増減
@@ -461,16 +484,15 @@ module Luca
461
484
  end
462
485
 
463
486
  def 都道府県民税仮払納付
464
- [(@都道府県民税中間納付 - 確定都道府県住民税), 0].max
465
- 中間還付税額(@税額.dig(:kenmin, :kintou), @都道府県民税均等割中間納付) + 中間還付税額(@税額.dig(:kenmin, :houjinzei), @都道府県民税法人税割中間納付)
487
+ readable(@bs_data['1503']) || 0
466
488
  end
467
489
 
468
490
  def 都道府県民税損金納付
469
- [@都道府県民税均等割中間納付, @税額.dig(:kenmin, :kintou)].min + [@都道府県民税法人税割中間納付, @税額.dig(:kenmin, :houjinzei)].min
491
+ [@都道府県民税均等割中間納付 + @都道府県民税法人税割中間納付, readable(@pl_data['H112'])||0].min
470
492
  end
471
493
 
472
494
  def 確定市民税
473
- @税額.dig(:shimin, :kintou) - @税額.dig(:shimin, :houjinzei)
495
+ readable(@pl_data['H113']) || 0
474
496
  end
475
497
 
476
498
  def 期首未納市民税
@@ -478,7 +500,7 @@ module Luca
478
500
  end
479
501
 
480
502
  def 期末未納市民税
481
- 納付税額(@税額.dig(:shimin, :kintou), @市民税均等割中間納付) + 納付税額(@税額.dig(:shimin, :houjinzei), @市民税法人税割中間納付)
503
+ readable(@bs_data['5154']) || 0
482
504
  end
483
505
 
484
506
  def 未納市民税期中増減
@@ -487,15 +509,15 @@ module Luca
487
509
  end
488
510
 
489
511
  def 市民税仮払納付
490
- 中間還付税額(@税額.dig(:shimin, :kintou), @市民税均等割中間納付) + 中間還付税額(@税額.dig(:shimin, :houjinzei), @市民税法人税割中間納付)
512
+ readable(@bs_data['1505']) || 0
491
513
  end
492
514
 
493
515
  def 市民税損金納付
494
- [@市民税均等割中間納付, @税額.dig(:shimin, :kintou)].min + [@市民税法人税割中間納付, @税額.dig(:shimin, :houjinzei)].min
516
+ [@市民税均等割中間納付 + @市民税法人税割中間納付, readable(@pl_data['H113'])||0].min
495
517
  end
496
518
 
497
519
  def 確定事業税
498
- @税額.dig(:kenmin, :shotoku) + @税額.dig(:kenmin, :tokubetsu)
520
+ readable(@pl_data['H114']) || 0
499
521
  end
500
522
 
501
523
  def 事業税損金納付
@@ -522,6 +544,25 @@ module Luca
522
544
  readable((@bs_data[code] || 0) * -1)
523
545
  end
524
546
 
547
+ def 別表五一期首資本
548
+ readable(@start_balance.dig('911')||0 + @start_balance.dig('913')||0)
549
+ end
550
+
551
+ # 資本金、資本準備金、その他資本剰余金、自己株式(控除)の合算
552
+ #
553
+ def 資本金等の額期中増減
554
+ inc = ['911', '913'].map do |code|
555
+ credit_amount(code, @start_date.year, @start_date.month, @end_date.year, @end_date.month) || 0
556
+ end
557
+ inc << (debit_amount('916', @start_date.year, @start_date.month, @end_date.year, @end_date.month)||0) * -1
558
+ dec = ['911', '913'].map do |code|
559
+ debit_amount(code, @start_date.year, @start_date.month, @end_date.year, @end_date.month) || 0
560
+ end
561
+ dec << (credit_amount('916', @start_date.year, @start_date.month, @end_date.year, @end_date.month)||0) * -1
562
+
563
+ [readable(dec.sum), readable(inc.sum)]
564
+ end
565
+
525
566
  def 別表七各期青色損失
526
567
  tags = @繰越損失管理.records
527
568
  .filter { |record| record['start_date'] > @end_date.prev_year(10) && record['end_date'] < @start_date }
@@ -545,22 +586,6 @@ module Luca
545
586
  tags.compact.join("\n")
546
587
  end
547
588
 
548
- def 期首資本金
549
- readable(@start_balance.dig('911')) || 0
550
- end
551
-
552
- def 期末資本金
553
- readable(@bs_data.dig('911')) || 0
554
- end
555
-
556
- def 別表五一期首資本
557
- 期首資本金
558
- end
559
-
560
- def 別表五一期末資本
561
- 期末資本金
562
- end
563
-
564
589
  def 期首未納消費税
565
590
  readable(@start_balance.dig('516')) || 0
566
591
  end
@@ -577,10 +602,10 @@ module Luca
577
602
 
578
603
  def 概況源泉徴収種類
579
604
  tags = []
580
- if credit_count('5191', @start_date.year, @start_date.month, @end_date.year, @end_date.month)
605
+ if credit_count('5191', @start_date.year, @start_date.month, @end_date.year, @end_date.month) > 0
581
606
  tags << render_attr('IAF03100', '<kubun_CD>1</kubun_CD>')
582
607
  end
583
- if credit_count('5193', @start_date.year, @start_date.month, @end_date.year, @end_date.month)
608
+ if credit_count('5193', @start_date.year, @start_date.month, @end_date.year, @end_date.month) > 0
584
609
  tags << render_attr('IAF03200', '<kubun_CD>1</kubun_CD>')
585
610
  elsif credit_count('5194', @start_date.year, @start_date.month, @end_date.year, @end_date.month)
586
611
  tags << render_attr('IAF03200', '<kubun_CD>1</kubun_CD>')
@@ -605,7 +630,7 @@ module Luca
605
630
  end
606
631
 
607
632
  def 概況月外注費(idx)
608
- gaikyo_month(idx, 'C10')
633
+ gaikyo_month(idx, 'C1O')
609
634
  end
610
635
 
611
636
  def 概況月源泉徴収(idx)
@@ -638,6 +663,14 @@ module Luca
638
663
  readable(@monthly.dig(index, code) || 0)
639
664
  end
640
665
 
666
+ def proc_version
667
+ if @end_date >= Date.parse('2021-4-1')
668
+ { 'proc' => '21.0.2', 'HOA112' => '3.1', 'HOA116' => '2.0', 'HOA420' => '20.0', 'HOA522' => '7.0', 'HOK010' => '6.0' }
669
+ else
670
+ { 'proc' => '20.0.2', 'HOA112' => '2.0', 'HOA116' => '1.0', 'HOA420' => '19.0', 'HOA522' => '6.0', 'HOK010' => '5.0' }
671
+ end
672
+ end
673
+
641
674
  def lib_path
642
675
  __dir__
643
676
  end
@@ -18,26 +18,33 @@ module Luca
18
18
  @dirname = 'journals'
19
19
  @record_type = 'raw'
20
20
 
21
- def kani(export: false)
21
+ def kani(report_cfg, export: false)
22
22
  set_pl(4)
23
23
  set_bs(4)
24
24
  @issue_date = Date.today
25
- @company = CGI.escapeHTML(config.dig('company', 'name'))
26
25
  @software = 'LucaJp'
27
- @jimusho_code = eltax_config('jimusho_code')
28
- @jimusho_name = eltax_config('jimusho_name')
29
- @app_version = eltax_config('app_version')
26
+ @jimusho_name = report_cfg['jimusho_name']
27
+ @report_category = report_cfg['type']
28
+ @employee = report_cfg['employee'] || 1
29
+ @office_count = report_cfg['office_count'] || 1
30
+ # 自治体ごとの税率カスタマイズ
31
+ @houjinzeiwari_rate = report_cfg['houjinzeiwari']
32
+ @shotoku399 = report_cfg['shotoku399']
33
+ @shotoku401 = report_cfg['shotoku401']
34
+ @shotoku801 = report_cfg['shotoku801']
30
35
 
31
36
  @税額 = 税額計算
32
- @均等割 = @税額.dig(:kenmin, :kintou)
33
- @確定法人税割 = (@税額.dig(:kenmin, :houjinzei) / 100).floor * 100
34
- @地方特別法人事業税中間納付 = prepaid_tax('1854')
35
- @所得割中間納付 = prepaid_tax('1855')
36
- @法人税割中間納付 = prepaid_tax('1859')
37
- @均等割中間納付 = prepaid_tax('185A')
37
+ jichitai = @report_category == 'city' ? :shimin : :kenmin
38
+ @均等割 = report_cfg['kintouwari'] || @税額.dig(jichitai, :kintou)
39
+ @確定法人税割 = @税額.dig(jichitai, :houjinzei)
40
+ @地方特別法人事業税中間納付 = prepaid_tax('1854', @jimusho_name)
41
+ @所得割中間納付 = prepaid_tax('1855', @jimusho_name)
42
+ @法人税割中間納付 = prepaid_tax('1859', @jimusho_name)
43
+ @均等割中間納付 = prepaid_tax('185A', @jimusho_name)
38
44
  @所得割 = @税額.dig(:kenmin, :shotoku)
39
45
  if export
40
46
  {
47
+ customer: @jimusho_name,
41
48
  jigyouzei: {
42
49
  shotoku: {
43
50
  zeigaku: @所得割,
@@ -60,52 +67,78 @@ module Luca
60
67
  }
61
68
  }
62
69
  else
70
+ @company = CGI.escapeHTML(config.dig('company', 'name'))
71
+ @form_vers = proc_version
72
+ @jichitai_code = report_cfg['jichitai_code']
73
+ @jimusho_code = report_cfg['jimusho_code']
74
+ @kanri_bango = report_cfg['x_houjin_bango']
75
+ @app_version = report_cfg['app_version']
76
+ @address = report_cfg['address'] || it_part_config('nozeisha_adr')
77
+ @jigyosho_name = report_cfg['name'] || '本店'
63
78
  @procedure_code = 'R0102100'
64
79
  @procedure_name = '法人都道府県民税・事業税・特別法人事業税又は地方法人特別税 確定申告'
65
- @form_sec = ['R0102AA190', 'R0102AG120', 別表九フォーム].compact.map{ |c| form_attr(c) }.join('')
80
+ @form_sec = case @report_category
81
+ when 'prefecture'
82
+ ["R0102AA#{@form_vers['R0102AA']}", 別表九フォーム]
83
+ .compact.map{ |c| form_attr(c) }.join('')
84
+ when '23ku'
85
+ ["R0102AA#{@form_vers['R0102AA']}", "R0102AG120", 別表九フォーム]
86
+ .compact.map{ |c| form_attr(c) }.join('')
87
+ when 'city'
88
+ ["R0504AA180"].compact.map{ |c| form_attr(c) }.join('')
89
+ end
66
90
  @user_inf = render_erb(search_template('eltax-userinf.xml.erb'))
67
- @form_data = [第六号, 別表四三, 別表九].compact.join("\n")
91
+ @form_data = case @report_category
92
+ when 'prefecture'
93
+ [第六号, 別表九].compact.join("\n")
94
+ when '23ku'
95
+ [第六号, 別表四三, 別表九].compact.join("\n")
96
+ when 'city'
97
+ [第二十号].compact.join("\n")
98
+ end
68
99
  render_erb(search_template('eltax.xml.erb'))
69
100
  end
70
101
  end
71
102
 
72
- def export_json
73
- records = kani(export: true)
74
- [].tap do |res|
75
- item = {}
103
+ def export_json(report_cfg)
104
+ records = kani(report_cfg, export: true)
105
+ label = @report_category == 'city' ? '市町村住民税' : '都道府県住民税'
106
+ {}.tap do |item|
76
107
  item['date'] = @end_date
77
108
  item['debit'] = []
78
109
  item['credit'] = []
79
- records[:jigyouzei].each do |k, dat|
80
- if dat[:chukan] > 0
81
- item['credit'] << { 'label' => karibarai_label(k), 'amount' => dat[:chukan] }
110
+ unless @report_category == 'city'
111
+ records[:jigyouzei].each do |k, dat|
112
+ if dat[:chukan] > 0
113
+ item['credit'] << { 'label' => karibarai_label(k), 'amount' => dat[:chukan] }
114
+ end
115
+ if dat[:chukan] > dat[:zeigaku]
116
+ item['debit'] << { 'label' => '未収地方事業税', 'amount' => dat[:chukan] - dat[:zeigaku] }
117
+ else
118
+ item['credit'] << { 'label' => '未払地方事業税', 'amount' => dat[:zeigaku] - dat[:chukan] }
119
+ end
120
+ item['debit'] << { 'label' => '地方事業税', 'amount' => dat[:zeigaku] } if dat[:zeigaku] > 0
82
121
  end
83
- if dat[:chukan] > dat[:zeigaku]
84
- item['debit'] << { 'label' => '未収地方事業税', 'amount' => dat[:chukan] - dat[:zeigaku] }
85
- else
86
- item['credit'] << { 'label' => '未払地方事業税', 'amount' => dat[:zeigaku] - dat[:chukan] }
87
- end
88
- item['debit'] << { 'label' => '法人税、住民税及び事業税', 'amount' => dat[:zeigaku] } if dat[:zeigaku] > 0
89
122
  end
90
123
  records[:juminzei].each do |k, dat|
91
124
  if dat[:chukan] > 0
92
125
  item['credit'] << { 'label' => karibarai_label(k), 'amount' => dat[:chukan] }
93
126
  end
94
127
  if dat[:chukan] > dat[:zeigaku]
95
- item['debit'] << { 'label' => '未収都道府県住民税', 'amount' => dat[:chukan] - dat[:zeigaku] }
128
+ item['debit'] << { 'label' => "未収#{label}", 'amount' => dat[:chukan] - dat[:zeigaku] }
96
129
  else
97
- item['credit'] << { 'label' => '未払都道府県民税', 'amount' => dat[:zeigaku] - dat[:chukan] }
130
+ item['credit'] << { 'label' => "未払#{label}", 'amount' => dat[:zeigaku] - dat[:chukan] }
98
131
  end
99
- item['debit'] << { 'label' => '法人税、住民税及び事業税', 'amount' => dat[:zeigaku] } if dat[:zeigaku] > 0
132
+ item['debit'] << { 'label' => label, 'amount' => dat[:zeigaku] } if dat[:zeigaku] > 0
100
133
  end
134
+ item['x-customer'] = records[:customer] unless records[:customer].nil?
101
135
  item['x-editor'] = 'LucaJp'
102
- res << item
103
- puts JSON.dump(res)
104
136
  end
105
137
  end
106
138
 
107
139
  def 第六号
108
- @資本金準備金 = eltax_config('shihon') || it_part_config('shihon_kin')
140
+ @資本金準備金 = readable(['911', '9131'].map { |cd| @bs_data.dig(cd) }.compact.sum)
141
+ STDERR.puts "第六号様式: 「決算確定の日」「国外関連者」などの追記が必要"
109
142
  render_erb(search_template('el-no6.xml.erb'))
110
143
  end
111
144
 
@@ -114,10 +147,15 @@ module Luca
114
147
  render_erb(search_template('el-no6-43.xml.erb'))
115
148
  end
116
149
 
150
+ def 第二十号
151
+ @資本金準備金 = readable(['911', '9131'].map { |cd| @bs_data.dig(cd) }.compact.sum)
152
+ render_erb(search_template('el-no20.xml.erb'))
153
+ end
154
+
117
155
  def 別表九フォーム
118
156
  return nil if @繰越損失管理.records.length == 0
119
157
 
120
- 'R0102AM190'
158
+ "R0102AM#{@form_vers['R0102AM']}"
121
159
  end
122
160
 
123
161
  def 別表九
@@ -129,7 +167,13 @@ module Luca
129
167
  private
130
168
 
131
169
  def 法人税割課税標準
132
- (@税額.dig(:houjin, :kokuzei) / 1000).floor * 1000
170
+ case Luca::Jp::Util.eltax_config('reports')
171
+ .filter { |r| レポート種別.include?(r['type']) }.length
172
+ when 0, 1
173
+ (@税額.dig(:houjin, :kokuzei) / 1000).floor * 1000
174
+ else
175
+ 従業員数による分割課税標準 @税額.dig(:houjin, :kokuzei)
176
+ end
133
177
  end
134
178
 
135
179
  def 事業税中間納付
@@ -205,6 +249,14 @@ module Luca
205
249
  end
206
250
  end
207
251
 
252
+ def proc_version
253
+ if @start_date >= Date.parse('2020-4-1')
254
+ { 'R0102AA' => '200', 'R0102AM' => '200' }
255
+ else
256
+ { 'R0102AA' => '190', 'R0102AM' => '190' }
257
+ end
258
+ end
259
+
208
260
  def lib_path
209
261
  __dir__
210
262
  end