lucabook 0.2.29 → 0.2.31
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 +15 -1
- data/lib/luca_book/dict.rb +25 -0
- data/lib/luca_book/import.rb +3 -1
- data/lib/luca_book/list.rb +1 -0
- data/lib/luca_book/list_by_header.rb +3 -11
- data/lib/luca_book/state.rb +7 -2
- data/lib/luca_book/templates/dict-jp-edinet.tsv +1 -1
- data/lib/luca_book/templates/dict-jp.tsv +1 -1
- data/lib/luca_book/templates/journals.html.erb +1 -1
- data/lib/luca_book/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87936c519f40b82f1559b0cc20820e3f3a8b8d8afde4914ca1b8f749db5b69a0
|
4
|
+
data.tar.gz: 9dfc82e16185a42f2ea8e598b69a7f7448fb8aeae55d831ac72617980982e037
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f388153393b76ff871c6c8e028efeaf4476400608ec7b100c81bb1a39f0bf8efc67fa3b79d7d0e987bc8565e41c4098109164a7afe873baa816fafa2ca564ed7
|
7
|
+
data.tar.gz: 4701eb25e02571465d4ed053f1f17ee361a36f5420589dff1396f6adf1267d89e9f4de0c90fb812b45e549109da1fd0a93ce8133b007f0864120b64518037652
|
data/exe/luca-book
CHANGED
@@ -110,6 +110,11 @@ class LucaCmd
|
|
110
110
|
def self.update_balance(args, params)
|
111
111
|
LucaBook::Dict.generate_balance(*args)
|
112
112
|
end
|
113
|
+
|
114
|
+
def self.export_balance(args, params)
|
115
|
+
date = Date.new(args[0].to_i, args[1].to_i, args[2].to_i)
|
116
|
+
LucaBook::Dict.export_balance(date)
|
117
|
+
end
|
113
118
|
end
|
114
119
|
end
|
115
120
|
|
@@ -228,9 +233,11 @@ when /reports?/, 'r'
|
|
228
233
|
else
|
229
234
|
puts 'Proper subcommand needed.'
|
230
235
|
puts
|
231
|
-
puts 'Usage: luca-book (r|report[s]) (bs|pl) [options] YYYY M'
|
236
|
+
puts 'Usage: luca-book (r|report[s]) (bs|pl|mail|xbrl) [options] YYYY M'
|
232
237
|
puts ' bs: show balance sheet'
|
233
238
|
puts ' pl: show statement of income'
|
239
|
+
puts ' mail: send BS/PL via email'
|
240
|
+
puts ' xbrl: render XBRL report'
|
234
241
|
exit 1
|
235
242
|
end
|
236
243
|
when /balance/
|
@@ -242,6 +249,12 @@ when /balance/
|
|
242
249
|
args = opt.parse!(ARGV)
|
243
250
|
LucaCmd::Dict.update_balance(args, params)
|
244
251
|
end
|
252
|
+
when 'export'
|
253
|
+
OptionParser.new do |opt|
|
254
|
+
opt.banner = 'Usage: luca-book balance export YYYY M d'
|
255
|
+
args = opt.parse!(ARGV)
|
256
|
+
LucaCmd::Dict.export_balance(args, params)
|
257
|
+
end
|
245
258
|
end
|
246
259
|
else
|
247
260
|
puts 'Proper subcommand needed.'
|
@@ -249,5 +262,6 @@ else
|
|
249
262
|
puts 'Usage: luca-book (j[ournals]|r[eports]) subcommand'
|
250
263
|
puts ' journals: operate journal records'
|
251
264
|
puts ' reports: show reports'
|
265
|
+
puts ' balance update: generate accumulated balance'
|
252
266
|
exit 1
|
253
267
|
end
|
data/lib/luca_book/dict.rb
CHANGED
@@ -139,6 +139,31 @@ module LucaBook
|
|
139
139
|
File.open(filepath, 'w') { |f| f.write csv }
|
140
140
|
end
|
141
141
|
|
142
|
+
# TODO: support date in the middle of month.
|
143
|
+
def self.export_balance(date)
|
144
|
+
start_date, end_date = Util.current_fy(date, to: date)
|
145
|
+
labels = load('base.tsv')
|
146
|
+
bs = load_balance(start_date, end_date)
|
147
|
+
dat = [].tap do |res|
|
148
|
+
item = {}
|
149
|
+
item['date'] = date.to_s
|
150
|
+
item['debit'] = []
|
151
|
+
item['credit'] = []
|
152
|
+
bs.each do |code, balance|
|
153
|
+
next if balance.zero?
|
154
|
+
|
155
|
+
if /^[1-4]/.match(code)
|
156
|
+
item['debit'] << { 'label' => labels.dig(code, :label), 'amount' => LucaSupport::Code.readable(balance) }
|
157
|
+
elsif /^[5-9]/.match(code)
|
158
|
+
item['credit'] << { 'label' => labels.dig(code, :label), 'amount' => LucaSupport::Code.readable(balance) }
|
159
|
+
end
|
160
|
+
end
|
161
|
+
item['x-editor'] = 'LucaBook'
|
162
|
+
res << item
|
163
|
+
end
|
164
|
+
puts JSON.dump(dat)
|
165
|
+
end
|
166
|
+
|
142
167
|
def self.load_balance(start_date, end_date)
|
143
168
|
base = latest_balance(start_date).each_with_object({}) do |(k, v), h|
|
144
169
|
h[k] = BigDecimal(v[:balance].to_s) if v[:balance]
|
data/lib/luca_book/import.rb
CHANGED
@@ -81,7 +81,7 @@ module LucaBook
|
|
81
81
|
else
|
82
82
|
amount = BigDecimal(row[@config[:credit_amount]])
|
83
83
|
end
|
84
|
-
default_label = debit ? @config
|
84
|
+
default_label = debit ? @config[:default_debit] : @config[:default_credit]
|
85
85
|
code, options = search_code(row[@config[:label]], default_label, amount)
|
86
86
|
counter_code = @code_map.dig(@config[:counter_label])
|
87
87
|
if options
|
@@ -94,10 +94,12 @@ module LucaBook
|
|
94
94
|
d['date'] = parse_date(row)
|
95
95
|
if debit
|
96
96
|
d['debit'] = data
|
97
|
+
d['debit'][0]['code'] ||= DEBIT_DEFAULT
|
97
98
|
d['credit'] = data_c
|
98
99
|
else
|
99
100
|
d['debit'] = data_c
|
100
101
|
d['credit'] = data
|
102
|
+
d['credit'][0]['code'] ||= CREDIT_DEFAULT
|
101
103
|
end
|
102
104
|
d['note'] = Array(@config[:note]).map{ |col| row[col] }.join(' ')
|
103
105
|
d['headers'] = { 'x-editor' => "LucaBook::Import/#{@dict_name}" }
|
data/lib/luca_book/list.rb
CHANGED
@@ -162,6 +162,7 @@ module LucaBook #:nodoc:
|
|
162
162
|
view = { code: record[:code], amount: {} }
|
163
163
|
view[:date], view[:txid] = decode_id(voucher[:id])
|
164
164
|
view[:label] = @@dict.dig(record[:code], :label) if record[:code].length >= 4
|
165
|
+
view[:label] = voucher.dig(:headers, 'x-customer') if view[:label].nil?
|
165
166
|
view[:amount][balance] = readable(record[:amount])
|
166
167
|
view[:counter_code] = voucher.dig(counter_balance, 0, :code)
|
167
168
|
view[:counter_label] = @@dict.dig(view[:counter_code], :label) || ''
|
@@ -49,7 +49,7 @@ module LucaBook #:nodoc:
|
|
49
49
|
res['note'] = dat[:note]
|
50
50
|
end
|
51
51
|
end
|
52
|
-
a << { 'code' => v.last[:code], 'header' => k, 'balance' => v.last[:balance], 'count' => v.count, '
|
52
|
+
a << { 'code' => v.last[:code], 'header' => k, 'balance' => v.last[:balance], 'count' => v.count, 'journals' => journals }
|
53
53
|
end
|
54
54
|
readable(@data)
|
55
55
|
end
|
@@ -67,16 +67,8 @@ module LucaBook #:nodoc:
|
|
67
67
|
def set_balance
|
68
68
|
return BigDecimal('0') if @code.nil? || /^[A-H]/.match(@code)
|
69
69
|
|
70
|
-
|
71
|
-
start_balance
|
72
|
-
start = Dict.issue_date(balance_dict)&.next_month
|
73
|
-
last = @start.prev_month
|
74
|
-
if last.year >= start.year && last.month >= start.month
|
75
|
-
#TODO: start_balance to be implemented by header
|
76
|
-
self.class.term(start.year, start.month, last.year, last.month, code: @code).accumulate_code
|
77
|
-
else
|
78
|
-
#start_balance
|
79
|
-
end
|
70
|
+
#TODO: start_balance to be implemented by header
|
71
|
+
LucaBook::State.start_balance(@start.year, @start.month)
|
80
72
|
end
|
81
73
|
|
82
74
|
def calc_code
|
data/lib/luca_book/state.rb
CHANGED
@@ -146,7 +146,7 @@ module LucaBook
|
|
146
146
|
res['debit_label'] = base[:debit][i] ? @@dict.dig(base[:debit][i].keys[0], :label) : ''
|
147
147
|
#res['debit_balance'] = base[:debit][i] ? (@start_balance.dig(base[:debit][i].keys[0]) || 0) + base[:debit][i].values[0] : ''
|
148
148
|
res['debit_balance'] = base[:debit][i] ? base[:debit][i].values[0] : ''
|
149
|
-
res['credit_label'] = base[:credit][i] ?
|
149
|
+
res['credit_label'] = base[:credit][i] ? @@dict.dig(base[:credit][i].keys[0], :label) : ''
|
150
150
|
#res['credit_balance'] = base[:credit][i] ? (@start_balance.dig(base[:credit][i].keys[0]) || 0) + base[:credit][i].values[0] : ''
|
151
151
|
res['credit_balance'] = base[:credit][i] ? base[:credit][i].values[0] : ''
|
152
152
|
a << res
|
@@ -232,6 +232,7 @@ module LucaBook
|
|
232
232
|
recursive ? total_subaccount(total) : total
|
233
233
|
end
|
234
234
|
|
235
|
+
# TODO: currency setting other than JPY
|
235
236
|
def render_xbrl(filename = nil)
|
236
237
|
set_bs(3, legal: true)
|
237
238
|
set_pl(3)
|
@@ -260,7 +261,11 @@ module LucaBook
|
|
260
261
|
return nil if tag.nil?
|
261
262
|
return nil if readable(amount).zero? && prior_amount.nil?
|
262
263
|
|
263
|
-
prior = prior_amount.nil?
|
264
|
+
prior = if prior_amount.nil?
|
265
|
+
/^[9]/.match(code) ? "<#{tag} decimals=\"0\" unitRef=\"JPY\" contextRef=\"Prior1YearNonConsolidatedInstant\">0</#{tag}>\n" : ''
|
266
|
+
else
|
267
|
+
"<#{tag} decimals=\"0\" unitRef=\"JPY\" contextRef=\"Prior1YearNonConsolidatedInstant\">#{readable(prior_amount)}</#{tag}>\n"
|
268
|
+
end
|
264
269
|
current = "<#{tag} decimals=\"0\" unitRef=\"JPY\" contextRef=\"#{context}\">#{readable(amount)}</#{tag}>"
|
265
270
|
|
266
271
|
prior + current
|
@@ -82,7 +82,7 @@ code label xbrl_id consumption_tax income_tax
|
|
82
82
|
91 株主資本 jppfs_cor:ShareholdersAbstract
|
83
83
|
911 資本金 jppfs_cor:CapitalStock
|
84
84
|
912 新株式申込証拠金 jppfs_cor:DepositForSubscriptionsToShares
|
85
|
-
913 資本剰余金 jppfs_cor:
|
85
|
+
913 資本剰余金 jppfs_cor:CapitalSurplus
|
86
86
|
9131 資本準備金 jppfs_cor:LegalCapitalSurplus
|
87
87
|
9132 その他資本剰余金 jppfs_cor:OtherCapitalSurplus
|
88
88
|
914 利益剰余金 jppfs_cor:RetainedEarnings
|
@@ -105,7 +105,7 @@ code label xbrl_id consumption_tax income_tax
|
|
105
105
|
91 株主資本 jpfr-t-cte:ShareholdersEquity
|
106
106
|
911 資本金 jpfr-t-cte:CapitalStock
|
107
107
|
912 新株式申込証拠金 jpfr-t-cte:DepositForSubscriptionsToShares
|
108
|
-
913 資本剰余金 jpfr-t-cte:
|
108
|
+
913 資本剰余金 jpfr-t-cte:CapitalSurplus
|
109
109
|
9131 資本準備金 jpfr-t-cte:LegalCapitalSurplus
|
110
110
|
9132 その他資本剰余金 jpfr-t-cte:OtherCapitalSurplus
|
111
111
|
914 繰越利益剰余金 jpfr-t-cte:RetainedEarningsBroughtForward
|
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.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chuma Takahiro
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lucarecord
|
@@ -68,7 +68,7 @@ dependencies:
|
|
68
68
|
version: 12.3.3
|
69
69
|
description: 'Book keep
|
70
70
|
|
71
|
-
'
|
71
|
+
'
|
72
72
|
email:
|
73
73
|
- co.chuma@gmail.com
|
74
74
|
executables:
|
@@ -106,7 +106,7 @@ licenses:
|
|
106
106
|
metadata:
|
107
107
|
homepage_uri: https://github.com/chumaltd/luca/tree/master/lucabook
|
108
108
|
source_code_uri: https://github.com/chumaltd/luca/tree/master/lucabook
|
109
|
-
post_install_message:
|
109
|
+
post_install_message:
|
110
110
|
rdoc_options: []
|
111
111
|
require_paths:
|
112
112
|
- lib
|
@@ -121,8 +121,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: '0'
|
123
123
|
requirements: []
|
124
|
-
rubygems_version: 3.2.
|
125
|
-
signing_key:
|
124
|
+
rubygems_version: 3.2.5
|
125
|
+
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: Book keep
|
128
128
|
test_files: []
|