luca-jp 0.1.0 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/exe/luca-jp +57 -0
  3. data/lib/luca/jp.rb +13 -0
  4. data/lib/luca/jp/aoiro.rb +470 -0
  5. data/lib/luca/jp/chihouzei.rb +197 -0
  6. data/lib/luca/jp/common.rb +216 -0
  7. data/lib/luca/jp/it_part.rb +99 -0
  8. data/lib/luca/jp/sonshitsu.rb +102 -0
  9. data/lib/luca/jp/syouhizei.rb +120 -12
  10. data/lib/luca/jp/templates/aoiro.xtx.erb +21 -0
  11. data/lib/luca/jp/templates/beppyo1-next.xml.erb +31 -0
  12. data/lib/luca/jp/templates/beppyo1.xml.erb +71 -0
  13. data/lib/luca/jp/templates/beppyo15.xml.erb +30 -0
  14. data/lib/luca/jp/templates/beppyo2.xml.erb +9 -0
  15. data/lib/luca/jp/templates/beppyo4.xml.erb +84 -0
  16. data/lib/luca/jp/templates/beppyo51.xml.erb +85 -0
  17. data/lib/luca/jp/templates/beppyo52.xml.erb +241 -0
  18. data/lib/luca/jp/templates/beppyo7.xml.erb +31 -0
  19. data/lib/luca/jp/templates/consumption.xtx.erb +21 -0
  20. data/lib/luca/jp/templates/el-no6-43.xml.erb +178 -0
  21. data/lib/luca/jp/templates/el-no6-9.xml.erb +51 -0
  22. data/lib/luca/jp/templates/el-no6.xml.erb +206 -0
  23. data/lib/luca/jp/templates/eltax.xml.erb +117 -0
  24. data/lib/luca/jp/templates/fuhyo43.xml.erb +37 -0
  25. data/lib/luca/jp/templates/fuhyo53.xml.erb +24 -0
  26. data/lib/luca/jp/templates/gaikyo.xml.erb +89 -0
  27. data/lib/luca/jp/templates/kariuke-meisai.xml.erb +37 -0
  28. data/lib/luca/jp/templates/syouhizei-shinkoku-kanni.xml.erb +95 -0
  29. data/lib/luca/jp/templates/tekiyougaku.xml.erb +35 -0
  30. data/lib/luca/jp/templates/yakuin-meisai.xml.erb +13 -0
  31. data/lib/luca/jp/templates/yokin-meisai.xml.erb +13 -0
  32. data/lib/luca/jp/util.rb +69 -0
  33. data/lib/luca/jp/version.rb +1 -1
  34. metadata +30 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d226efcad9d2c52181b9fcbdd4ae8b74d9d5b754fe77394aa82461ad216fcffa
4
- data.tar.gz: 8fe33b512f972ee94b78086d5a776ca348d26293c3da4e50d6979c839f0bb4c9
3
+ metadata.gz: 293a22484ad653e329dce906de157f442f6a2b84c6157761c88e40a488eec411
4
+ data.tar.gz: 9099aa4b48971bdc2015f68df09f795900e2414a55e25095a1943b8907014572
5
5
  SHA512:
