lucasalary 0.5.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/exe/luca-salary +30 -19
- data/lib/luca_salary/base.rb +2 -2
- data/lib/luca_salary/monthly.rb +3 -3
- data/lib/luca_salary/payment.rb +3 -3
- data/lib/luca_salary/state.rb +1 -1
- data/lib/luca_salary/total.rb +7 -7
- data/lib/luca_salary/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c67611f8fd2fd2ae358b490cb0edf52bb7f3e2e67be665fa980d13d4867b84cc
|
4
|
+
data.tar.gz: 4f9549a73cda4e61e22e4fc32bf45e8449eac786570b8f476046399d3a151aed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb07bfd39efd6c6fd9c5d2bb309914f1a383f57b370ed28eded86ba1d008db0a1f8938c3a06a795a067e0d6d3298824c294b1bb0a19c12d7f55d2f21e15bac3f
|
7
|
+
data.tar.gz: 5c9cb0834e0e258743f854e233705275910e495490e007fc9cc1c1bcf57ff49b8cd8b95a293a51a61c6ddda50f5a1c10603640b9a920cb86bde133ddd14f8229
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
## LucaSalary 0.6.1
|
2
|
+
|
3
|
+
* Reworked global constants w/LucaRecord v0.7
|
4
|
+
* Removed bundler from test suite avoiding casual native build
|
5
|
+
* add `luca-salary version` subcommand
|
6
|
+
|
7
|
+
## LucaSalary 0.6.0
|
8
|
+
|
9
|
+
* BREAKING: monthly payment now passes calculation date to local modules.
|
10
|
+
* BREAKING: year total calculation now passes profiles to local modules.
|
11
|
+
|
1
12
|
## LucaSalary 0.5.0
|
2
13
|
|
3
14
|
* `luca-salary` command now searches valid sub directory.
|
data/exe/luca-salary
CHANGED
@@ -1,23 +1,16 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
target = 'profiles'
|
6
|
-
Dir.glob('*').reject { |f| File.symlink?(f) }
|
7
|
-
.find { |f| File.directory?("#{f}/data/#{target}") }.tap do |d|
|
8
|
-
abort "No valid data directory, exit..." if d.nil?
|
9
|
-
|
10
|
-
Dir.chdir(d)
|
11
|
-
end
|
12
|
-
end
|
4
|
+
REQUIRED_DIR='profiles'
|
13
5
|
|
14
6
|
require 'json'
|
15
7
|
require 'optparse'
|
16
8
|
require 'luca_salary'
|
17
9
|
require 'luca_salary/monthly'
|
18
10
|
require 'luca_support' #TODO: test use only
|
11
|
+
require 'luca_cmd'
|
19
12
|
|
20
|
-
|
13
|
+
class LucaCmd
|
21
14
|
class Profile
|
22
15
|
def self.create(args = nil, _params = nil)
|
23
16
|
LucaSalary::Profile.gen_profile!(args.first)
|
@@ -79,7 +72,6 @@ module LucaCmd
|
|
79
72
|
end
|
80
73
|
end
|
81
74
|
|
82
|
-
LucaRecord::Base.valid_project?
|
83
75
|
cmd = ARGV.shift
|
84
76
|
params = {}
|
85
77
|
|
@@ -91,7 +83,9 @@ when /profiles?/
|
|
91
83
|
OptionParser.new do |opt|
|
92
84
|
opt.banner = 'Usage: luca-salary profiles create Name'
|
93
85
|
args = opt.parse(ARGV)
|
94
|
-
LucaCmd
|
86
|
+
LucaCmd.check_dir(REQUIRED_DIR) do
|
87
|
+
LucaCmd::Profile.create(args)
|
88
|
+
end
|
95
89
|
end
|
96
90
|
else
|
97
91
|
puts 'Proper subcommand needed.'
|
@@ -105,16 +99,22 @@ when 'enc', 'encrypt'
|
|
105
99
|
opt.banner = 'Usage: luca-salary enc|encrypt'
|
106
100
|
opt.on('--clean', 'remove plain directory') { |_v| params[:clean] = true }
|
107
101
|
args = opt.parse(ARGV)
|
108
|
-
|
102
|
+
LucaCmd.check_dir(REQUIRED_DIR) do
|
103
|
+
LucaSupport::Enc.encrypt("s_profiles", cleanup: params[:clean])
|
104
|
+
end
|
109
105
|
end
|
110
106
|
when 'dec', 'decrypt'
|
111
107
|
OptionParser.new do |opt|
|
112
108
|
opt.banner = 'Usage: luca-salary dec|decrypt'
|
113
109
|
args = opt.parse(ARGV)
|
114
|
-
|
110
|
+
LucaCmd.check_dir(REQUIRED_DIR) do
|
111
|
+
LucaSupport::Enc.decrypt("s_profiles")
|
112
|
+
end
|
115
113
|
end
|
116
114
|
when 'export'
|
117
|
-
LucaCmd
|
115
|
+
LucaCmd.check_dir(REQUIRED_DIR) do
|
116
|
+
LucaCmd::Payment.export(ARGV)
|
117
|
+
end
|
118
118
|
when 'pay', /payments?/
|
119
119
|
subcmd = ARGV.shift
|
120
120
|
case subcmd
|
@@ -122,7 +122,9 @@ when 'pay', /payments?/
|
|
122
122
|
OptionParser.new do |opt|
|
123
123
|
opt.banner = 'Usage: luca-salary payments create year month [date]'
|
124
124
|
args = opt.parse(ARGV)
|
125
|
-
LucaCmd
|
125
|
+
LucaCmd.check_dir(REQUIRED_DIR) do
|
126
|
+
LucaCmd::Payment.create(args)
|
127
|
+
end
|
126
128
|
end
|
127
129
|
when 'list'
|
128
130
|
OptionParser.new do |opt|
|
@@ -131,21 +133,27 @@ when 'pay', /payments?/
|
|
131
133
|
opt.on('--nu', 'show table in nushell') { |_v| params[:output] = 'nu' }
|
132
134
|
opt.on('--explore', 'explore table in nushell') { |_v| params[:output] = 'explore' }
|
133
135
|
args = opt.parse(ARGV)
|
134
|
-
LucaCmd
|
136
|
+
LucaCmd.check_dir(REQUIRED_DIR) do
|
137
|
+
LucaCmd::Payment.list(args, params)
|
138
|
+
end
|
135
139
|
end
|
136
140
|
when 'report'
|
137
141
|
OptionParser.new do |opt|
|
138
142
|
opt.banner = 'Usage: luca-salary payments report [--nu] year month [year month]'
|
139
143
|
opt.on('--nu', 'show table in nushell') { |_v| params[:output] = 'nu' }
|
140
144
|
args = opt.parse(ARGV)
|
141
|
-
LucaCmd
|
145
|
+
LucaCmd.check_dir(REQUIRED_DIR) do
|
146
|
+
LucaCmd::Payment.report(args, params)
|
147
|
+
end
|
142
148
|
end
|
143
149
|
when 'total'
|
144
150
|
OptionParser.new do |opt|
|
145
151
|
opt.banner = 'Usage: luca-salary payments total [--adjust] year [month]'
|
146
152
|
opt.on('--adjust', 'Apply year total adjustment to payslip of year/month') { |_v| params['mode'] = 'adjust' }
|
147
153
|
args = opt.parse(ARGV)
|
148
|
-
LucaCmd
|
154
|
+
LucaCmd.check_dir(REQUIRED_DIR) do
|
155
|
+
LucaCmd::Payment.total(args, params)
|
156
|
+
end
|
149
157
|
end
|
150
158
|
else
|
151
159
|
puts 'Proper subcommand needed.'
|
@@ -153,6 +161,9 @@ when 'pay', /payments?/
|
|
153
161
|
puts 'Usage: luca-salary payment[s] (create|list) [--help|options]'
|
154
162
|
exit 1
|
155
163
|
end
|
164
|
+
when 'version'
|
165
|
+
puts "luca-salary: version #{LucaSalary::VERSION}"
|
166
|
+
exit 0
|
156
167
|
else
|
157
168
|
puts 'Proper subcommand needed.'
|
158
169
|
puts
|
data/lib/luca_salary/base.rb
CHANGED
@@ -54,11 +54,11 @@ module LucaSalary
|
|
54
54
|
private
|
55
55
|
|
56
56
|
def load_dict
|
57
|
-
LucaRecord::Dict.load_tsv_dict(Pathname(
|
57
|
+
LucaRecord::Dict.load_tsv_dict(Pathname(LucaRecord::CONST.pjdir) / 'dict' / 'code.tsv')
|
58
58
|
end
|
59
59
|
|
60
60
|
def set_driver
|
61
|
-
code =
|
61
|
+
code = LucaRecord::CONST.config['country']
|
62
62
|
if code
|
63
63
|
require "luca_salary/#{code.downcase}"
|
64
64
|
Kernel.const_get "LucaSalary::#{code.capitalize}"
|
data/lib/luca_salary/monthly.rb
CHANGED
@@ -14,7 +14,7 @@ module LucaSalary
|
|
14
14
|
|
15
15
|
def initialize(date = nil)
|
16
16
|
@date = date.nil? ? Date.today : Date.parse(date)
|
17
|
-
@pjdir = Pathname(
|
17
|
+
@pjdir = Pathname(LucaRecord::CONST.pjdir)
|
18
18
|
@config = load_config(@pjdir + 'config.yml')
|
19
19
|
@driver = set_driver
|
20
20
|
end
|
@@ -25,12 +25,12 @@ module LucaSalary
|
|
25
25
|
country = @driver.new(@pjdir, @config, @date)
|
26
26
|
# TODO: handle retirement
|
27
27
|
LucaSalary::Profile.all do |profile|
|
28
|
-
current_profile = parse_current(profile)
|
28
|
+
current_profile = parse_current(Profile.find_secure(profile['id']))
|
29
29
|
if self.class.search(@date.year, @date.month, @date.day, current_profile['id']).count > 0
|
30
30
|
puts "payment record already exists: #{current_profile['id']}"
|
31
31
|
return nil
|
32
32
|
end
|
33
|
-
h = country.calc_payment(current_profile)
|
33
|
+
h = country.calc_payment(current_profile, @date)
|
34
34
|
h['profile_id'] = current_profile['id']
|
35
35
|
self.class.create(h, date: @date, codes: Array(current_profile['id']))
|
36
36
|
end
|
data/lib/luca_salary/payment.rb
CHANGED
@@ -15,7 +15,7 @@ module LucaSalary
|
|
15
15
|
|
16
16
|
def initialize(date = nil)
|
17
17
|
@date = Date.parse(date)
|
18
|
-
@pjdir = Pathname(
|
18
|
+
@pjdir = Pathname(LucaRecord::CONST.pjdir)
|
19
19
|
@dict = LucaRecord::Dict.load_tsv_dict(@pjdir / 'dict' / 'code.tsv')
|
20
20
|
end
|
21
21
|
|
@@ -51,8 +51,8 @@ module LucaSalary
|
|
51
51
|
# `payment_term: 1` means payment on the next month of calculation target.
|
52
52
|
#
|
53
53
|
def export_json
|
54
|
-
accrual_date = if
|
55
|
-
pt =
|
54
|
+
accrual_date = if LucaRecord::CONST.config['payment_term']
|
55
|
+
pt = LucaRecord::CONST.config['payment_term']
|
56
56
|
Date.new(@date.prev_month(pt).year, @date.prev_month(pt).month, -1)
|
57
57
|
else
|
58
58
|
Date.new(@date.year, @date.month, -1)
|
data/lib/luca_salary/state.rb
CHANGED
@@ -14,7 +14,7 @@ module LucaSalary
|
|
14
14
|
@count = count
|
15
15
|
@start_date = start_d
|
16
16
|
@end_date = end_d
|
17
|
-
@dict = LucaRecord::Dict.load_tsv_dict(Pathname(
|
17
|
+
@dict = LucaRecord::Dict.load_tsv_dict(Pathname(LucaRecord::CONST.pjdir) / 'dict' / 'code.tsv')
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.range(from_year, from_month, to_year = from_year, to_month = from_month)
|
data/lib/luca_salary/total.rb
CHANGED
@@ -19,7 +19,7 @@ module LucaSalary
|
|
19
19
|
slip['profile'] = parse_current(Profile.find_secure(slip['id']))
|
20
20
|
slip
|
21
21
|
end
|
22
|
-
@dict = LucaRecord::Dict.load_tsv_dict(Pathname(
|
22
|
+
@dict = LucaRecord::Dict.load_tsv_dict(Pathname(LucaRecord::CONST.pjdir) / 'dict' / 'code.tsv')
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.accumulator(year)
|
@@ -29,17 +29,17 @@ module LucaSalary
|
|
29
29
|
payment, _count = accumulate(slips)
|
30
30
|
payment['id'] = id
|
31
31
|
date = Date.new(year, 12, 31)
|
32
|
-
payment = local_convert(payment, date)
|
32
|
+
payment = local_convert(Profile.find_secure(id), payment, date)
|
33
33
|
upsert(payment, basedir: "payments/total/#{year}#{LucaSupport::Code.encode_month(12)}")
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
def self.local_convert(payment, date)
|
38
|
-
return payment if
|
37
|
+
def self.local_convert(profile, payment, date)
|
38
|
+
return payment if LucaRecord::CONST.config['country'].nil?
|
39
39
|
|
40
|
-
require "luca_salary/#{
|
41
|
-
klass = Kernel.const_get("LucaSalary::#{
|
42
|
-
klass.year_total(payment, date)
|
40
|
+
require "luca_salary/#{LucaRecord::CONST.config['country'].downcase}"
|
41
|
+
klass = Kernel.const_get("LucaSalary::#{LucaRecord::CONST.config['country'].capitalize}")
|
42
|
+
klass.year_total(profile, payment, date)
|
43
43
|
rescue NameError
|
44
44
|
return payment
|
45
45
|
end
|
data/lib/luca_salary/version.rb
CHANGED
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.
|
4
|
+
version: 0.6.1
|
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:
|
11
|
+
date: 2024-01-10 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.7.0
|
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.7.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -96,7 +96,7 @@ metadata:
|
|
96
96
|
homepage_uri: https://github.com/chumaltd/luca/tree/master/lucasalary
|
97
97
|
source_code_uri: https://github.com/chumaltd/luca/tree/master/lucasalary
|
98
98
|
changelog_uri: https://github.com/chumaltd/luca/tree/master/lucasalary/CHANGELOG.md
|
99
|
-
post_install_message:
|
99
|
+
post_install_message:
|
100
100
|
rdoc_options: []
|
101
101
|
require_paths:
|
102
102
|
- lib
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
114
|
rubygems_version: 3.4.10
|
115
|
-
signing_key:
|
115
|
+
signing_key:
|
116
116
|
specification_version: 4
|
117
117
|
summary: Salary calculation framework
|
118
118
|
test_files: []
|