lucabook 0.5.3 → 0.5.6
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 +1 -1
- data/lib/luca_book/dict.rb +6 -5
- data/lib/luca_book/state.rb +17 -9
- data/lib/luca_book/templates/base-jp.xbrl.erb +0 -1
- data/lib/luca_book/templates/base-jp.xsd.erb +0 -1
- data/lib/luca_book/util.rb +7 -0
- data/lib/luca_book/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84fabdb63d40411cdee9a0030a1703e0073b5cff05d83c6381764afd74c8bb96
|
4
|
+
data.tar.gz: e8ce567fcb5738cb292111d2ec7a78e745ab2213e5a2a80514c894d2a9e5ae91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cd25b10a96bf01a8e83a28809a313c53ff71bc369b1f5b6f062b3ca4695eaf5acd7e0f4d0ac8d4de2234264a143c670378fab79c4a0e6b1f5fd7ce5d6170fc4
|
7
|
+
data.tar.gz: 2699cb60f9f33f2e97e11d9351649ccbac86dd422a50b0085064cb76cb48e1bbfb99d92d7ac88faadce64af02de57157b341274f6f7ee623ded3216c056b1896
|
data/exe/luca-book
CHANGED
data/lib/luca_book/dict.rb
CHANGED
@@ -102,12 +102,13 @@ module LucaBook
|
|
102
102
|
end
|
103
103
|
|
104
104
|
def self.latest_balance_path(date)
|
105
|
-
|
106
|
-
latest = Date.new(start_year, LucaSupport::CONST.config['fy_start'], 1).prev_month
|
105
|
+
start_date, _ = LucaBook::Util.current_fy(date)
|
107
106
|
dict_dir = Pathname(LucaSupport::CONST.pjdir) / 'data' / 'balance'
|
108
|
-
|
109
|
-
|
110
|
-
dict_dir /
|
107
|
+
paths = Dir.glob(%Q(start-*-*-*), base: dict_dir, sort: true)
|
108
|
+
.reject {|path| path > %Q(start-#{start_date.year}-#{format("%02d", start_date.month)}-) }
|
109
|
+
return dict_dir / 'start.tsv' if paths.empty?
|
110
|
+
|
111
|
+
dict_dir / paths.reverse.first
|
111
112
|
end
|
112
113
|
|
113
114
|
def self.issue_date(obj)
|
data/lib/luca_book/state.rb
CHANGED
@@ -130,10 +130,10 @@ module LucaBook
|
|
130
130
|
@bs = bs
|
131
131
|
|
132
132
|
mail = Mail.new
|
133
|
-
mail.to = LucaSupport::CONST.config.dig('mail', 'preview') || LucaSupport
|
133
|
+
mail.to = LucaSupport::CONST.config.dig('mail', 'preview') || LucaSupport::CONST.config.dig('mail', 'from')
|
134
134
|
mail.subject = 'Financial Report available'
|
135
135
|
mail.html_part = Mail::Part.new(body: render_erb(search_template('monthly-report.html.erb')), content_type: 'text/html; charset=UTF-8')
|
136
|
-
LucaSupport::Mail.new(mail, LucaSupport
|
136
|
+
LucaSupport::Mail.new(mail, LucaSupport::CONST.pjdir).deliver
|
137
137
|
end
|
138
138
|
|
139
139
|
def bs(level = 3, legal: false)
|
@@ -213,17 +213,18 @@ module LucaBook
|
|
213
213
|
|
214
214
|
def self.start_balance(year, month, recursive: true)
|
215
215
|
start_date = Date.new(year, month, 1)
|
216
|
-
|
216
|
+
balance = Dict.latest_balance(start_date)
|
217
|
+
base = balance.each_with_object({}) do |(k, v), h|
|
217
218
|
h[k] = BigDecimal(v[:balance].to_s) if v[:balance]
|
218
219
|
h[k] ||= BigDecimal('0') if k.length == 2
|
219
220
|
end
|
220
|
-
|
221
|
+
pre_first = Date.parse(balance.dig("_date", :label)).next_month
|
222
|
+
if start_date <= pre_first
|
221
223
|
return recursive ? total_subaccount(base) : base
|
222
224
|
end
|
223
225
|
|
224
226
|
pre_last = start_date.prev_month
|
225
|
-
|
226
|
-
pre = accumulate_term(year, LucaSupport::CONST.config['fy_start'], pre_last.year, pre_last.month)
|
227
|
+
pre = accumulate_term(pre_first.year, pre_first.month, pre_last.year, pre_last.month)
|
227
228
|
total = {}.tap do |h|
|
228
229
|
(pre.keys + base.keys).uniq.each do |k|
|
229
230
|
h[k] = (base[k] || BigDecimal('0')) + (pre[k] || BigDecimal('0'))
|
@@ -232,6 +233,14 @@ module LucaBook
|
|
232
233
|
recursive ? total_subaccount(total) : total
|
233
234
|
end
|
234
235
|
|
236
|
+
def write_xbrl(filename = nil)
|
237
|
+
xbrl, xsd = render_xbrl(filename)
|
238
|
+
doctype = %Q(<?xml version="1.0" encoding="UTF-8"?>)
|
239
|
+
|
240
|
+
File.open("#{@filename}.xbrl", 'w') { |f| f.write [doctype, xbrl].join("\n") }
|
241
|
+
File.open("#{@filename}.xsd", 'w') { |f| f.write [doctype, xsd].join("\n") }
|
242
|
+
end
|
243
|
+
|
235
244
|
def render_xbrl(filename = nil)
|
236
245
|
set_bs(3, legal: true)
|
237
246
|
set_pl(3)
|
@@ -248,8 +257,7 @@ module LucaBook
|
|
248
257
|
@xbrl_entries += equity_change.join("\n")
|
249
258
|
@filename = filename || "statement-#{@issue_date}"
|
250
259
|
|
251
|
-
|
252
|
-
File.open("#{@filename}.xsd", 'w') { |f| f.write render_erb(search_template("base-#{country_suffix}.xsd.erb")) }
|
260
|
+
[render_erb(search_template("base-#{country_suffix}.xbrl.erb")), render_erb(search_template("base-#{country_suffix}.xsd.erb"))]
|
253
261
|
end
|
254
262
|
|
255
263
|
# TODO: proper decimals attr for each currency
|
@@ -336,7 +344,7 @@ module LucaBook
|
|
336
344
|
changes = []
|
337
345
|
LucaBook::Journal.filter_by_code(@start_date.year, @start_date.month, @end_date.year, @end_date.month, '9').each do |dat|
|
338
346
|
debit_str = 'ASET' if dat[:debit].find { |e| /^[124]/.match(e[:code]) }
|
339
|
-
debit_str ||= '33' if dat[:debit].find { |e| /^
|
347
|
+
debit_str ||= '33' if dat[:debit].find { |e| /^33/.match(e[:code]) }
|
340
348
|
debit_str ||= 'ASET' if dat[:debit].find { |e| /^[3]/.match(e[:code]) }
|
341
349
|
credit_str = 'DEBT' if dat[:credit].find { |e| /^[57]/.match(e[:code]) }
|
342
350
|
credit_str ||= 'ASET' if dat[:credit].find { |e| /^[12]/.match(e[:code]) }
|
@@ -1,4 +1,3 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
1
|
<xbrli:xbrl xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:link="http://www.xbrl.org/2003/linkbase" xmlns:iso4217="http://www.xbrl.org/2003/iso4217" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jpfr-etax-di="http://xml.e-tax.nta.go.jp/jp/fr/etax/o/di/2013-03-25" xmlns:jpfr-oe="http://info.edinet-fsa.go.jp/jp/fr/gaap/o/oe/2012-01-25" xmlns:jpfr-t-cte="http://info.edinet-fsa.go.jp/jp/fr/gaap/t/cte/2012-01-25" xmlns:jppfs_cor="http://disclosure.edinet-fsa.go.jp/taxonomy/jppfs/2019-11-01/jppfs_cor" xmlns:jpfr-etax-t-cte="http://xml.e-tax.nta.go.jp/jp/fr/etax/t/cte/2013-03-25">
|
3
2
|
<link:schemaRef xmlns:link="http://www.xbrl.org/2003/linkbase" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="<%= @filename %>.xsd" />
|
4
3
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
1
|
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:link="http://www.xbrl.org/2003/linkbase" xmlns:e-tax-pks-<%= @issue_date %>="http://xbrlsoft.e-tax.nta.go.jp/XSD/e-tax-pks-<%= @issue_date %>" targetNamespace="http://xbrlsoft.e-tax.nta.go.jp/XSD/e-tax-pks-<%= @issue_date %>" elementFormDefault="qualified">
|
3
2
|
<xsd:import namespace="http://www.xbrl.org/2003/instance" schemaLocation="http://www.xbrl.org/2003/xbrl-instance-2003-12-31.xsd" />
|
4
3
|
<xsd:import namespace="http://xml.e-tax.nta.go.jp/jp/fr/etax/o/di/2013-03-25" schemaLocation="http://xml.e-tax.nta.go.jp/jp/fr/etax/o/di/2013-03-25/jpfr-etax-di-2013-03-25.xsd" />
|
data/lib/luca_book/util.rb
CHANGED
@@ -52,5 +52,12 @@ module LucaBook
|
|
52
52
|
@end_date = [to, @end_date].min if to
|
53
53
|
[@start_date, @end_date]
|
54
54
|
end
|
55
|
+
|
56
|
+
def previous_fy(date = nil)
|
57
|
+
current_start, current_end = current_fy(date)
|
58
|
+
@start_date = current_start.prev_year
|
59
|
+
@end_date = current_start.prev_day
|
60
|
+
[@start_date, @end_date]
|
61
|
+
end
|
55
62
|
end
|
56
63
|
end
|
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.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chuma Takahiro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lucarecord
|