lucasalary 0.1.17 → 0.1.18

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: e1eaada7633a6968784a6421f92f6393aebb762d67725f7df7237a429e4dd0f5
4
- data.tar.gz: 7168896dd1c49cd1a4f44e35ab5dc232426c304964fb878bff67d899db9f8753
3
+ metadata.gz: 37e8c1758e8ea780f6f124747241c5c43b4047f96e6a72ebe28d3ae546034843
4
+ data.tar.gz: b9d761bbedb5f77d222ac7e2d16cd5258ee60d52d7e2cc75ac941f1faae2b5f2
5
5
  SHA512:
6
- metadata.gz: b959970ee8cec2debca73f672c2f16d6365d3bd29b5c53fc4814369ecf08e9312f137c824371c799e3a2bf4cda2f27f3b200a3d7a46e5c66a599a78702fb3175
7
- data.tar.gz: fa89846e020e818a8e9367312292a9256757ebed278bc1d7afbbe785a525d28929a7f04d4801490164e749dcbdee65da051108546cbae7a364fc32bd8cfc392c
6
+ metadata.gz: de2e967a7585233f87b4f3eeac7729b9d183563fc71610f355ca4329e2ff521d23473514d62e514da8e3735fe7bde4d8bc7f5dd58afd3e3bad2add31bb98630d
7
+ data.tar.gz: b7fa56bbc2a8e15e20b6db16a7e1e4c4f6f555f0f19da175fe41e67785af84a809e7f3ee16ba1c7d5394e86038e18f0ac756f68ea26140169a1b9bb9bb8eb9dc
@@ -1,3 +1,7 @@
1
+ ## LucaSalary 0.1.18
2
+
3
+ * Add summary to payslip. Refactor monthly payment.
4
+
1
5
  ## LucaSalary 0.1.17
2
6
 
3
7
  * Breaking change: restructure CLI in sub-sub command format.
@@ -16,9 +16,9 @@ module LucaCmd
16
16
  def self.create(args = nil, _params = nil)
17
17
  if args
18
18
  args << 28 if args.length == 2 # specify safe last day
19
- LucaSalary::Base.new(args.join('-')).calc
19
+ LucaSalary::Monthly.new(args.join('-')).calc
20
20
  else
21
- LucaSalary::Base.new.calc
21
+ LucaSalary::Monthly.new.calc
22
22
  end
23
23
  end
24
24
 
@@ -56,6 +56,11 @@ when /profiles?/
56
56
  args = opt.parse(ARGV)
57
57
  LucaCmd::Profile.create(args)
58
58
  end
59
+ else
60
+ puts 'Proper subcommand needed.'
61
+ puts
62
+ puts 'Usage: luca-salary profile[s] create Name'
63
+ exit 1
59
64
  end
60
65
  when 'export'
61
66
  LucaCmd::Payment.export(ARGV)
@@ -75,7 +80,18 @@ when /payments?/
75
80
  args = opt.parse(ARGV)
76
81
  LucaCmd::Payment.list(args, params)
77
82
  end
83
+ else
84
+ puts 'Proper subcommand needed.'
85
+ puts
86
+ puts 'Usage: luca-salary payment[s] (create|list) [--help|options]'
87
+ exit 1
78
88
  end
79
89
  else
80
- puts 'Invalid subcommand'
90
+ puts 'Proper subcommand needed.'
91
+ puts
92
+ puts 'Usage: luca-salary subcommand [options]'
93
+ puts ' profiles'
94
+ puts ' payments'
95
+ puts ' export: puts payment data for LucaBook import'
96
+ exit 1
81
97
  end
@@ -9,30 +9,16 @@ require 'luca_record'
9
9
 
10
10
  module LucaSalary
11
11
  class Base < LucaRecord::Base
12
- attr_reader :driver, :dict, :config, :pjdir
12
+ attr_reader :dict, :config, :pjdir
13
13
  @dirname = 'payments'
14
14
 
15
15
  def initialize(date = nil)
16
16
  @date = date.nil? ? Date.today : Date.parse(date)
17
17
  @pjdir = Pathname(LucaSupport::Config::Pjdir)
18
18
  @config = load_config(@pjdir / 'config.yml')
