lucasalary 0.1.16 → 0.1.17

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: f49cf6d52b646b39f7016d61c0647689ea43508072064dcc8dd76c424eae7afa
4
- data.tar.gz: 03d2e15f7245f9297c5176e7488be53daf1fd5f07ab84577cd10721910e803d5
3
+ metadata.gz: e1eaada7633a6968784a6421f92f6393aebb762d67725f7df7237a429e4dd0f5
4
+ data.tar.gz: 7168896dd1c49cd1a4f44e35ab5dc232426c304964fb878bff67d899db9f8753
5
5
  SHA512:
6
- metadata.gz: f103a5237210acd3d5baa555799ee6acefaccbbd75278d9d9ab45ff176a706cb05be12aa02913cbdfec940f42084643f5cb052453ef3f2f2f83cc607c974cd4f
7
- data.tar.gz: 914e93f2dda3788ddfc2913046bb7ffc8f6c74b59468ae47c21253df97189408dd4eb24c6ed8d06999e5a39fe1c95bda0fd8cd95564d10e579fd2089fa550099
6
+ metadata.gz: b959970ee8cec2debca73f672c2f16d6365d3bd29b5c53fc4814369ecf08e9312f137c824371c799e3a2bf4cda2f27f3b200a3d7a46e5c66a599a78702fb3175
7
+ data.tar.gz: fa89846e020e818a8e9367312292a9256757ebed278bc1d7afbbe785a525d28929a7f04d4801490164e749dcbdee65da051108546cbae7a364fc32bd8cfc392c
@@ -0,0 +1,4 @@
1
+ ## LucaSalary 0.1.17
2
+
3
+ * Breaking change: restructure CLI in sub-sub command format.
4
+ * Add 'x-editor' on export to LucaBook
@@ -5,60 +5,76 @@ require 'optparse'
5
5
  require 'luca_salary'
6
6
  require 'luca_salary/monthly'
7
7
 
8
- def export(args = nil, _params = nil)
9
- if args
10
- args << 28 if args.length == 2 # specify safe last day
11
- LucaSalary::Monthly.new(args.join('-')).export_json
12
- else
13
- LucaSalary::Monthly.new.export_json
8
+ module LucaCmd
9
+ class Profile
10
+ def self.create(args = nil, _params = nil)
11
+ LucaSalary::Profile.gen_profile!(args.first)
12
+ end
14
13
  end
15
- end
16
14
 
17
- def payment(args = nil, _params = nil)
18
- if args
19
- args << 28 if args.length == 2 # specify safe last day
20
- LucaSalary::Base.new(args.join('-')).calc
21
- else
22
- LucaSalary::Base.new.calc
23
- end
24
- end
15
+ class Payment
16
+ def self.create(args = nil, _params = nil)
17
+ if args
18
+ args << 28 if args.length == 2 # specify safe last day
19
+ LucaSalary::Base.new(args.join('-')).calc
20
+ else
21
+ LucaSalary::Base.new.calc
22
+ end
23
+ end
25
24
 
26
- def report(args = nil, params = nil)
27
- if args
28
- args << 28 if args.length == 2 # specify safe last day
29
- LucaSalary::Monthly.new(args.join('-')).report(params.dig('mode'))
30
- else
31
- LucaSalary::Monthly.new.report(params.dig('mode'))
32
- end
33
- end
25
+ def self.export(args = nil, _params = nil)
26
+ if args
27
+ args << 28 if args.length == 2 # specify safe last day
28
+ LucaSalary::Payment.new(args.join('-')).export_json
29
+ else
30
+ LucaSalary::Payment.new.export_json
31
+ end
32
+ end
34
33
 
35
- def add_person(args = nil, _params = nil)
36
- LucaSalary::Profile.gen_profile!(args.first)
34
+ def self.list(args = nil, params = nil)
35
+ if args
36
+ args << 28 if args.length == 2 # specify safe last day
37
+ LucaSalary::Monthly.new(args.join('-')).report(params.dig('mode'))
38
+ else
39
+ LucaSalary::Monthly.new.report(params.dig('mode'))
40
+ end
41
+ end
42
+ end
37
43
  end
38
44
 
39
45
  LucaRecord::Base.valid_project?
40
46
  cmd = ARGV.shift
47
+ params = {}
41
48
 
42
49
  case cmd
