lucabook 0.2.21 → 0.2.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/luca-book +3 -3
- data/lib/luca_book/dict.rb +77 -0
- data/lib/luca_book/import.rb +29 -32
- data/lib/luca_book/import_jp.rb +83 -0
- data/lib/luca_book/journal.rb +17 -0
- data/lib/luca_book/list.rb +0 -4
- data/lib/luca_book/state.rb +12 -48
- data/lib/luca_book/templates/dict-en.tsv +23 -23
- data/lib/luca_book/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4755b2574729e35ae914dd92338ed007df2e1158d49c613613cac3b42423c6ee
|
4
|
+
data.tar.gz: a559a270322897b10b6dae569102f028004221431300debe19f3d0e5ae6432fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34b28c364e41ddecf9296ef39130897f03228e0bb0184241e0a7fce4349d41b14ff0ea72318154eb0bfa5e8fdac401783851c61e34e3419620eac6ab12cf6b05
|
7
|
+
data.tar.gz: 1bbd862143cc37ba7c459a6d3fae832bbdad744b1db6afc3956175fa97660a1decf8a778c6c40c3e276dd35272ed363f5d9e575ce555b73a368cf2ef8173fcbf
|
data/exe/luca-book
CHANGED
@@ -31,7 +31,7 @@ class LucaCmd
|
|
31
31
|
if params['code']
|
32
32
|
render(LucaBook::State.by_code(params['code'], *args), params)
|
33
33
|
else
|
34
|
-
render(LucaBook::State.
|
34
|
+
render(LucaBook::State.range(*args).stats(params[:level]), params)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -41,13 +41,13 @@ class LucaCmd
|
|
41
41
|
level = params[:level] || 3
|
42
42
|
legal = params[:legal] || false
|
43
43
|
args = gen_range(params[:n] || 1) if args.empty?
|
44
|
-
render(LucaBook::State.
|
44
|
+
render(LucaBook::State.range(*args).bs(level, legal: legal), params)
|
45
45
|
end
|
46
46
|
|
47
47
|
def self.profitloss(args, params)
|
48
48
|
level = params[:level] || 2
|
49
49
|
args = gen_range(params[:n]) if args.empty?
|
50
|
-
render(LucaBook::State.
|
50
|
+
render(LucaBook::State.range(*args).pl(level), params)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
data/lib/luca_book/dict.rb
CHANGED
@@ -7,6 +7,83 @@ require 'pathname'
|
|
7
7
|
|
8
8
|
module LucaBook
|
9
9
|
class Dict < LucaRecord::Dict
|
10
|
+
# Column number settings for CSV/TSV convert
|
11
|
+
#
|
12
|
+
# :label
|
13
|
+
# for double entry data
|
14
|
+
# :counter_label
|
15
|
+
# must be specified with label
|
16
|
+
# :debit_label
|
17
|
+
# for double entry data
|
18
|
+
# * debit_value
|
19
|
+
# :credit_label
|
20
|
+
# for double entry data
|
21
|
+
# * credit_value
|
22
|
+
# :note
|
23
|
+
# can be the same column as another label
|
24
|
+
#
|
25
|
+
# :encoding
|
26
|
+
# file encoding
|
27
|
+
#
|
28
|
+
def csv_config
|
29
|
+
{}.tap do |config|
|
30
|
+
if @config.dig('label')
|
31
|
+
config[:label] = @config['label'].to_i
|
32
|
+
if @config.dig('counter_label')
|
33
|
+
config[:counter_label] = @config['counter_label']
|
34
|
+
config[:type] = 'single'
|
35
|
+
end
|
36
|
+
elsif @config.dig('debit_label')
|
37
|
+
config[:debit_label] = @config['debit_label'].to_i
|
38
|
+
if @config.dig('credit_label')
|
39
|
+
config[:credit_label] = @config['credit_label'].to_i
|
40
|
+
config[:type] = 'double'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
config[:type] ||= 'invalid'
|
44
|
+
config[:debit_value] = @config['debit_value'].to_i if @config.dig('debit_value')
|
45
|
+
config[:credit_value] = @config['credit_value'].to_i if @config.dig('credit_value')
|
46
|
+
config[:note] = @config['note'] if @config.dig('note')
|
47
|
+
config[:encoding] = @config['encoding'] if @config.dig('encoding')
|
48
|
+
|
49
|
+
config[:year] = @config['year'] if @config.dig('year')
|
50
|
+
config[:month] = @config['month'] if @config.dig('month')
|
51
|
+
config[:day] = @config['day'] if @config.dig('day')
|
52
|
+
config[:default_debit] = @config['default_debit'] if @config.dig('default_debit')
|
53
|
+
config[:default_credit] = @config['default_credit'] if @config.dig('default_credit')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def search(word, default_word = nil, amount = nil)
|
58
|
+
res = super(word, default_word, main_key: 'account_label')
|
59
|
+
if res.is_a?(Array) && res[0].is_a?(Array)
|
60
|
+
filter_amount(res, amount)
|
61
|
+
else
|
62
|
+
res
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Choose setting on Big or small condition.
|
67
|
+
#
|
68
|
+
def filter_amount(settings, amount = nil)
|
69
|
+
return settings[0] if amount.nil?
|
70
|
+
|
71
|
+
settings.each do |item|
|
72
|
+
return item unless item[1].keys.include?(:on_amount)
|
73
|
+
|
74
|
+
condition = item.dig(1, :on_amount)
|
75
|
+
case condition[0]
|
76
|
+
when '>'
|
77
|
+
return item if amount > BigDecimal(condition[1..])
|
78
|
+
when '<'
|
79
|
+
return item if amount < BigDecimal(condition[1..])
|
80
|
+
else
|
81
|
+
return item
|
82
|
+
end
|
83
|
+
end
|
84
|
+
nil
|
85
|
+
end
|
86
|
+
|
10
87
|
def self.latest_balance
|
11
88
|
dict_dir = Pathname(LucaSupport::Config::Pjdir) / 'data' / 'balance'
|
12
89
|
# TODO: search latest balance dictionary
|
data/lib/luca_book/import.rb
CHANGED
@@ -4,9 +4,14 @@ require 'date'
|
|
4
4
|
require 'json'
|
5
5
|
require 'luca_book'
|
6
6
|
require 'luca_support'
|
7
|
-
#require 'luca_book/dict'
|
8
7
|
require 'luca_record'
|
9
8
|
|
9
|
+
begin
|
10
|
+
require "luca_book/import_#{LucaSupport::CONFIG['country']}"
|
11
|
+
rescue LoadError => e
|
12
|
+
e.message
|
13
|
+
end
|
14
|
+
|
10
15
|
module LucaBook
|
11
16
|
class Import
|
12
17
|
DEBIT_DEFAULT = '10XX'
|
@@ -18,7 +23,7 @@ module LucaBook
|
|
18
23
|
@target_file = path
|
19
24
|
# TODO: yaml need to be configurable
|
20
25
|
@dict_name = dict
|
21
|
-
@dict =
|
26
|
+
@dict = LucaBook::Dict.new("import-#{dict}.yaml")
|
22
27
|
@code_map = LucaRecord::Dict.reverse(LucaRecord::Dict.load('base.tsv'))
|
23
28
|
@config = @dict.csv_config if dict
|
24
29
|
end
|
@@ -45,8 +50,6 @@ module LucaBook
|
|
45
50
|
#
|
46
51
|
def self.import_json(io)
|
47
52
|
JSON.parse(io).each do |d|
|
48
|
-
validate(d)
|
49
|
-
|
50
53
|
code_map = LucaRecord::Dict.reverse(LucaRecord::Dict.load('base.tsv'))
|
51
54
|
d['debit'].each { |h| h['code'] = code_map.dig(h['label']) || DEBIT_DEFAULT }
|
52
55
|
d['credit'].each { |h| h['code'] = code_map.dig(h['label']) || CREDIT_DEFAULT }
|
@@ -67,46 +70,39 @@ module LucaBook
|
|
67
70
|
end
|
68
71
|
end
|
69
72
|
|
70
|
-
def self.validate(obj)
|
71
|
-
raise 'NoDateKey' unless obj.key?('date')
|
72
|
-
raise 'NoDebitKey' unless obj.key?('debit')
|
73
|
-
raise 'NoDebitValue' if obj['debit'].empty?
|
74
|
-
raise 'NoCreditKey' unless obj.key?('credit')
|
75
|
-
raise 'NoCreditValue' if obj['credit'].empty?
|
76
|
-
end
|
77
|
-
|
78
73
|
private
|
79
74
|
|
80
|
-
#
|
81
75
|
# convert single entry data
|
82
76
|
#
|
83
77
|
def parse_single(row)
|
84
|
-
|
78
|
+
if (row.dig(@config[:credit_value]) || []).empty?
|
79
|
+
value = BigDecimal(row[@config[:debit_value]])
|
80
|
+
debit = true
|
81
|
+
else
|
82
|
+
value = BigDecimal(row[@config[:credit_value]])
|
83
|
+
end
|
84
|
+
default_label = debit ? @config.dig(:default_debit) : @config.dig(:default_credit)
|
85
|
+
code, options = search_code(row[@config[:label]], default_label, value)
|
86
|
+
counter_code = @code_map.dig(@config[:counter_label])
|
87
|
+
if respond_to? :tax_extension
|
88
|
+
data, data_c = tax_extension(code, counter_code, value, options) if options
|
89
|
+
end
|
90
|
+
data ||= [{ 'code' => code, 'value' => value }]
|
91
|
+
data_c ||= [{ 'code' => counter_code, 'value' => value }]
|
85
92
|
{}.tap do |d|
|
86
93
|
d['date'] = parse_date(row)
|
87
|
-
if
|
88
|
-
d['debit'] =
|
89
|
-
|
90
|
-
]
|
91
|
-
d['credit'] = [
|
92
|
-
{ 'code' => @code_map.dig(@config[:counter_label]) }
|
93
|
-
]
|
94
|
+
if debit
|
95
|
+
d['debit'] = data
|
96
|
+
d['credit'] = data_c
|
94
97
|
else
|
95
|
-
d['debit'] =
|
96
|
-
|
97
|
-
]
|
98
|
-
d['credit'] = [
|
99
|
-
{ 'code' => search_code(row[@config[:label]], @config.dig(:default_credit)) || CREDIT_DEFAULT }
|
100
|
-
]
|
98
|
+
d['debit'] = data_c
|
99
|
+
d['credit'] = data
|
101
100
|
end
|
102
|
-
d['debit'][0]['value'] = value
|
103
|
-
d['credit'][0]['value'] = value
|
104
101
|
d['note'] = Array(@config[:note]).map{ |col| row[col] }.join(' ')
|
105
102
|
d['x-editor'] = "LucaBook::Import/#{@dict_name}"
|
106
103
|
end
|
107
104
|
end
|
108
105
|
|
109
|
-
#
|
110
106
|
# convert double entry data
|
111
107
|
#
|
112
108
|
def parse_double(row)
|
@@ -125,8 +121,9 @@ module LucaBook
|
|
125
121
|
end
|
126
122
|
end
|
127
123
|
|
128
|
-
def search_code(label, default_label)
|
129
|
-
@
|
124
|
+
def search_code(label, default_label, amount = nil)
|
125
|
+
label, options = @dict.search(label, default_label, amount)
|
126
|
+
[@code_map.dig(label), options]
|
130
127
|
end
|
131
128
|
|
132
129
|
def parse_date(row)
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
require 'luca_book'
|
5
|
+
require 'luca_support'
|
6
|
+
|
7
|
+
module LucaBook
|
8
|
+
class Import
|
9
|
+
# TODO: need to be separated into pluggable l10n module.
|
10
|
+
# TODO: gensen rate >1m yen.
|
11
|
+
# TODO: gensen & consumption `round()` rules need to be confirmed.
|
12
|
+
# Profit or Loss account should be specified as code1.
|
13
|
+
#
|
14
|
+
def tax_extension(code1, code2, amount, options)
|
15
|
+
return nil if options.nil? || options[:tax_options].nil?
|
16
|
+
return nil if !options[:tax_options].include?('jp-gensen') && !options[:tax_options].include?('jp-consumption')
|
17
|
+
|
18
|
+
gensen_rate = BigDecimal('0.1021')
|
19
|
+
consumption_rate = BigDecimal('0.1')
|
20
|
+
gensen_code = @code_map.dig(options[:gensen_label]) || @code_map.dig('預り金')
|
21
|
+
gensen_idx = /^[5-8B-G]/.match(code1) ? 1 : 0
|
22
|
+
consumption_idx = /^[A-G]/.match(code1) ? 0 : 1
|
23
|
+
consumption_code = @code_map.dig(options[:consumption_label])
|
24
|
+
consumption_code ||= /^[A]/.match(code1) ? @code_map.dig('仮受消費税等') : @code_map.dig('仮払消費税等')
|
25
|
+
if options[:tax_options].include?('jp-gensen') && options[:tax_options].include?('jp-consumption')
|
26
|
+
paid_rate = BigDecimal('1') + consumption_rate - gensen_rate
|
27
|
+
gensen_amount = (amount / paid_rate * gensen_rate).round
|
28
|
+
consumption_amount = (amount / paid_rate * consumption_rate).round
|
29
|
+
[].tap do |res|
|
30
|
+
res << [].tap do |res1|
|
31
|
+
amount1 = amount
|
32
|
+
amount1 -= consumption_amount if consumption_idx == 0
|
33
|
+
amount1 += gensen_amount if gensen_idx == 1
|
34
|
+
res1 << { 'code' => code1, 'value' => amount1 }
|
35
|
+
res1 << { 'code' => consumption_code, 'value' => consumption_amount } if consumption_idx == 0
|
36
|
+
res1 << { 'code' => gensen_code, 'value' => gensen_amount } if gensen_idx == 0
|
37
|
+
end
|
38
|
+
res << [].tap do |res2|
|
39
|
+
amount2 = amount
|
40
|
+
amount2 -= consumption_amount if consumption_idx == 1
|
41
|
+
amount2 += gensen_amount if gensen_idx == 0
|
42
|
+
res2 << { 'code' => code2, 'value' => amount2 }
|
43
|
+
res2 << { 'code' => consumption_code, 'value' => consumption_amount } if consumption_idx == 1
|
44
|
+
res2 << { 'code' => gensen_code, 'value' => gensen_amount } if gensen_idx == 1
|
45
|
+
end
|
46
|
+
end
|
47
|
+
elsif options[:tax_options].include?('jp-gensen')
|
48
|
+
paid_rate = BigDecimal('1') - gensen_rate
|
49
|
+
gensen_amount = (amount / paid_rate * gensen_rate).round
|
50
|
+
[].tap do |res|
|
51
|
+
res << [].tap do |res1|
|
52
|
+
amount1 = amount
|
53
|
+
amount1 += gensen_amount if gensen_idx == 1
|
54
|
+
res1 << { 'code' => code, 'value' => amount1 }
|
55
|
+
res1 << { 'code' => gensen_code, 'value' => gensen_amount } if gensen_idx == 0
|
56
|
+
end
|
57
|
+
res << [].tap do |res2|
|
58
|
+
amount2 = amount
|
59
|
+
amount2 += gensen_amount if gensen_idx == 0
|
60
|
+
mount2 ||= amount
|
61
|
+
res2 << { 'code' => code2, 'value' => amount2 }
|
62
|
+
res2 << { 'code' => gensen_code, 'value' => gensen_amount } if gensen_idx == 1
|
63
|
+
end
|
64
|
+
end
|
65
|
+
elsif options[:tax_options].include?('jp-consumption')
|
66
|
+
paid_rate = BigDecimal('1') + consumption_rate - gensen_rate
|
67
|
+
consumption_amount = (amount / paid_rate * consumption_rate).round
|
68
|
+
res << [].tap do |res1|
|
69
|
+
amount1 = amount
|
70
|
+
amount1 -= consumption_amount if consumption_idx == 0
|
71
|
+
res1 << { 'code' => code1, 'value' => amount1 }
|
72
|
+
res1 << { 'code' => consumption_code, 'value' => consumption_amount } if consumption_idx == 0
|
73
|
+
end
|
74
|
+
res << [].tap do |res2|
|
75
|
+
amount2 = amount
|
76
|
+
amount2 -= consumption_amount if consumption_idx == 1
|
77
|
+
res2 << { 'code' => code2, 'value' => amount2 }
|
78
|
+
res2 << { 'code' => consumption_code, 'value' => consumption_amount } if consumption_idx == 1
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/luca_book/journal.rb
CHANGED
@@ -13,6 +13,7 @@ module LucaBook
|
|
13
13
|
# create journal from hash
|
14
14
|
#
|
15
15
|
def self.create(d)
|
16
|
+
validate(d)
|
16
17
|
date = Date.parse(d['date'])
|
17
18
|
|
18
19
|
debit_amount = LucaSupport::Code.decimalize(serialize_on_key(d['debit'], 'value'))
|
@@ -52,6 +53,22 @@ module LucaBook
|
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
56
|
+
def self.validate(obj)
|
57
|
+
raise 'NoDateKey' unless obj.key?('date')
|
58
|
+
raise 'NoDebitKey' unless obj.key?('debit')
|
59
|
+
raise 'NoCreditKey' unless obj.key?('credit')
|
60
|
+
debit_codes = serialize_on_key(obj['debit'], 'code').compact
|
61
|
+
debit_values = serialize_on_key(obj['debit'], 'value').compact
|
62
|
+
raise 'NoDebitCode' if debit_codes.empty?
|
63
|
+
raise 'NoDebitValue' if debit_values.empty?
|
64
|
+
raise 'UnmatchDebit' if debit_codes.length != debit_values.length
|
65
|
+
credit_codes = serialize_on_key(obj['credit'], 'code').compact
|
66
|
+
credit_values = serialize_on_key(obj['credit'], 'value').compact
|
67
|
+
raise 'NoCreditCode' if credit_codes.empty?
|
68
|
+
raise 'NoCreditValue' if credit_values.empty?
|
69
|
+
raise 'UnmatchCredit' if credit_codes.length != credit_values.length
|
70
|
+
end
|
71
|
+
|
55
72
|
# collect values on specified key
|
56
73
|
#
|
57
74
|
def self.serialize_on_key(array_of_hash, key)
|
data/lib/luca_book/list.rb
CHANGED
data/lib/luca_book/state.rb
CHANGED
@@ -25,21 +25,7 @@ module LucaBook
|
|
25
25
|
@start_balance = set_balance
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
def search_tag(code)
|
30
|
-
count = 0
|
31
|
-
Dir.children(LucaSupport::Config::Pjdir).sort.each do |dir|
|
32
|
-
next if ! FileTest.directory?(LucaSupport::Config::Pjdir+dir)
|
33
|
-
|
34
|
-
open_records(datadir, dir, 3) do |row, i|
|
35
|
-
next if i == 2
|
36
|
-
count += 1 if row.include?(code)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
puts "#{code}: #{count}"
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.term(from_year, from_month, to_year = from_year, to_month = from_month)
|
28
|
+
def self.range(from_year, from_month, to_year = from_year, to_month = from_month)
|
43
29
|
date = Date.new(from_year.to_i, from_month.to_i, -1)
|
44
30
|
last_date = Date.new(to_year.to_i, to_month.to_i, -1)
|
45
31
|
raise 'invalid term specified' if date > last_date
|
@@ -64,7 +50,7 @@ module LucaBook
|
|
64
50
|
reports = [].tap do |r|
|
65
51
|
while date <= last_date do
|
66
52
|
diff = {}.tap do |h|
|
67
|
-
g = gross(date.year, date.month, code)
|
53
|
+
g = gross(date.year, date.month, code: code)
|
68
54
|
sum = g.dig(:debit).nil? ? BigDecimal('0') : Util.calc_diff(g[:debit], code)
|
69
55
|
sum -= g.dig(:credit).nil? ? BigDecimal('0') : Util.calc_diff(g[:credit], code)
|
70
56
|
h['code'] = code
|
@@ -80,22 +66,9 @@ module LucaBook
|
|
80
66
|
date = Date.new(date.next_month.year, date.next_month.month, -1)
|
81
67
|
end
|
82
68
|
end
|
83
|
-
#YAML.dump(LucaSupport::Code.readable(reports)) #.tap{ |data| puts data }
|
84
|
-
#new(reports, counts, date: Date.new(from_year.to_i, from_month.to_i, -1))
|
85
69
|
LucaSupport::Code.readable(reports)
|
86
70
|
end
|
87
71
|
|
88
|
-
def records_with_balance(year, month, code, balance)
|
89
|
-
@book.search(year, month, nil, code).each do |h|
|
90
|
-
balance += Util.calc_diff(Util.amount_by_code(h[:debit], code), code) - Util.calc_diff(Util.amount_by_code(h[:credit], code), code)
|
91
|
-
h[:balance] = balance
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def to_yaml
|
96
|
-
YAML.dump(readable(code2label)).tap { |data| puts data }
|
97
|
-
end
|
98
|
-
|
99
72
|
def code2label
|
100
73
|
@statement ||= @data
|
101
74
|
@statement.map do |report|
|
@@ -201,14 +174,11 @@ module LucaBook
|
|
201
174
|
return nil if date > last_date
|
202
175
|
|
203
176
|
{}.tap do |res|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
next if /^[_]/.match(k)
|
177
|
+
diff, _count = net(date.year, date.month, last_date.year, last_date.month)
|
178
|
+
diff.each do |k, v|
|
179
|
+
next if /^[_]/.match(k)
|
208
180
|
|
209
|
-
|
210
|
-
end
|
211
|
-
date = date.next_month
|
181
|
+
res[k] = res[k].nil? ? v : res[k] + v
|
212
182
|
end
|
213
183
|
end
|
214
184
|
end
|
@@ -299,15 +269,17 @@ module LucaBook
|
|
299
269
|
|
300
270
|
# for assert purpose
|
301
271
|
#
|
302
|
-
def self.gross(
|
272
|
+
def self.gross(start_year, start_month, end_year = nil, end_month = nil, code: nil, date_range: nil, rows: 4)
|
303
273
|
if ! date_range.nil?
|
304
274
|
raise if date_range.class != Range
|
305
275
|
# TODO: date based range search
|
306
276
|
end
|
307
277
|
|
278
|
+
end_year ||= start_year
|
279
|
+
end_month ||= start_month
|
308
280
|
sum = { debit: {}, credit: {}, debit_count: {}, credit_count: {} }
|
309
281
|
idx_memo = []
|
310
|
-
|
282
|
+
term(start_year, start_month, end_year, end_month, code) do |f, _path|
|
311
283
|
CSV.new(f, headers: false, col_sep: "\t", encoding: 'UTF-8')
|
312
284
|
.each_with_index do |row, i|
|
313
285
|
break if i >= rows
|
@@ -357,8 +329,8 @@ module LucaBook
|
|
357
329
|
|
358
330
|
# netting vouchers in specified term
|
359
331
|
#
|
360
|
-
def self.net(
|
361
|
-
g = gross(
|
332
|
+
def self.net(start_year, start_month, end_year = nil, end_month = nil, code: nil, date_range: nil)
|
333
|
+
g = gross(start_year, start_month, end_year, end_month, code: code, date_range: date_range)
|
362
334
|
idx = (g[:debit].keys + g[:credit].keys).uniq.sort
|
363
335
|
count = {}
|
364
336
|
diff = {}.tap do |sum|
|
@@ -371,14 +343,6 @@ module LucaBook
|
|
371
343
|
[diff, count]
|
372
344
|
end
|
373
345
|
|
374
|
-
# TODO: obsolete in favor of Dict.latest_balance()
|
375
|
-
def load_start
|
376
|
-
file = Pathname(LucaSupport::Config::Pjdir) / 'data' / 'balance' / 'start.tsv'
|
377
|
-
{}.tap do |dict|
|
378
|
-
LucaRecord::Dict.load_tsv_dict(file).each { |k, v| h[k] = v[:balance] if !v[:balance].nil? }
|
379
|
-
end
|
380
|
-
end
|
381
|
-
|
382
346
|
private
|
383
347
|
|
384
348
|
def legal_items
|
@@ -1,19 +1,19 @@
|
|
1
|
-
code label
|
1
|
+
code label xbrl_id consumption_tax income_tax
|
2
2
|
10 Current Assets
|
3
3
|
10XX UNSETTLED_IMPORT
|
4
4
|
110 Cash and cash equivalents
|
5
5
|
1101 Saving accounts
|
6
6
|
1102 Checking accounts
|
7
|
-
111 Cash
|
8
|
-
120 Notes receivable
|
9
|
-
130 Accounts receivable - trade
|
7
|
+
111 Cash us-gaap:Cash
|
8
|
+
120 Notes receivable us-gaap:NotesReceivableGross
|
9
|
+
130 Accounts receivable - trade us-gaap:AccountsReceivableGross
|
10
10
|
140 短期貸付金
|
11
11
|
150 未収入金
|
12
|
-
160 Inventory
|
12
|
+
160 Inventory us-gaap:InventoryGross
|
13
13
|
161 商品
|
14
14
|
162 製品
|
15
|
-
163 Inventory work in process
|
16
|
-
164 Supplies
|
15
|
+
163 Inventory work in process us-gaap:InventoryWorkInProcess
|
16
|
+
164 Supplies us-gaap:Supplies
|
17
17
|
180 その他流動資産
|
18
18
|
181 前渡金
|
19
19
|
182 Prepaid expenses
|
@@ -22,17 +22,17 @@ code label xbrl_id consumption_tax income_tax
|
|
22
22
|
1D0 Deferred income tax
|
23
23
|
40 Fixed Assets
|
24
24
|
410 Tangible Assets
|
25
|
-
411 Buildings
|
25
|
+
411 Buildings us-gaap:BuildingsAndImprovementsGross
|
26
26
|
412 Equipment
|
27
27
|
413 Machinery
|
28
28
|
414 Vehicles
|
29
29
|
415 Tools
|
30
30
|
416 Land
|
31
|
-
417 Construction in progress
|
31
|
+
417 Construction in progress us-gaap:ConstructionInProgressGross
|
32
32
|
418 Ships
|
33
33
|
420 Intangible Assets
|
34
34
|
421 Software
|
35
|
-
422 Goodwill
|
35
|
+
422 Goodwill us-gaap:Goodwill
|
36
36
|
423 Patents
|
37
37
|
424 借地権
|
38
38
|
425 商標権
|
@@ -52,10 +52,10 @@ code label xbrl_id consumption_tax income_tax
|
|
52
52
|
443 社債発行費
|
53
53
|
50 Current Liabilities
|
54
54
|
50XX UNSETTLED_IMPORT
|
55
|
-
510 Notes payable
|
55
|
+
510 Notes payable us-gaap:NotesPayable
|
56
56
|
511 Accounts payable - trade
|
57
|
-
512 Short-term borrowings
|
58
|
-
513 Commercial paper
|
57
|
+
512 Short-term borrowings us-gaap:ShortermBorrowings
|
58
|
+
513 Commercial paper us-gaap:CommercialPaper
|
59
59
|
514 Accounts payable - other
|
60
60
|
515 Income taxes payable
|
61
61
|
516 未払消費税等
|
@@ -66,7 +66,7 @@ code label xbrl_id consumption_tax income_tax
|
|
66
66
|
51B Deferred tax liabilities
|
67
67
|
70 Long-term Liabilities
|
68
68
|
711 Debt securities
|
69
|
-
712 Loans payable
|
69
|
+
712 Loans payable us-gaap:LoansPayable
|
70
70
|
713 退職給付引当金
|
71
71
|
714 Deferred tax liabilities
|
72
72
|
90 Net Assets
|
@@ -74,7 +74,7 @@ code label xbrl_id consumption_tax income_tax
|
|
74
74
|
911 Capital stock
|
75
75
|
912 Capital surplus
|
76
76
|
913 Retained earnings
|
77
|
-
914 Treasury stock
|
77
|
+
914 Treasury stock us-gaap:TreasuryStockValue
|
78
78
|
920 評価換算差額等
|
79
79
|
921 有価証券評価差額金
|
80
80
|
922 為替換算調整勘定
|
@@ -88,29 +88,29 @@ B12 Parts
|
|
88
88
|
B13 Labor
|
89
89
|
BA Gross profit
|
90
90
|
C0 Operating expenses
|
91
|
-
C11 Officers Compensation
|
92
|
-
C12 Salaries
|
91
|
+
C11 Officers Compensation us-gaap:OfficersCompensation
|
92
|
+
C12 Salaries us-gaap:SalariesAndWages
|
93
93
|
C13 Bonuses
|
94
94
|
C14 役員賞与
|
95
95
|
C15 退職金
|
96
96
|
C16 Legal welfare
|
97
|
-
C17 Travel
|
98
|
-
C18 Communication
|
99
|
-
C19 Repairs
|
100
|
-
C1A Advertising
|
97
|
+
C17 Travel us-gaap:TravelAndEntertainmentExpense
|
98
|
+
C18 Communication us-gaap:Communication
|
99
|
+
C19 Repairs us-gaap:CostOfPropertyRepairsAndMaintenance
|
100
|
+
C1A Advertising us-gaap:AdvertisingExpense
|
101
101
|
C1B Entertainment
|
102
102
|
C1C Packing-and-freight
|
103
103
|
C1D Welfare
|
104
104
|
C1E Rents
|
105
105
|
C1F Utilities
|
106
|
-
C1G Supplies
|
106
|
+
C1G Supplies us-gaap:SuppliesExpense
|
107
107
|
C1H Insurance
|
108
108
|
C1I Taxes
|
109
109
|
C1J 賃借料
|
110
110
|
C1K Books
|
111
111
|
C1L 貸倒損失
|
112
112
|
C1M 諸会費
|
113
|
-
C1N Fees and commisions
|
113
|
+
C1N Fees and commisions us-gaap:BankingFeesAndCommisions
|
114
114
|
C1O 外注費
|
115
115
|
C1P Depreciation
|
116
116
|
C1Q Miscellaneous
|
data/lib/luca_book/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lucabook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chuma Takahiro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lucarecord
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- lib/luca_book/console.rb
|
83
83
|
- lib/luca_book/dict.rb
|
84
84
|
- lib/luca_book/import.rb
|
85
|
+
- lib/luca_book/import_jp.rb
|
85
86
|
- lib/luca_book/journal.rb
|
86
87
|
- lib/luca_book/list.rb
|
87
88
|
- lib/luca_book/setup.rb
|