19
- @driver = set_driver
20
19
  @dict = load_dict
21
20
  end
22
21
 
23
- #
24
- # call country specific calculation
25
- #
26
- def calc
27
- self.class.prepare_dir!(datadir / 'payments', @date)
28
- country = @driver.new(@pjdir, @config, @date)
29
- LucaSalary::Profile.all do |profile|
30
- current_profile = parse_current(profile)
31
- h = country.calc_payment(current_profile)
32
- LucaSalary::Payment.new(@date.to_s).create(current_profile, h)
33
- end
34
- end
35
-
36
22
  def gen_aggregation!
37
23
  LucaSalary::Profile.all do |profile|
38
24
  id = profile.dig('id')
@@ -60,7 +46,6 @@ module LucaSalary
60
46
  dat.filter { |k, _v| /^#{code}[0-9A-Fa-f]{,3}$/.match(k.to_s) }
61
47
  end
62
48
 
63
- #
64
49
  # Subtotal each items.
65
50
  # 1::
66
51
  # Base salary or wages.
@@ -9,14 +9,33 @@ require 'luca_salary'
9
9
  require 'luca_record'
10
10
 
11
11
  module LucaSalary
12
- class Monthly < LucaRecord::Base
12
+ class Monthly < LucaSalary::Base
13
+ @dirname = 'payments'
14
+
13
15
  def initialize(date = nil)
14
- @date = parse_date(date)
16
+ @date = date.nil? ? Date.today : Date.parse(date)
15
17
  @pjdir = Pathname(LucaSupport::Config::Pjdir)
16
18
  @config = load_config(@pjdir + 'config.yml')
19
+ @driver = set_driver
17
20
  end
18
21
 
22
+ # call country specific calculation
19
23
  #
24
+ def calc
25
+ country = @driver.new(@pjdir, @config, @date)
26
+ # TODO: handle retirement
27
+ LucaSalary::Profile.all do |profile|
28
+ current_profile = parse_current(profile)
29
+ if self.class.search(@date.year, @date.month, @date.day, current_profile['id']).count > 0
30
+ puts "payment record already exists: #{current_profile['id']}"
31
+ return nil
32
+ end
33
+ h = country.calc_payment(current_profile)
34
+ h['profile_id'] = current_profile['id']
35
+ self.class.create(h, date: @date, codes: Array(current_profile['id']))
36
+ end
37
+ end
38
+
20
39
  # output payslips via mail or console
21
40
  #
22
41
  def report(mode = nil)
@@ -17,31 +17,28 @@ module LucaSalary
17
17
  @dict = LucaRecord::Dict.load_tsv_dict(@pjdir / 'dict' / 'code.tsv')
18
18
  end
19
19
 
20
- # create record with LucaSalary::Profile instance and apyment data
21
- #
22
- def create(profile, payment)
23
- id = profile.dig('id')
24
- if self.class.search(@date.year, @date.month, @date.day, id).first
25
- puts "payment record already exists: #{id}"
26
- return nil
27
- end
28
-
29
- self.class.create(payment, date: @date, codes: Array(id))
30
- end
31
-
32
20
  def payslip
33
21
  {}.tap do |report|
34
22
  report['asof'] = "#{@date.year}/#{@date.month}"
23
+ report['payments'] = []
35
24
  report['records'] = []
36
25
 
37
26
  self.class.asof(@date.year, @date.month) do |payment|
27
+ profile = LucaSalary::Profile.find(payment['profile_id'])
28
+ summary = {
29
+ 'name' => profile['name'],
30
+ "#{@dict.dig('5', :label) || '5'}" => payment['5']
31
+ }
32
+
38
33
  slip = {}.tap do |line|
34
+ line['name'] = profile['name']
39
35
  payment.each do |k, v|
40
36
  next if k == 'id'
41
37
 
42
38
  line["#{@dict.dig(k, :label) || k}"] = v
43
39
  end
44
40
  end
41
+ report['payments'] << summary
45
42
  report['records'] << slip
46
43
  end
47
44
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LucaSalary
4
- VERSION = '0.1.17'
4
+ VERSION = '0.1.18'
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.17
4
+ version: 0.1.18
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-10 00:00:00.000000000 Z
11
+ date: 2020-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lucarecord