lucasalary 0.1.20 → 0.1.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +2 -0
- data/exe/luca-salary +15 -0
- data/lib/luca_salary/base.rb +6 -4
- data/lib/luca_salary/payment.rb +32 -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: 3de293feb769006a2764979fdc52357699cc79c116fcde6b6c871b473e650035
|
4
|
+
data.tar.gz: 63f14cd43cc3a7aec7c31c6a59bafa67c03b998c8a23b882becb5d76e308fbbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99ed7707f597948379ec7059926c67bd101f5fb182c33c3cf347574ed9dc44daa9af1519768c89f88723c579b5339d7fb57d78bb05976f8e46ba4eb2d6db0e1f
|
7
|
+
data.tar.gz: 88ac6c04ab1956d26f976e31e5fbb9474d49163fbabbe3bd9259defd472190898280d8f3b76a6ddd32ca8420ba41d289d2c379abd2f7ddc1c5f1072326f9a982
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
## LucaSalary 0.1.25
|
2
|
+
|
3
|
+
* Add `luca-salary payments total --adjust`: applying yearly tax refund.
|
4
|
+
|
5
|
+
## LucaSalary 0.1.24
|
6
|
+
|
7
|
+
* Fix: remove null record from `luca-salary export` JSON
|
8
|
+
|
9
|
+
## LucaSalary 0.1.23
|
10
|
+
|
11
|
+
* Breaking change: move sum_code() to Class method
|
12
|
+
|
13
|
+
## LucaSalary 0.1.22
|
14
|
+
|
15
|
+
* Add `luca-salary payments total` command for year total
|
16
|
+
* Fix: call localcode with calculation date
|
17
|
+
|
1
18
|
## LucaSalary 0.1.20
|
2
19
|
|
3
20
|
* Implement `year_total`
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Luca Salary
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/lucasalary.svg)](https://badge.fury.io/rb/lucasalary)
|
4
|
+
[![doc](https://img.shields.io/badge/doc-rubydoc-green.svg)](https://www.rubydoc.info/gems/lucasalary/index)
|
5
|
+
![license](https://img.shields.io/github/license/chumaltd/luca)
|
4
6
|
|
5
7
|
LucaSalary is Abstraction framework coworking with each country module. As income tax differs in each county, most of implementation need to be developed separately.
|
6
8
|
At this time, [Japan module](https://github.com/chumaltd/luca-salary-jp) is under development as a practical reference.
|
data/exe/luca-salary
CHANGED
@@ -39,6 +39,14 @@ module LucaCmd
|
|
39
39
|
LucaSalary::Monthly.new.report(params.dig('mode'))
|
40
40
|
end
|
41
41
|
end
|
42
|
+
|
43
|
+
def self.total(args = nil, params = nil)
|
44
|
+
if params['mode'] == 'adjust'
|
45
|
+
LucaSalary::Payment.year_adjust(args[0].to_i, args[1].to_i)
|
46
|
+
else
|
47
|
+
LucaSalary::Payment.year_total(args.first.to_i)
|
48
|
+
end
|
49
|
+
end
|
42
50
|
end
|
43
51
|
end
|
44
52
|
|
@@ -80,6 +88,13 @@ when /payments?/
|
|
80
88
|
args = opt.parse(ARGV)
|
81
89
|
LucaCmd::Payment.list(args, params)
|
82
90
|
end
|
91
|
+
when 'total'
|
92
|
+
OptionParser.new do |opt|
|
93
|
+
opt.banner = 'Usage: luca-salary payments total [--adjust] year [month]'
|
94
|
+
opt.on('--adjust', 'Apply year total adjustment to payslip of year/month') { |_v| params['mode'] = 'adjust' }
|
95
|
+
args = opt.parse(ARGV)
|
96
|
+
LucaCmd::Payment.total(args, params)
|
97
|
+
end
|
83
98
|
else
|
84
99
|
puts 'Proper subcommand needed.'
|
85
100
|
puts
|
data/lib/luca_salary/base.rb
CHANGED
@@ -37,15 +37,17 @@ module LucaSalary
|
|
37
37
|
{}.tap do |h|
|
38
38
|
(1..4).each do |n|
|
39
39
|
code = n.to_s
|
40
|
-
h[code] = sum_code(obj, code)
|
40
|
+
h[code] = self.class.sum_code(obj, code)
|
41
41
|
end
|
42
42
|
h['5'] = h['1'] - h['2'] - h['3'] + h['4']
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
def sum_code(obj, code, exclude = nil)
|
46
|
+
def self.sum_code(obj, code, exclude = nil)
|
47
47
|
target = obj.select { |k, _v| /^#{code}[0-9A-Fa-f]{,3}$/.match(k) }
|
48
|
-
target = target
|
48
|
+
target = target
|
49
|
+
.reject { |_k, v| v.nil? }
|
50
|
+
.reject { |k, _v| exclude&.include?(k) }
|
49
51
|
target.values.inject(:+) || 0
|
50
52
|
end
|
51
53
|
|
@@ -59,7 +61,7 @@ module LucaSalary
|
|
59
61
|
code = CONFIG['country']
|
60
62
|
if code
|
61
63
|
require "luca_salary/#{code.downcase}"
|
62
|
-
Kernel.const_get "LucaSalary::#{code.
|
64
|
+
Kernel.const_get "LucaSalary::#{code.capitalize}"
|
63
65
|
else
|
64
66
|
nil
|
65
67
|
end
|
data/lib/luca_salary/payment.rb
CHANGED
@@ -62,21 +62,46 @@ module LucaSalary
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
65
|
-
|
66
|
-
|
65
|
+
date = Date.new(year, 12, 31)
|
66
|
+
payment = local_convert(payment, date)
|
67
|
+
create(payment, date: date, codes: [id], basedir: 'payments/total')
|
67
68
|
end
|
68
69
|
end
|
69
70
|
|
70
|
-
def self.local_convert(payment)
|
71
|
+
def self.local_convert(payment, date)
|
71
72
|
return payment if CONFIG['country'].nil?
|
72
73
|
|
73
74
|
require "luca_salary/#{CONFIG['country'].downcase}"
|
74
75
|
klass = Kernel.const_get("LucaSalary::#{CONFIG['country'].capitalize}")
|
75
|
-
klass.year_total(payment)
|
76
|
-
rescue
|
76
|
+
klass.year_total(payment, date)
|
77
|
+
rescue NameError
|
77
78
|
return payment
|
78
79
|
end
|
79
80
|
|
81
|
+
# Apply adjustment for yearly refund.
|
82
|
+
# Search Year Total records 6 months before specified payslip month.
|
83
|
+
#
|
84
|
+
def self.year_adjust(year, month)
|
85
|
+
target_month = Date.new(year, month, 1)
|
86
|
+
total_st = target_month.prev_month(6)
|
87
|
+
search(year, month).each do |slip, path|
|
88
|
+
term(total_st.year, total_st.month, year, month, slip['profile_id'], "#{@dirname}/total/") do |total|
|
89
|
+
slip['3A1'] = total['3A1']
|
90
|
+
slip['4A1'] = total['4A1']
|
91
|
+
end
|
92
|
+
# Recalculate sum
|
93
|
+
['3', '4'].each do |key|
|
94
|
+
slip[key] = 0
|
95
|
+
slip[key] = LucaSalary::Base.sum_code(slip, key)
|
96
|
+
slip['5'] = slip['1'] - slip['2'] - slip['3'] + slip['4']
|
97
|
+
end
|
98
|
+
IO.write(
|
99
|
+
abs_path(@dirname) / path[0] / "#{path[1]}-#{path[2]}",
|
100
|
+
YAML.dump(LucaSupport::Code.readable(slip.sort.to_h))
|
101
|
+
)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
80
105
|
# Export json for LucaBook.
|
81
106
|
# Accrual_date can be change with `payment_term` on config.yml. Default value is 0.
|
82
107
|
# `payment_term: 1` means payment on the next month of calculation target.
|
@@ -99,8 +124,8 @@ module LucaSalary
|
|
99
124
|
[].tap do |res|
|
100
125
|
{}.tap do |item|
|
101
126
|
item['date'] = "#{accrual_date.year}-#{accrual_date.month}-#{accrual_date.day}"
|
102
|
-
item['debit'] = h[:debit].map { |k, v| { 'label' => k, 'amount' => v } }
|
103
|
-
item['credit'] = h[:credit].map { |k, v| { 'label' => k, 'amount' => v } }
|
127
|
+
item['debit'] = h[:debit].reject { |_k, v| v.nil? }.map { |k, v| { 'label' => k, 'amount' => v } }
|
128
|
+
item['credit'] = h[:credit].reject { |_k, v| v.nil? }.map { |k, v| { 'label' => k, 'amount' => v } }
|
104
129
|
item['x-editor'] = 'LucaSalary'
|
105
130
|
res << item
|
106
131
|
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.1.
|
4
|
+
version: 0.1.25
|
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: 2023-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lucarecord
|
@@ -68,7 +68,7 @@ dependencies:
|
|
68
68
|
version: 12.3.3
|
69
69
|
description: 'Salary calculation framework
|
70
70
|
|
71
|
-
'
|
71
|
+
'
|
72
72
|
email:
|
73
73
|
- co.chuma@gmail.com
|
74
74
|
executables:
|
@@ -93,7 +93,7 @@ metadata:
|
|
93
93
|
homepage_uri: https://github.com/chumaltd/luca/tree/master/lucasalary
|
94
94
|
source_code_uri: https://github.com/chumaltd/luca/tree/master/lucasalary
|
95
95
|
changelog_uri: https://github.com/chumaltd/luca/tree/master/lucasalary/CHANGELOG.md
|
96
|
-
post_install_message:
|
96
|
+
post_install_message:
|
97
97
|
rdoc_options: []
|
98
98
|
require_paths:
|
99
99
|
- lib
|
@@ -108,8 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
|
-
rubygems_version: 3.
|
112
|
-
signing_key:
|
111
|
+
rubygems_version: 3.3.5
|
112
|
+
signing_key:
|
113
113
|
specification_version: 4
|
114
114
|
summary: Salary calculation framework
|
115
115
|
test_files: []
|