6
- metadata.gz: 9087580538986050f9f759825a20fa3be2931814d558b555d1fcfd34d9b5469e2295f3840b6e4ee788dab53623cad0a7b1ffac1fd6764afe8faff25a753ca2d0
7
- data.tar.gz: 5817884c64afecdba20440cc3f8a346656a025604d72b8d862e841aea6b53439a992a1076d8c4230e5507406a436da50fd88b3f6644d219eff38eb96b3b6f550
6
+ metadata.gz: 81c8174c9f743fb97ed5ac3cc98b2d30f4d6143c7ae7256b8fc4df738a005ee4ae2c30379d2a074587adcaeff92415001f9bac044b607171a90426c11f2a0043
7
+ data.tar.gz: ca6aabb77e93cd285616d7ffa0a3d5996b53fe661c88ddb3ea62dffe05ac238ea1bea03ea52d9f08d04c74c50e251ae5dfa7280a84aec8a724dd95f9bcb5b127
data/exe/luca-jp CHANGED
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'optparse'
4
+ require 'luca/jp'
5
+
6
+ class LucaCmd
7
+ def self.syouhizei(args, params)
8
+ if params[:export]
9
+ Luca::Jp::Syouhizei.range(*args).export_json
10
+ else
11
+ puts Luca::Jp::Syouhizei.range(*args).kani
12
+ end
13
+ end
14
+
15
+ def self.houjinzei(args, params)
16
+ if params[:export]
17
+ Luca::Jp::Aoiro.range(*args).export_json
18
+ else
19
+ puts Luca::Jp::Aoiro.range(*args).kani
20
+ end
21
+ end
22
+
23
+ def self.chihouzei(args, params)
24
+ if params[:export]
25
+ Luca::Jp::Chihouzei.range(*args).export_json
26
+ else
27
+ puts Luca::Jp::Chihouzei.range(*args).kani
28
+ end
29
+ end
30
+ end
31
+
32
+ cmd = ARGV.shift
33
+ params = {}
34
+
35
+ case cmd
36
+ when /hou?jinzei/
37
+ OptionParser.new do |opt|
38
+ opt.banner = 'Usage: luca-jp houjinzei [options] yyyy mm yyyy mm'
39
+ opt.on('--export', 'export json') { |_v| params[:export] = true }
40
+ args = opt.parse!(ARGV)
41
+ LucaCmd.houjinzei(args, params)
42
+ end
43
+ when /s[yh]ou?hizei/
44
+ OptionParser.new do |opt|
45
+ opt.banner = 'Usage: luca-jp syouhizei [options] yyyy mm yyyy mm'
46
+ opt.on('--export', 'export json') { |_v| params[:export] = true }
47
+ args = opt.parse!(ARGV)
48
+ LucaCmd.syouhizei(args, params)
49
+ end
50
+ when /chihou?zei/
51
+ OptionParser.new do |opt|
52
+ opt.banner = 'Usage: luca-jp chihouzei [options] yyyy mm yyyy mm'
53
+ opt.on('--export', 'export json') { |_v| params[:export] = true }
54
+ args = opt.parse!(ARGV)
55
+ LucaCmd.chihouzei(args, params)
56
+ end
57
+ end
data/lib/luca/jp.rb CHANGED
@@ -1,10 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'luca/jp/version'
4
+ require 'luca_support/config'
4
5
 
5
6
  module Luca
6
7
  module Jp
7
8
  autoload :Kessan, 'luca/jp/kessan'
9
+ autoload :Aoiro, 'luca/jp/aoiro'
8
10
  autoload :Syouhizei, 'luca/jp/syouhizei'
11
+ autoload :Chihouzei, 'luca/jp/chihouzei'
12
+ autoload :Common, 'luca/jp/common'
13
+ autoload :ItPart, 'luca/jp/it_part'
14
+ autoload :Sonshitsu, 'luca/jp/sonshitsu'
15
+ autoload :Util, 'luca/jp/util'
9
16
  end
17
+
18
+ EX_CONF = begin
19
+ YAML.load_file(Pathname(LucaSupport::PJDIR) / 'config-lucajp.yml')
20
+ rescue Errno::ENOENT
21
+ nil
22
+ end
10
23
  end
