14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/luca/jp/urikake.rb', line 14
def report(encoding = nil)
listed_amount = 0
encoding ||= 'SJIS'
customers, total = list
format_ver = @date > Date.new(2024, 3, 1) ? 4 : 3
str = CSV.generate(String.new, headers: false, col_sep: ',', encoding: encoding) do |f|
customers.map do |c|
amount = readable(c['unsettled'])
listed_amount += amount
if format_ver >= 4
address = c['tax_id'] ? nil : c['address']
f << ['3', '0', '売掛金', c['tax_id']&.to_i, nil, c['customer'], address, amount, nil ]
else
f << ['3', '0', '売掛金', c['customer'], c['address'], amount, nil ]
end
end
if format_ver >= 4
f << ['3', '0', '売掛金', nil, nil, 'その他', nil, total - listed_amount, nil ]
f << ['3', '1', nil, nil, nil, nil, nil, total, nil ]
else
f << ['3', '0', '売掛金', 'その他', nil, total - listed_amount, nil ]
f << ['3', '1', nil, nil, nil, total, nil ]
end
end
STDERR.puts "Writing HOI030_#{format_ver}.0.csv..."
File.open("HOI030_#{format_ver}.0.csv", 'w') { |f| f.write(str) }
end
|