lucadeal 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 599780f0a61b27bcea93724823c02bdfdd52b7b04a028265c00bc2fe1e0e865c
4
- data.tar.gz: 7b3a09097cb6543b3b07718c7ecb35fd21bcdafbe851eb6240a33707a2e7ddf3
3
+ metadata.gz: 14852f4570ab9b7da28524ffe3c4b9fc2129e96a3f7ade9991cfe2f20c8730e1
4
+ data.tar.gz: 0a002fdffad8e94900f81ca53d130407c2dee4f03770cc7881d22f7313d20603
5
5
  SHA512:
6
- metadata.gz: 2a8c83638b3ee0d8d9afb02bb555ee4bc679b89873b677a5f75751a9d75412479e6900be700f06dc6d44473d9a3149a11d173e5bb0b39ca45aa8055da22da120
7
- data.tar.gz: 4012470b9d9a1e671f1d0d4bcfd7144b4c4e097f282f099c518396706e946f313d22b35955c0999acf40753e284a0c9b48d7fec6d514492e477ee082e5623785
6
+ metadata.gz: 1046732b7d2256f2384186a38cd6d766d8409c7602959d864782f502b0c87729e24b1510c9662a92ea1dae2eb699edfa5e4b9ad36bd4ffd838bb9b42b1ca1ff7
7
+ data.tar.gz: 4fd222f9031b9032542794d01a81982ca38732ecf38c8dac5ef48a165034dcbcd325646a841595c2b4139d2e30c9471faf5ebeab0b8fab2d140f251e09b5151f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## LucaDeal 0.4.0
2
+
3
+ * implement `luca-deal invoices print` for local HTML/PDF rendering.
4
+ * remove `luca-deal invoices list --html` in favor of `print` sub command.
5
+
1
6
  ## LucaDeal 0.3.1
2
7
 
3
8
  * 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])
@@ -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.0'
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.0
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: 2022-05-19 00:00:00.000000000 Z
11
+ date: 2022-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lucarecord
@@ -103,7 +103,7 @@ metadata:
103
103
  homepage_uri: https://github.com/chumaltd/luca/tree/master/lucadeal
104
104
  source_code_uri: https://github.com/chumaltd/luca/tree/master/lucadeal
105
105
  changelog_uri: https://github.com/chumaltd/luca/tree/master/lucadeal/CHANGELOG.md
106
- post_install_message:
106
+ post_install_message:
107
107
  rdoc_options: []
108
108
  require_paths:
109
109
  - lib
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  requirements: []
121
121
  rubygems_version: 3.3.5
122
- signing_key:
122
+ signing_key:
123
123
  specification_version: 4
124
124
  summary: Deal with contracts
125
125
  test_files: []