lucabook 0.2.17 → 0.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/exe/luca-book +44 -14
- data/lib/luca_book/state.rb +23 -15
- data/lib/luca_book/templates/dict-en.tsv +7 -0
- data/lib/luca_book/templates/dict-jp.tsv +18 -13
- data/lib/luca_book/version.rb +1 -1
- metadata +2 -3
- data/lib/luca_book/report.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d25b3a6c62980682db52a5553ce26cafdcb36e80e9657a302a8413e1e92b565b
|
4
|
+
data.tar.gz: e82a86c04d13aa6addef398afd85755a7a54ce437d1e9415ce3f98bf1b28f914
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 652c00f982977bbb619bfc834c312dbbb06f2ada524e1824869c04ef4ed09e3fadd5aee2b082fc3944cda4eaf7bfd18fd041a80582fe57f67cc88d13197b60a6
|
7
|
+
data.tar.gz: 422dedf33b9a9bd53ac8502613ae4a27c3c10730e2ac65841fddd9e424d9435a2cb92118700f9571dceea09b54b1f9a1538b9c76facfed87542832e2ce4ba939
|
data/exe/luca-book
CHANGED
@@ -12,20 +12,21 @@ module LucaCmd
|
|
12
12
|
LucaBook::Import.import_json(STDIN.read)
|
13
13
|
else
|
14
14
|
puts 'Usage: luca-book import -c import_config'
|
15
|
+
exit 1
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
18
19
|
def self.list(args, params)
|
20
|
+
args = LucaCmd.gen_range(params[:n] || 1) if args.empty?
|
19
21
|
if params['code']
|
20
22
|
LucaBook::List.term(*args, code: params['code']).list_on_code.to_yaml
|
21
|
-
elsif args.length > 0
|
22
|
-
LucaBook::List.term(*args).list_journals.to_yaml
|
23
23
|
else
|
24
|
-
|
24
|
+
LucaBook::List.term(*args).list_journals.to_yaml
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.stats(args, params)
|
29
|
+
args = LucaCmd.gen_range(params[:n]) if args.empty?
|
29
30
|
LucaBook::State.term(*args).stats(params[:level])
|
30
31
|
end
|
31
32
|
end
|
@@ -34,13 +35,24 @@ module LucaCmd
|
|
34
35
|
def self.balancesheet(args, params)
|
35
36
|
level = params[:level] || 2
|
36
37
|
legal = params[:legal] || false
|
38
|
+
args = LucaCmd.gen_range(params[:n] || 1) if args.empty?
|
37
39
|
LucaBook::State.term(*args).bs(level, legal: legal)
|
38
40
|
end
|
39
41
|
|
40
42
|
def self.profitloss(args, params)
|
43
|
+
args = LucaCmd.gen_range(params[:n]) if args.empty?
|
41
44
|
LucaBook::State.term(*args).pl.to_yaml
|
42
45
|
end
|
43
46
|
end
|
47
|
+
|
48
|
+
module_function
|
49
|
+
|
50
|
+
def gen_range(count)
|
51
|
+
count ||= 3
|
52
|
+
today = Date.today
|
53
|
+
start = today.prev_month(count - 1)
|
54
|
+
[start.year, start.month, today.year, today.month]
|
55
|
+
end
|
44
56
|
end
|
45
57
|
|
46
58
|
def new_pj(args = nil, params = {})
|
@@ -57,7 +69,7 @@ when /journals?/, 'j'
|
|
57
69
|
case subcmd
|
58
70
|
when 'import'
|
59
71
|
OptionParser.new do |opt|
|
60
|
-
opt.banner = 'Usage: luca-book journals import filepath'
|
72
|
+
opt.banner = 'Usage: luca-book journals import [options] filepath'
|
61
73
|
opt.on('-c', '--config VAL', 'import definition'){ |v| params['config'] = v }
|
62
74
|
opt.on('-j', '--json', 'import via json format'){ |_v| params['json'] = true }
|
63
75
|
args = opt.parse!(ARGV)
|
@@ -65,23 +77,32 @@ when /journals?/, 'j'
|
|
65
77
|
end
|
66
78
|
when 'list'
|
67
79
|
OptionParser.new do |opt|
|
68
|
-
opt.banner = 'Usage: luca-book journals list [
|
80
|
+
opt.banner = 'Usage: luca-book journals list [options] [YYYY M]'
|
69
81
|
opt.on('-c', '--code VAL', 'search with code') { |v| params['code'] = v }
|
82
|
+
opt.on('-n VAL', 'report count') { |v| params[:n] = v.to_i }
|
70
83
|
opt.on_tail('List records. If you specify code and/or month, search on each criteria.')
|
71
84
|
args = opt.parse!(ARGV)
|
72
85
|
LucaCmd::Journal.list(args, params)
|
73
86
|
end
|
74
87
|
when 'stats'
|
75
88
|
OptionParser.new do |opt|
|
76
|
-
opt.banner = 'Usage: luca-book
|
77
|
-
opt.on('-
|
89
|
+
opt.banner = 'Usage: luca-book journals stats [options] [YYYY M]'
|
90
|
+
opt.on('-n VAL', 'report count') { |v| params[:n] = v.to_i }
|
78
91
|
args = opt.parse!(ARGV)
|
79
92
|
LucaCmd::Journal.stats(args, params)
|
80
93
|
end
|
94
|
+
else
|
95
|
+
puts 'Proper subcommand needed.'
|
96
|
+
puts
|
97
|
+
puts 'Usage: luca-book (j|journal[s]) subcommand [options] [YYYY M YYYY M]'
|
98
|
+
puts ' import: import journals from JSON/TSV'
|
99
|
+
puts ' list: list journals'
|
100
|
+
puts ' stats: list account statistics'
|
101
|
+
exit 1
|
81
102
|
end
|
82
103
|
when 'new'
|
83
104
|
OptionParser.new do |opt|
|
84
|
-
opt.banner = 'Usage: luca-book new Dir'
|
105
|
+
opt.banner = 'Usage: luca-book new [options] Dir'
|
85
106
|
opt.on('-c', '--country VAL', 'specify country code') { |v| params['coountry'] = v }
|
86
107
|
args = opt.parse(ARGV)
|
87
108
|
new_pj(args, params)
|
@@ -91,7 +112,7 @@ when /reports?/, 'r'
|
|
91
112
|
case subcmd
|
92
113
|
when 'bs'
|
93
114
|
OptionParser.new do |opt|
|
94
|
-
opt.banner = 'Usage: luca-book reports bs'
|
115
|
+
opt.banner = 'Usage: luca-book reports bs [options] [YYYY M]'
|
95
116
|
opt.on('-l', '--level VAL', 'account level') { |v| params[:level] = v.to_i }
|
96
117
|
opt.on('--legal', 'show legal mandatory account') { |_v| params[:legal] = true }
|
97
118
|
args = opt.parse!(ARGV)
|
@@ -99,15 +120,24 @@ when /reports?/, 'r'
|
|
99
120
|
end
|
100
121
|
when 'pl'
|
101
122
|
OptionParser.new do |opt|
|
102
|
-
opt.banner = 'Usage: luca-book reports pl'
|
123
|
+
opt.banner = 'Usage: luca-book reports pl [options] [YYYY M YYYY M]'
|
124
|
+
opt.on('-n VAL', 'report count') { |v| params[:n] = v.to_i }
|
103
125
|
args = opt.parse!(ARGV)
|
104
126
|
LucaCmd::Report.profitloss(args, params)
|
105
127
|
end
|
128
|
+
else
|
129
|
+
puts 'Proper subcommand needed.'
|
130
|
+
puts
|
131
|
+
puts 'Usage: luca-book (r|report[s]) (bs|pl) [options] YYYY M'
|
132
|
+
puts ' bs: show balance sheet'
|
133
|
+
puts ' pl: show statement of income'
|
134
|
+
exit 1
|
106
135
|
end
|
107
|
-
|
108
|
-
puts '
|
136
|
+
else
|
137
|
+
puts 'Proper subcommand needed.'
|
138
|
+
puts
|
139
|
+
puts 'Usage: luca-book (j[ournals]|r[eports]) subcommand'
|
109
140
|
puts ' journals: operate journal records'
|
110
141
|
puts ' reports: show reports'
|
111
|
-
|
112
|
-
puts 'Invalid subcommand'
|
142
|
+
exit 1
|
113
143
|
end
|
data/lib/luca_book/state.rb
CHANGED
@@ -47,9 +47,9 @@ module LucaBook
|
|
47
47
|
reports = [].tap do |r|
|
48
48
|
while date <= last_date do
|
49
49
|
diff, count = accumulate_month(date.year, date.month)
|
50
|
-
r << diff
|
51
|
-
counts << count
|
52
|
-
date = date.next_month
|
50
|
+
r << diff.tap { |c| c['_d'] = date.to_s }
|
51
|
+
counts << count.tap { |c| c['_d'] = date.to_s }
|
52
|
+
date = Date.new(date.next_month.year, date.next_month.month, -1)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
new reports, counts
|
@@ -87,16 +87,18 @@ module LucaBook
|
|
87
87
|
@statement ||= @data
|
88
88
|
@statement.map do |report|
|
89
89
|
{}.tap do |h|
|
90
|
-
report.each { |k, v| h[@dict.dig(k, :label)] = v }
|
90
|
+
report.each { |k, v| h[@dict.dig(k, :label) || k] = v }
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
95
|
def stats(level = nil)
|
96
|
-
keys = @count.map(&:keys).flatten.uniq.sort
|
96
|
+
keys = @count.map(&:keys).flatten.push('_t').uniq.sort
|
97
97
|
@count.map! do |data|
|
98
|
+
sum = 0
|
98
99
|
keys.each do |k|
|
99
100
|
data[k] ||= 0
|
101
|
+
sum += data[k] if /^[^_]/.match(k)
|
100
102
|
next if level.nil? || k.length <= level
|
101
103
|
|
102
104
|
if data[k[0, level]]
|
@@ -106,6 +108,7 @@ module LucaBook
|
|
106
108
|
end
|
107
109
|
end
|
108
110
|
data.select! { |k, _v| k.length <= level } if level
|
111
|
+
data['_t'] = sum
|
109
112
|
data.sort.to_h
|
110
113
|
end
|
111
114
|
keys.map! { |k| k[0, level] }.uniq.select! { |k| k.length <= level } if level
|
@@ -147,7 +150,7 @@ module LucaBook
|
|
147
150
|
case k
|
148
151
|
when /^[0-4].*/
|
149
152
|
res[:debit] << { k => v }
|
150
|
-
when /^[5-
|
153
|
+
when /^[5-9].*/
|
151
154
|
res[:credit] << { k => v }
|
152
155
|
end
|
153
156
|
end
|
@@ -155,8 +158,9 @@ module LucaBook
|
|
155
158
|
end
|
156
159
|
|
157
160
|
def pl
|
158
|
-
@statement = @data.map { |data| data.select { |k, _v| /^[A-
|
161
|
+
@statement = @data.map { |data| data.select { |k, _v| /^[A-H_].+/.match(k) } }
|
159
162
|
@statement << @statement.each_with_object({}) { |item, h| item.each { |k, v| h[k].nil? ? h[k] = v : h[k] += v } }
|
163
|
+
.tap { |h| h['_d'] = 'Total' }
|
160
164
|
self
|
161
165
|
end
|
162
166
|
|
@@ -169,12 +173,6 @@ module LucaBook
|
|
169
173
|
#
|
170
174
|
def self.total_subaccount(report)
|
171
175
|
{}.tap do |res|
|
172
|
-
res['10'] = sum_matched(report, /^[123][0-9A-Z]{2,}/)
|
173
|
-
res['40'] = sum_matched(report, /^[4][0-9A-Z]{2,}/)
|
174
|
-
res['50'] = sum_matched(report, /^[56][0-9A-Z]{2,}/)
|
175
|
-
res['70'] = sum_matched(report, /^[78][0-9A-Z]{2,}/)
|
176
|
-
res['8ZZ'] = res['50'] + res['70']
|
177
|
-
res['9ZZ'] = sum_matched(report, /^[9][0-9A-Z]{2,}/)
|
178
176
|
res['A0'] = sum_matched(report, /^[A][0-9A-Z]{2,}/)
|
179
177
|
res['B0'] = sum_matched(report, /^[B][0-9A-Z]{2,}/)
|
180
178
|
res['BA'] = res['A0'] - res['B0']
|
@@ -184,12 +182,22 @@ module LucaBook
|
|
184
182
|
res['E0'] = sum_matched(report, /^[E][0-9A-Z]{2,}/)
|
185
183
|
res['EA'] = res['CA'] + res['D0'] - res['E0']
|
186
184
|
res['F0'] = sum_matched(report, /^[F][0-9A-Z]{2,}/)
|
187
|
-
res['G0'] = sum_matched(report, /^[G][0-9A-Z]{
|
185
|
+
res['G0'] = sum_matched(report, /^[G][0-9][0-9A-Z]{1,}/)
|
188
186
|
res['GA'] = res['EA'] + res['F0'] - res['G0']
|
189
|
-
res['
|
187
|
+
res['H0'] = sum_matched(report, /^[H][0-9][0-9A-Z]{1,}/)
|
188
|
+
res['HA'] = res['GA'] - res['H0']
|
189
|
+
|
190
|
+
res['9142'] = (report['9142'] || 0) + res['HA']
|
191
|
+
res['10'] = sum_matched(report, /^[123][0-9A-Z]{2,}/)
|
192
|
+
res['40'] = sum_matched(report, /^[4][0-9A-Z]{2,}/)
|
193
|
+
res['50'] = sum_matched(report, /^[56][0-9A-Z]{2,}/)
|
194
|
+
res['70'] = sum_matched(report, /^[78][0-9A-Z]{2,}/)
|
195
|
+
res['8ZZ'] = res['50'] + res['70']
|
196
|
+
res['9ZZ'] = sum_matched(report, /^[9][0-9A-Z]{2,}/)
|
190
197
|
|
191
198
|
res['1'] = res['10'] + res['40']
|
192
199
|
res['5'] = res['8ZZ'] + res['9ZZ'] + res['HA']
|
200
|
+
res['_d'] = report['_d']
|
193
201
|
|
194
202
|
report.each do |k, v|
|
195
203
|
if k.length >= 4
|
@@ -115,6 +115,11 @@ C1O 外注費
|
|
115
115
|
C1P Depreciation
|
116
116
|
C1Q Miscellaneous
|
117
117
|
C1R 貸倒引当金繰入
|
118
|
+
C1S 支払報酬
|
119
|
+
C1T 研修費
|
120
|
+
C1U 採用費
|
121
|
+
C1V 業務委託費
|
122
|
+
C1W 会議費
|
118
123
|
CA Operating profit/loss
|
119
124
|
D0 営業外収益
|
120
125
|
D11 Interest income
|
@@ -139,4 +144,6 @@ G11 固定資産売却損
|
|
139
144
|
G12 固定資産除却損
|
140
145
|
G13 災害損失
|
141
146
|
GA Income before taxes
|
147
|
+
H0 Income Taxes
|
148
|
+
H11 Income Taxes Current
|
142
149
|
HA Net Income/Loss
|
@@ -1,5 +1,5 @@
|
|
1
1
|
code label xbrl_id consumption_tax income_tax
|
2
|
-
1 資産合計
|
2
|
+
1 資産合計 jppfs_cor:AssetsAbstract
|
3
3
|
10 流動資産 jppfs_cor:CurrentAssetsAbstract
|
4
4
|
10XX UNSETTLED_IMPORT
|
5
5
|
110 現金及び預金 jppfs_cor:CashAndDeposits
|
@@ -55,7 +55,7 @@ code label xbrl_id consumption_tax income_tax
|
|
55
55
|
442 創立費 jppfs_cor:DeferredOrganisationExpensesDA
|
56
56
|
442 新株発行費 jppfs_cor:StockIssuanceCostDA
|
57
57
|
443 社債発行費 jppfs_cor:BondIssuanceCostDA
|
58
|
-
5 負債・純資産合計
|
58
|
+
5 負債・純資産合計 jppfs_cor:LiabilitiesAndNetAssets
|
59
59
|
50 流動負債 jppfs_cor:CurrentLiabilitiesAbstract
|
60
60
|
50XX UNSETTLED_IMPORT
|
61
61
|
510 支払手形 jppfs_cor:NotePayableTrade
|
@@ -74,25 +74,24 @@ code label xbrl_id consumption_tax income_tax
|
|
74
74
|
712 長期借入金 jppfs_cor:LongTermLoansPayable
|
75
75
|
713 退職給付引当金 jppfs_cor:ProvisionForRetirementBenefits
|
76
76
|
714 繰延税金負債 jppfs_cor:DeferredTaxLiabilities
|
77
|
-
8ZZ 負債合計
|
78
|
-
90 純資産 jppfs_cor:NetAssetsAbstract
|
77
|
+
8ZZ 負債合計 jppfs_cor:LiabilitiesAbstract
|
79
78
|
91 株主資本 jppfs_cor:ShareholdersAbstract
|
80
79
|
911 資本金 jppfs_cor:CapitalStock
|
81
|
-
912 新株式申込証拠金
|
80
|
+
912 新株式申込証拠金 jppfs_cor:DepositForSubscriptionsToShares
|
82
81
|
913 資本剰余金 jppfs_cor:LegalCapitalSurplus
|
83
|
-
9131 資本準備金
|
84
|
-
9132 その他資本剰余金
|
82
|
+
9131 資本準備金 jppfs_cor:LegalCapitalSurplus
|
83
|
+
9132 その他資本剰余金 jppfs_cor:OtherCapitalSurplus
|
85
84
|
914 利益剰余金 jppfs_cor:RetainedEarnings
|
86
|
-
9141 利益準備金
|
87
|
-
9142 その他利益剰余金
|
85
|
+
9141 利益準備金 jppfs_cor:LegalRetainedEarnings
|
86
|
+
9142 その他利益剰余金 jppfs_cor:OtherRetainedEarningsAbstract
|
88
87
|
915 自己株式 jppfs_cor:TreasuryStock
|
89
|
-
916 自己株式申込証拠金
|
88
|
+
916 自己株式申込証拠金 jppfs_cor:DepositForSubscriptionsToTreasuryStock
|
90
89
|
92 評価換算差額等 jppfs_cor:ValuationAndTranslationAdjustments
|
91
90
|
921 有価証券評価差額金 jppfs_cor:ValuationDifferenceOnAvailableForSaleSecurities
|
92
91
|
922 為替換算調整勘定 jppfs_cor:ForeignCurrencyTranslationAdjustment
|
93
92
|
93 新株予約権 jppfs_cor:SubscriptionRightsToShares
|
94
93
|
940 非支配株主持分 jppfs_cor:NonControllingInterests
|
95
|
-
9ZZ 純資産合計
|
94
|
+
9ZZ 純資産合計 jppfs_cor:NetAssetsAbstract
|
96
95
|
A0 売上 jppfs_cor:NetSalesAbstract
|
97
96
|
A11 売上高 jppfs_cor:NetSales
|
98
97
|
B0 売上原価 jppfs_cor:CostOfSalesAbstract
|
@@ -130,7 +129,11 @@ C1O 外注費 jppfs_cor:SubcontructExpensesSGA
|
|
130
129
|
C1P 減価償却費 jppfs_cor:DepreciationSGA
|
131
130
|
C1Q 雑費 jppfs_cor:MiscellaneousExpensesSGA
|
132
131
|
C1R 貸倒引当金繰入 jppfs_cor:ProvisionOfAllowanceForDebtfulAccountsSGA
|
133
|
-
C1S 支払報酬
|
132
|
+
C1S 支払報酬 jppfs_cor:CompensationsSGA
|
133
|
+
C1T 研修費 jppfs_cor:TrainingExpensesSGA
|
134
|
+
C1U 採用費 jppfs_cor:RecruitingExpensesSGA
|
135
|
+
C1V 業務委託費 jppfs_cor:BusinessConsignmentExpensesSGA
|
136
|
+
C1W 会議費 jppfs_cor:ConferenceExpensesSGA
|
134
137
|
CA 営業利益 jppfs_cor:OperatingIncome
|
135
138
|
D0 営業外収益 jppfs_cor:NonOperatingIncomeAbstract
|
136
139
|
D11 受取利息 jppfs_cor:InterestIncomeNOI
|
@@ -154,5 +157,7 @@ G0 特別損失 jppfs_cor:ExtraordinaryLossAbstract
|
|
154
157
|
G11 固定資産売却損 jppfs_cor:LossOnSalesOfNoncurrentAssetsEL
|
155
158
|
G12 固定資産除却損 jppfs_cor:LossOnRetirementOfNoncurrentAssetsEL
|
156
159
|
G13 災害損失 jppfs_cor:LossOnDisasterEL
|
157
|
-
GA
|
160
|
+
GA 税引前利益 jppfs_cor:IncomeBeforeIncomeTaxes
|
161
|
+
H0 法人税等 jppfs_cor:IncomeTaxes
|
162
|
+
H11 法人税、住民税及び事業税 jppfs_cor:IncomeTaxesCurrent
|
158
163
|
HA 当期利益 jppfs_cor:ProfitLoss
|
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.18
|
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-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lucarecord
|
@@ -84,7 +84,6 @@ files:
|
|
84
84
|
- lib/luca_book/import.rb
|
85
85
|
- lib/luca_book/journal.rb
|
86
86
|
- lib/luca_book/list.rb
|
87
|
-
- lib/luca_book/report.rb
|
88
87
|
- lib/luca_book/setup.rb
|
89
88
|
- lib/luca_book/state.rb
|
90
89
|
- lib/luca_book/templates/base-jp.xbrl.erb
|
data/lib/luca_book/report.rb
DELETED