lucadeal 0.3.1 → 0.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 599780f0a61b27bcea93724823c02bdfdd52b7b04a028265c00bc2fe1e0e865c
4
- data.tar.gz: 7b3a09097cb6543b3b07718c7ecb35fd21bcdafbe851eb6240a33707a2e7ddf3
3
+ metadata.gz: 560b745f485f42d80938858af2ff4cdbe1b2cc9aef27898ca0801430c6d638cd
4
+ data.tar.gz: f800500cc78a51ca0cb574856493ae43660d659a463f741b442d0887da9027a9
5
5
  SHA512:
6
- metadata.gz: 2a8c83638b3ee0d8d9afb02bb555ee4bc679b89873b677a5f75751a9d75412479e6900be700f06dc6d44473d9a3149a11d173e5bb0b39ca45aa8055da22da120
7
- data.tar.gz: 4012470b9d9a1e671f1d0d4bcfd7144b4c4e097f282f099c518396706e946f313d22b35955c0999acf40753e284a0c9b48d7fec6d514492e477ee082e5623785
6
+ metadata.gz: 1c1d0abdf72851ceb10a18cf64538aee7ef1c9313d0ab4fc86bcbebf090824e4002670225208b7ddf30c38eb6e064062e15ba15c858f411895c17ce674ca1612
7
+ data.tar.gz: 1d9f8d246ddd47196860e350662dc34989e810e0f5e9951b380e1028962ce4a0c9a2c926592991d5a8a39036a8ab38fbc38c22b6580bec8372f50ab02753e2f7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## LucaDeal 0.4.1
2
+
3
+ * Limit LucaRecord dependency '>= 0.5.4'
4
+
5
+ ## LucaDeal 0.4.0
6
+
7
+ * implement `luca-deal invoices print` for local HTML/PDF rendering.
8
+ * remove `luca-deal invoices list --html` in favor of `print` sub command.
9
+
1
10
  ## LucaDeal 0.3.1
2
11
 
3
12
  * add `luca-deal invoices settle --search-terms` for late payment case.
data/exe/luca-deal CHANGED
@@ -177,9 +177,7 @@ class LucaCmd
177
177
  date = "#{Date.today.year}-#{Date.today.month}-1"
178
178
  count = 3
179
179
  end
180
- if params[:html]
181
- LucaDeal::Invoice.new(date).preview_stdout
182
- elsif params[:mail]
180
+ if params[:mail]
183
181
  LucaDeal::Invoice.new(date).stats_email
184
182
  else
185
183
  render(LucaDeal::Invoice.new(date).stats(count || 1), params)
@@ -201,6 +199,16 @@ class LucaCmd
201
199
  end
202
200
  end
203
201
 
202
+ def self.print(args = nil, params = {})
203
+ if args.length >= 2
204
+ date = "#{args[0]}-#{args[1]}-#{args[2] || '1'}" if !args.empty?
205
+ LucaDeal::Invoice.new(date).print(nil, params)
206
+ else
207
+ date = "#{Date.today.year}-#{Date.today.month}-#{Date.today.day}"
208
+ LucaDeal::Invoice.new(date).print(args[0], params)
209
+ end
210
+ end
211
+
204
212
  def self.settle(args = nil, params = nil)
205
213
  str = args[0].nil? ? STDIN.read : File.read(args[0])
206
214
  LucaDeal::Invoice.settle(str, params[:term])
@@ -266,7 +274,7 @@ class LucaCmd
266
274
  when 'json'
267
275
  puts JSON.dump(dat)
268
276
  when 'nu'
269
- LucaSupport::View.nushell(YAML.dump(dat))
277
+ LucaSupport::View.nushell(dat)
270
278
  when 'csv'
271
279
  str = CSV.generate(String.new, col_sep: "\t") do |row|
272
280
  row << dat.first.keys
@@ -377,7 +385,6 @@ when /invoices?/, 'i'
377
385
  opt.banner = 'Usage: luca-deal invoices list [options] year month [date]'
378
386
  opt.on('--nu', 'show table in nushell') { |_v| params[:output] = 'nu' }
379
387
  opt.on('-o', '--output VAL', 'output serialized data') { |v| params[:output] = v }
380
- opt.on('--html', 'output html invoices') { |_v| params[:html] = 'monthly' }
381
388
  opt.on('--mail', 'send payment list by email') { |_v| params[:mail] = true }
382
389
  args = opt.parse(ARGV)
383
390
  LucaCmd::Invoice.list(args, params)
@@ -389,6 +396,13 @@ when /invoices?/, 'i'
389
396
  args = opt.parse(ARGV)
390
397
  LucaCmd::Invoice.mail(args, params)
391
398
  end
399
+ when 'print'
400
+ OptionParser.new do |opt|
401
+ opt.banner = 'Usage: luca-deal invoices print [options] <invoice_id | year month>'
402
+ opt.on('--pdf', 'output PDF invoices. wkhtmlpdf is required') { |_v| params[:output] = :pdf }
403
+ args = opt.parse(ARGV)
404
+ LucaCmd::Invoice.print(args, params)
405
+ end
392
406
  when 'settle'
393
407
  params[:term] = 1
394
408
  OptionParser.new do |opt|
@@ -405,6 +419,7 @@ when /invoices?/, 'i'
405
419
  puts ' delete'
406
420
  puts ' list'
407
421
  puts ' mail: send mail with invoice'
422
+ puts ' print: render invoices into HTML/PDF'
408
423
  puts ' settle'
409
424
  exit 1
410
425
  end
@@ -40,13 +40,26 @@ module LucaDeal
40
40
  end
41
41
  end
42
42
 
43
- # Render HTML to console
43
+ # Render HTML/PDF to files
44
+ # TODO: change output dir
44
45
  #
45
- def preview_stdout
46
- self.class.asof(@date.year, @date.month) do |dat, _|
46
+ def print(id = nil, params = {})
47
+ filetype = params[:output] || :html
48
+ if id
49
+ dat = self.class.find(id)
47
50
  @company = set_company
48
51
  invoice_vars(dat)
49
- puts render_invoice
52
+ File.open(attachment_name(dat, filetype), 'w') do |f|
53
+ f.puts render_invoice(filetype)
54
+ end
55
+ else
56
+ self.class.asof(@date.year, @date.month) do |dat, _|
57
+ @company = set_company
58
+ invoice_vars(dat)
59
+ File.open(attachment_name(dat, filetype), 'w') do |f|
60
+ f.puts render_invoice(filetype)
61
+ end
62
+ end
50
63
  end
51
64
  end
52
65
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LucaDeal
4
- VERSION = '0.3.1'
4
+ VERSION = '0.4.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lucadeal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chuma Takahiro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-19 00:00:00.000000000 Z
11
+ date: 2023-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lucarecord
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.5.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 0.5.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement