lucasalary 0.1.24 → 0.1.25

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: 49f2002c8bc5ec17d605422ee282c0b7cb6053f88aa2fa3dce308e9dbbbdc5c5
4
- data.tar.gz: e993bd468b91510ad9dc68e55b58c54be562b0dcb76f9a757d4f88b6392d860d
3
+ metadata.gz: 3de293feb769006a2764979fdc52357699cc79c116fcde6b6c871b473e650035
4
+ data.tar.gz: 63f14cd43cc3a7aec7c31c6a59bafa67c03b998c8a23b882becb5d76e308fbbe
5
5
  SHA512:
6
- metadata.gz: 3847524b19036ca598ae119613fd49a9983ce54cdcd37f233b02fead3c636de0f4dfb2c5f80c459c1bc9d8eda82aa8ac22ddc12326fbbcb3cc13e21f9b159804
7
- data.tar.gz: 15758df4fb112cf71614d11315a6477ebc5506a9176c4c29867dfc7776ea549d7a15ffe38ca1b3edab2c7993c09ae3d89ef82ef0fea01fde89538854ae4a984c
6
+ metadata.gz: 99ed7707f597948379ec7059926c67bd101f5fb182c33c3cf347574ed9dc44daa9af1519768c89f88723c579b5339d7fb57d78bb05976f8e46ba4eb2d6db0e1f
7
+ data.tar.gz: 88ac6c04ab1956d26f976e31e5fbb9474d49163fbabbe3bd9259defd472190898280d8f3b76a6ddd32ca8420ba41d289d2c379abd2f7ddc1c5f1072326f9a982
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## LucaSalary 0.1.25
2
+
3
+ * Add `luca-salary payments total --adjust`: applying yearly tax refund.
4
+
1
5
  ## LucaSalary 0.1.24
2
6
 
3
7
  * Fix: remove null record from `luca-salary export` JSON
data/exe/luca-salary CHANGED
@@ -40,8 +40,12 @@ module LucaCmd
40
40
  end
41
41
  end
42
42
 
43
- def self.total(args = nil, _params = nil)
44
- LucaSalary::Payment.year_total(args.first.to_i)
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
45
49
  end
46
50
  end
47
51
  end
@@ -86,9 +90,10 @@ when /payments?/
86
90
  end
87
91
  when 'total'
88
92
  OptionParser.new do |opt|
89
- opt.banner = 'Usage: luca-salary payments total year'
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' }
90
95
  args = opt.parse(ARGV)
91
- LucaCmd::Payment.total(args)
96
+ LucaCmd::Payment.total(args, params)
92
97
  end
93
98
  else
94
99
  puts 'Proper subcommand needed.'
@@ -45,7 +45,9 @@ module LucaSalary
45
45
 
46
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.reject { |k, _v| exclude.include?(k) } if exclude
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
 
@@ -78,6 +78,30 @@ module LucaSalary
78
78
  return payment
79
79
  end
80
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
+
81
105
  # Export json for LucaBook.
82
106
  # Accrual_date can be change with `payment_term` on config.yml. Default value is 0.
83
107
  # `payment_term: 1` means payment on the next month of calculation target.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LucaSalary
4
- VERSION = '0.1.24'
4
+ VERSION = '0.1.25'
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.24
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: 2022-05-19 00:00:00.000000000 Z
11
+ date: 2023-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lucarecord
@@ -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
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  version: '0'
110
110
  requirements: []
111
111
  rubygems_version: 3.3.5
112
- signing_key:
112
+ signing_key:
113
113
  specification_version: 4
114
114
  summary: Salary calculation framework
115
115
  test_files: []