43
- when 'add'
44
- add_person(ARGV)
45
- when 'export'
46
- export(ARGV)
47
- when 'report'
48
- params = {}
49
- OptionParser.new do |opt|
50
- opt.banner = 'Usage: luca-salary report [--mail] year month [date]'
51
- opt.on('--mail', 'send to managers') { |_v| params['mode'] = 'mail' }
52
- args = opt.parse(ARGV)
53
- report(args, params)
50
+ when /profiles?/
51
+ subcmd = ARGV.shift
52
+ case subcmd
53
+ when 'create'
54
+ OptionParser.new do |opt|
55
+ opt.banner = 'Usage: luca-salary profiles create Name'
56
+ args = opt.parse(ARGV)
57
+ LucaCmd::Profile.create(args)
58
+ end
54
59
  end
55
- when 'payment'
56
- params = {}
57
- OptionParser.new do |opt|
58
- opt.banner = 'Usage: luca-salary payment [--mail] year month [date]'
59
- opt.on('--mail', 'send to managers') { |_v| params['mode'] = 'mail' }
60
- args = opt.parse(ARGV)
61
- payment(args)
60
+ when 'export'
61
+ LucaCmd::Payment.export(ARGV)
62
+ when /payments?/
63
+ subcmd = ARGV.shift
64
+ case subcmd
65
+ when 'create'
66
+ OptionParser.new do |opt|
67
+ opt.banner = 'Usage: luca-salary payments create year month [date]'
68
+ args = opt.parse(ARGV)
69
+ LucaCmd::Payment.create(args)
70
+ end
71
+ when 'list'
72
+ OptionParser.new do |opt|
73
+ opt.banner = 'Usage: luca-salary payments list [--mail] year month [date]'
74
+ opt.on('--mail', 'send to managers') { |_v| params['mode'] = 'mail' }
75
+ args = opt.parse(ARGV)
76
+ LucaCmd::Payment.list(args, params)
77
+ end
62
78
  end
63
79
  else
64
80
  puts 'Invalid subcommand'
@@ -20,15 +20,16 @@ module LucaSalary
20
20
  # output payslips via mail or console
21
21
  #
22
22
  def report(mode = nil)
23
+ data = LucaSalary::Payment.new(@date.to_s).payslip
23
24
  if mode == 'mail'
24
25
  mail = Mail.new do
25
26
  subject '[luca salary] Monthly Payment'
26
27
  end
27
28
  mail.to = @config.dig('mail', 'report_mail')
28
- mail.text_part = YAML.dump(LucaSalary::Payment.new(@date.to_s).payslip)
29
+ mail.text_part = YAML.dump(LucaSupport::Code.readable(data))
29
30
  LucaSupport::Mail.new(mail, @pjdir).deliver
30
31
  else
31
- puts YAML.dump(LucaSalary::Payment.new(@date.to_s).payslip)
32
+ puts YAML.dump(LucaSupport::Code.readable(data))
32
33
  end
33
34
  end
34
35
 
@@ -58,11 +58,15 @@ module LucaSalary
58
58
  acct_label = @dict[k][:acct_label]
59
59
  h[pos][acct_label] = h[pos].key?(acct_label) ? h[pos][acct_label] + v : v
60
60
  end
61
- res = {}
62
- res['date'] = "#{@date.year}-#{@date.month}-#{@date.day}"
63
- res['debit'] = h[:debit].map { |k, v| { 'label' => k, 'value' => v } }
64
- res['credit'] = h[:credit].map { |k, v| { 'label' => k, 'value' => v } }
65
- puts JSON.dump(res)
61
+ [].tap do |res|
62
+ item = {}
63
+ item['date'] = "#{@date.year}-#{@date.month}-#{@date.day}"
64
+ item['debit'] = h[:debit].map { |k, v| { 'label' => k, 'value' => v } }
65
+ item['credit'] = h[:credit].map { |k, v| { 'label' => k, 'value' => v } }
66
+ item['x-editor'] = 'LucaSalary'
67
+ res << item
68
+ puts JSON.dump(LucaSupport::Code.readable(res))
69
+ end
66
70
  end
67
71
 
68
72
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LucaSalary
4
- VERSION = '0.1.16'
4
+ VERSION = '0.1.17'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lucasalary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.16
4
+ version: 0.1.17
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-08 00:00:00.000000000 Z
11
+ date: 2020-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lucarecord