@@ -0,0 +1,470 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'cgi/escape'
5
+ require 'luca_book'
6
+ require 'luca_support'
7
+ require 'luca_record/dict'
8
+ require 'luca_support/config'
9
+ require 'luca/jp'
10
+
11
+ module Luca
12
+ module Jp
13
+ class Aoiro < LucaBook::State
14
+ include LucaSupport::View
15
+ include LucaSupport::Code
16
+ include Luca::Jp::Common
17
+ include Luca::Jp::ItPart
18
+ include Luca::Jp::Util
19
+
20
+ @dirname = 'journals'
21
+ @record_type = 'raw'
22
+
23
+ def kani(export: false)
24
+ set_pl(4)
25
+ set_bs(4)
26
+ @issue_date = Date.today
27
+ @company = CGI.escapeHTML(config.dig('company', 'name'))
28
+ @software = 'LucaJp'
29
+
30
+ @税額 = 税額計算
31
+ @確定法人税額 = @税額.dig(:houjin, :kokuzei)
32
+ @法人税額 = 中小企業の軽減税額 + 一般区分の税額
33
+ @地方法人税課税標準 = (@法人税額 / 1000).floor * 1000
34
+ @地方法人税額 = 地方法人税額(@地方法人税課税標準)
35
+ @確定地方法人税額 = @税額.dig(:houjin, :chihou)
36
+ @法人税中間納付 = prepaid_tax('1851')
37
+ @地方法人税中間納付 = prepaid_tax('1852')
38
+
39
+ if export
40
+ {
41
+ kokuzei: {
42
+ zeigaku: @確定法人税額,
43
+ chukan: @法人税中間納付
44
+ },
45
+ chihou: {
46
+ zeigaku: @確定地方法人税額,
47
+ chukan: @地方法人税中間納付
48
+ }
49
+ }
50
+ else
51
+ @procedure_code = 'RHO0012'
52
+ @procedure_name = '内国法人の確定申告(青色)'
53
+ @version = '20.0.2'
54
+ @都道府県民税中間納付 = prepaid_tax('1859') + prepaid_tax('185A')
55
+ @市民税中間納付 = prepaid_tax('185D') + prepaid_tax('185E')
56
+ @法人税期中増, @法人税期中減 = 未納法人税期中増減
57
+ @都道府県民税期中増, @都道府県民税期中減 = 未納都道府県民税期中増減
58
+ @市民税期中増, @市民税期中減 = 未納市民税期中増減
59
+ @事業税期中増, @事業税期中減 = 未納事業税期中増減
60
+ @納税充当金期中増, @納税充当金期中減 = 納税充当金期中増減
61
+ @還付法人税 = refund_tax('1502')
62
+ @還付都道府県住民税 = refund_tax('1503')
63
+ @還付市民税 = refund_tax('1505')
64
+ @概況売上 = gaikyo('A0')
65
+ @form_sec = ['HOA112', 'HOA116', 'HOA201', 'HOA420', 'HOA511', 'HOA522', 別表七フォーム, 'HOE200', 適用額明細フォーム, 'HOI010', 'HOI100', 'HOI141', 'HOK010'].compact.map{ |c| form_rdf(c) }.join('')
66
+ #@extra_form_sec = ['HOI040', 'HOI060', 'HOI090', 'HOI110']
67
+ @it = it_part
68
+ @form_data = [別表一, 別表一次葉, 別表二, 別表四簡易, 別表五一, 別表五二, 別表七, 別表十五, 適用額明細, 預貯金内訳, 仮受金内訳, 役員報酬内訳, 概況説明].compact.join("\n")
69
+ render_erb(search_template('aoiro.xtx.erb'))
70
+ end
71
+ end
72
+
73
+ def export_json
74
+ dat = kani(export: true)
75
+ [].tap do |res|
76
+ item = {}
77
+ item['date'] = @end_date
78
+ item['debit'] = []
79
+ item['credit'] = []
80
+ if dat[:kokuzei][:chukan] > 0
81
+ item['credit'] << { 'label' => '仮払法人税', 'amount' => dat[:kokuzei][:chukan] }
82
+ end
83
+ if dat[:kokuzei][:chukan] > dat[:kokuzei][:zeigaku]
84
+ item['debit'] << { 'label' => '未収法人税', 'amount' => dat[:kokuzei][:chukan] - dat[:kokuzei][:zeigaku] }
85
+ else
86
+ item['credit'] << { 'label' => '未払法人税', 'amount' => dat[:kokuzei][:zeigaku] - dat[:kokuzei][:chukan] }
87
+ end
88
+ item['debit'] << { 'label' => '法人税、住民税及び事業税', 'amount' => dat[:kokuzei][:zeigaku] } if dat[:kokuzei][:zeigaku] > 0
89
+ if dat[:chihou][:chukan] > 0
90
+ item['credit'] << { 'label' => '仮払法人税(地方)', 'amount' => dat[:chihou][:chukan] }
91
+ end
92
+ if dat[:chihou][:chukan] > dat[:chihou][:zeigaku]
93
+ item['debit'] << { 'label' => '未収法人税', 'amount' => dat[:chihou][:chukan] - dat[:chihou][:zeigaku] }
94
+ else
95
+ item['credit'] << { 'label' => '未払法人税', 'amount' => dat[:chihou][:zeigaku] - dat[:chihou][:chukan] }
96
+ end
97
+ item['debit'] << { 'label' => '法人税、住民税及び事業税', 'amount' => dat[:chihou][:zeigaku] } if dat[:chihou][:zeigaku] > 0
98
+ item['x-editor'] = 'LucaJp'
99
+ res << item
100
+ puts JSON.dump(res)
101
+ end
102
+ end
103
+
104
+ def 別表一
105
+ render_erb(search_template('beppyo1.xml.erb'))
106
+ end
107
+
108
+ def 別表一次葉
109
+ @消費税期中増, @消費税期中減 = 未納消費税期中増減
110
+ render_erb(search_template('beppyo1-next.xml.erb'))
111
+ end
112
+
113
+ def 別表二
114
+ render_erb(search_template('beppyo2.xml.erb'))
115
+ end
116
+
117
+ def 別表四簡易
118
+ @当期純損益 = readable(@pl_data.dig('HA'))
119
+ @法人税等 = readable(@pl_data.dig('H0'))
120
+ _, @納付事業税 = 未納事業税期中増減
121
+ @還付事業税 = readable(還付事業税 || 0)
122
+ @別表四調整所得 = @当期純損益 + @法人税等 + @還付事業税 - @納付事業税
123
+
124
+ render_erb(search_template('beppyo4.xml.erb'))
125
+ end
126
+
127
+ def 別表五一
128
+ render_erb(search_template('beppyo51.xml.erb'))
129
+ end
130
+
131
+ def 別表五二
132
+ @その他事業税 = 租税公課
133
+ render_erb(search_template('beppyo52.xml.erb'))
134
+ end
135
+
136
+ def 別表七フォーム
137
+ return nil if @繰越損失管理.records.length == 0
138
+
139
+ 'HOB710'
140
+ end
141
+
142
+ def 別表七
143
+ return nil if @繰越損失管理.records.length == 0
144
+
145
+ render_erb(search_template('beppyo7.xml.erb'))
146
+ end
147
+
148
+ def 別表十五
149
+ @交際費 = readable(@pl_data.dig('C1B') || 0)
150
+ @限度額 = @交際費 < 4_000_000 ? @交際費 : 4_000_000
151
+ @不算入額 = @交際費 < 4_000_000 ? 0 : @交際費 - 4_000_000
152
+ render_erb(search_template('beppyo15.xml.erb'))
153
+ end
154
+
155
+ def 預貯金内訳
156
+ @預金 = @bs_data.each.with_object({}) do |(k, v), h|
157
+ next unless /^110[0-9A-Z]/.match(k)
158
+ next unless readable(v || 0) > 0
159
+
160
+ h[@@dict.dig(k)[:label]] = readable(v)
161
+ end
162
+ render_erb(search_template('yokin-meisai.xml.erb'))
163
+ end
164
+
165
+ def 仮受金内訳
166
+ @源泉給与 = readable(@bs_data.dig('5191') || 0)
167
+ @源泉報酬 = readable(@bs_data.dig('5193') || 0)
168
+ render_erb(search_template('kariuke-meisai.xml.erb'))
169
+ end
170
+
171
+ def 役員報酬内訳
172
+ @役員報酬 = readable(@pl_data.dig('C11') || 0)
173
+ @給料 = readable(@pl_data.dig('C12') || 0)
174
+ render_erb(search_template('yakuin-meisai.xml.erb'))
175
+ end
176
+
177
+ def 適用額明細フォーム
178
+ return nil if @確定法人税額 == 0
179
+
180
+ 'HOE990'
181
+ end
182
+
183
+ def 適用額明細
184
+ return nil if @確定法人税額 == 0
185
+
186
+ render_erb(search_template('tekiyougaku.xml.erb'))
187
+ end
188
+
189
+ def 概況説明
190
+ @概況粗利益 = gaikyo('BA')
191
+ @概況役員報酬 = gaikyo('C11')
192
+ @概況給料 = gaikyo('C12')
193
+ @概況交際費 = gaikyo('C1B')
194
+ @概況減価償却 = gaikyo('C1P')
195
+ @概況地代租税 = gaikyo('C1E') + gaikyo('C1I')
196
+ @概況営業損益 = gaikyo('CA')
197
+ @概況特別利益 = gaikyo('F0')
198
+ @概況特別損失 = gaikyo('G0')
199
+ @概況税引前損益 = gaikyo('GA')
200
+ @概況資産計 = gaikyo('5')
201
+ @概況現預金 = gaikyo('10')
202
+ @概況受取手形 = gaikyo('120')
203
+ @概況売掛金 = gaikyo('130')
204
+ @概況棚卸資産 = gaikyo('160')
205
+ @概況貸付金 = gaikyo('140') + gaikyo('333')
206
+ @概況建物 = gaikyo('311')
207
+ @概況機械 = gaikyo('313')
208
+ @概況車船 = gaikyo('314') + gaikyo('318')
209
+ @概況土地 = gaikyo('316')
210
+ @概況負債計 = gaikyo('8ZZ')
211
+ @概況支払手形 = gaikyo('510')
212
+ @概況買掛金 = gaikyo('511')
213
+ @概況個人借入金 = gaikyo('5121')
214
+ @概況ほか借入金 = gaikyo('512') - gaikyo('5121')
215
+ @概況純資産 = gaikyo('9ZZ')
216
+ @代表者報酬 = gaikyo('C11')
217
+ @代表者借入 = gaikyo('5121')
218
+ @概況仕入 = gaikyo('B11') + gaikyo('B12')
219
+ @概況外注費 = gaikyo('C10')
220
+ @概況人件費 = gaikyo('C11') + gaikyo('C12') + gaikyo('C13')
221
+ render_erb(search_template('gaikyo.xml.erb'))
222
+ end
223
+
224
+ private
225
+
226
+ def 期首未納事業税
227
+ readable(@start_balance.dig('5152')) || 0
228
+ end
229
+
230
+ def 期末未納事業税
231
+ readable(@bs_data.dig('5152')) || 0
232
+ end
233
+
234
+ def 当期事業税納付
235
+ readable(@pl_data.dig('C1I2')) || 0
236
+ end
237
+
238
+ def 租税公課
239
+ readable(LucaBook::State.gross(@start_date.year, @start_date.month, @end_date.year, @end_date.month, code: 'C1I')[:debit]['C1I']) || 0
240
+ end
241
+
242
+ def 別表四還付事業税
243
+ return nil if @還付事業税 == 0
244
+
245
+ "<ARC00220><ARC00230>仮払事業税消却(未収計上した還付事業税)</ARC00230>#{render_attr('ARC00240', @還付事業税)}#{render_attr('ARC00250', @還付事業税)}</ARC00220>\n"
246
+ end
247
+
248
+ def 期首繰越損益
249
+ readable(@start_balance.dig('914')) || 0
250
+ end
251
+
252
+ def 期末繰越損益
253
+ readable(@bs_data.dig('914')) || 0
254
+ end
255
+
256
+ def 期首納税充当金
257
+ readable(@start_balance.dig('515')) || 0
258
+ end
259
+
260
+ def 期末納税充当金
261
+ readable(@bs_data.dig('515')) || 0
262
+ end
263
+
264
+ def 納税充当金期中増減
265
+ r = LucaBook::State.gross(@start_date.year, @start_date.month, @end_date.year, @end_date.month, code: '515')
266
+ [
267
+ readable(r[:credit]['515'] || 0) + @法人税期中増 + @都道府県民税期中増 + @市民税期中増 + @事業税期中増,
268
+ readable(r[:debit]['515'] || 0) + @法人税期中減 + @都道府県民税期中減 + @市民税期中減 + @事業税期中減
269
+ ]
270
+ end
271
+
272
+ def 期首未納法人税
273
+ readable(@start_balance.dig('5151')) || 0
274
+ end
275
+
276
+ def 期末未納法人税
277
+ readable(@bs_data.dig('5151')) || 0
278
+ end
279
+
280
+ def 未納法人税期中増減
281
+ r = LucaBook::State.gross(@start_date.year, @start_date.month, @end_date.year, @end_date.month, code: '5151')
282
+ [readable(r[:credit]['5151'] || 0), readable(r[:debit]['5151'] || 0)]
283
+ end
284
+
285
+ # 中間納付した金額のうち税額とならず、還付されるべき額
286
+ #
287
+ def 法人税仮払納付額
288
+ [(@法人税中間納付 + @地方法人税中間納付 - @確定法人税額 - @確定地方法人税額), 0].max
289
+ end
290
+
291
+ # 中間納付した金額のうち税額として確定した額
292
+ #
293
+ def 法人税損金納付額
294
+ [@法人税中間納付 + @地方法人税中間納付, @確定法人税額 + @確定地方法人税額].min
295
+ end
296
+
297
+ def 確定都道府県住民税
298
+ @税額.dig(:kenmin, :kintou) + @税額.dig(:kenmin, :houjinzei)
299
+ end
300
+
301
+ def 期首未納都道府県民税
302
+ readable(@start_balance.dig('5153')) || 0
303
+ end
304
+
305
+ def 期末未納都道府県民税
306
+ readable(@bs_data.dig('5153')) || 0
307
+ end
308
+
309
+ def 未納都道府県民税期中増減
310
+ r = LucaBook::State.gross(@start_date.year, @start_date.month, @end_date.year, @end_date.month, code: '5153')
311
+ [readable(r[:credit]['5153'] || 0), readable(r[:debit]['5153'] || 0)]
312
+ end
313
+
314
+ def 都道府県民税仮払納付
315
+ [(@都道府県民税中間納付 - 確定都道府県住民税), 0].max
316
+ end
317
+
318
+ def 都道府県民税損金納付
319
+ [[確定都道府県住民税, 0].max, @都道府県民税中間納付].min
320
+ end
321
+
322
+ def 確定市民税
323
+ @税額.dig(:shimin, :kintou) - @税額.dig(:shimin, :houjinzei)
324
+ end
325
+
326
+ def 期首未納市民税
327
+ readable(@start_balance.dig('5154')) || 0
328
+ end
329
+
330
+ def 期末未納市民税
331
+ readable(@bs_data.dig('5154')) || 0
332
+ end
333
+
334
+ def 未納市民税期中増減
335
+ r = LucaBook::State.gross(@start_date.year, @start_date.month, @end_date.year, @end_date.month, code: '5154')
336
+ [readable(r[:credit]['5154'] || 0), readable(r[:debit]['5154'] || 0)]
337
+ end
338
+
339
+ def 市民税仮払納付
340
+ [0, (@市民税中間納付 - 確定市民税)].max
341
+ end
342
+
343
+ def 市民税損金納付
344
+ [@市民税中間納付, [確定市民税, 0].max].min
345
+ end
346
+
347
+ def 別表五一期首差引金額
348
+ 期首繰越損益 + 期首納税充当金 - 期首未納法人税 - 期首未納都道府県民税 - 期首未納市民税
349
+ end
350
+
351
+ def 別表五一期末差引金額
352
+ 期末繰越損益 + 期末納税充当金 - 期末未納法人税 - 期末未納都道府県民税 - 期末未納市民税
353
+ end
354
+
355
+ def 別表五一期中減差引金額
356
+ 期首繰越損益 + @納税充当金期中減 - @法人税期中減 - @都道府県民税期中減 - @市民税期中減
357
+ end
358
+
359
+ def 別表五一期中増差引金額
360
+ 期末繰越損益 + @納税充当金期中増 - @法人税期中増 - @都道府県民税期中増 - @市民税期中増
361
+ end
362
+
363
+ def 期末未収税金(code)
364
+ readable((@bs_data[code] || 0) * -1)
365
+ end
366
+
367
+ def 別表七各期青色損失
368
+ tags = @繰越損失管理.records
369
+ .filter { |record| record['start_date'] > @end_date.prev_year(10) && record['end_date'] < @start_date }
370
+ .map do |record|
371
+ deduction = record['decrease']&.filter{ |r| r['date'] >= @start_date }&.dig(0, 'val') || 0
372
+ next if deduction == 0 && record['amount'] == 0
373
+
374
+ %Q(<MCB00110>
375
+ <MCB00120>
376
+ #{render_attr('MCB00130', etax_date(record['start_date']))}
377
+ #{render_attr('MCB00140', etax_date(record['end_date']))}
378
+ </MCB00120>
379
+ <MCB00150>
380
+ <MCB00160><kubun_CD>1</kubun_CD></MCB00160>
381
+ </MCB00150>
382
+ #{render_attr('MCB00190', deduction + record['amount'])}
383
+ #{render_attr('MCB00200', deduction)}
384
+ #{render_attr('MCB00210', record['amount'])}
385
+ </MCB00110)
386
+ end
387
+ tags.compact.join("\n")
388
+ end
389
+
390
+ def 期首資本金
391
+ readable(@start_balance.dig('911')) || 0
392
+ end
393
+
394
+ def 期末資本金
395
+ readable(@bs_data.dig('911')) || 0
396
+ end
397
+
398
+ def 別表五一期首資本
399
+ 期首資本金
400
+ end
401
+
402
+ def 別表五一期末資本
403
+ 期末資本金
404
+ end
405
+
406
+ def 期首未納消費税
407
+ readable(@start_balance.dig('516')) || 0
408
+ end
409
+
410
+ def 期末未納消費税
411
+ readable(@bs_data.dig('516')) || 0
412
+ end
413
+
414
+ def 未納消費税期中増減
415
+ r = LucaBook::State.gross(@start_date.year, @start_date.month, @end_date.year, @end_date.month, code: '516')
416
+ [readable(r[:credit]['516'] || 0), readable(r[:debit]['516'] || 0)]
417
+ end
418
+
419
+ def 概況月(idx)
420
+ @start_date.next_month(idx).month
421
+ end
422
+
423
+ def 概況月売上(idx)
424
+ gaikyo_month(idx, 'A0')
425
+ end
426
+
427
+ def 概況月仕入(idx)
428
+ gaikyo_month(idx, 'B11') + gaikyo_month(idx, 'B12')
429
+ end
430
+
431
+ def 概況月人件費(idx)
432
+ gaikyo_month(idx, 'C11') + gaikyo_month(idx, 'C12') + gaikyo_month(idx, 'C13') + gaikyo_month(idx, 'C14')
433
+ end
434
+
435
+ def 概況月外注費(idx)
436
+ gaikyo_month(idx, 'C10')
437
+ end
438
+
439
+ def 概況月源泉徴収(idx)
440
+ target = @start_date.next_month(idx)
441
+ readable(LucaBook::State.gross(target.year, target.month, code: '5191')[:credit]['5191'] || 0)
442
+ + readable(LucaBook::State.gross(target.year, target.month, code: '5193')[:credit]['5193'] || 0)
443
+ end
444
+
445
+ def 概況源泉徴収
446
+ readable(LucaBook::State.gross(@start_date.year, @start_date.month, @end_date.year, @end_date.month, code: '5191')[:credit]['5191'] || 0)
447
+ + readable(LucaBook::State.gross(@start_date.year, @start_date.month, @end_date.year, @end_date.month, code: '5193')[:credit]['5193'] || 0)
448
+ end
449
+
450
+ def gaikyo(code)
451
+ case code
452
+ when /^[0-9]/
453
+ readable(@bs_data.dig(code) || 0)
454
+ when /^[A-H]/
455
+ readable(@pl_data.dig(code) || 0)
456
+ else
457
+ raise 'invalid code supplied'
458
+ end
459
+ end
460
+
461
+ def gaikyo_month(index, code)
462
+ readable(@monthly.dig(index, code) || 0)
463
+ end
464
+
465
+ def lib_path
466
+ __dir__
467
+ end
468
+ end
469
+ end
470
+ end