lucasalary 0.1.20 → 0.1.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c27c381516005d8ae6962c4d0a44ff0a351f9fd097da547f6dfdcb88d7a6b0d
4
- data.tar.gz: 1b116229596958583c4c06b9fef3675cd53a1c7e70e04ef80fdc3733f6417b36
3
+ metadata.gz: 49f2002c8bc5ec17d605422ee282c0b7cb6053f88aa2fa3dce308e9dbbbdc5c5
4
+ data.tar.gz: e993bd468b91510ad9dc68e55b58c54be562b0dcb76f9a757d4f88b6392d860d
5
5
  SHA512:
6
- metadata.gz: 970e6cacf4d6b781831b53b714c7c4a7ec01de8c58fcc6ae59f396b52875d1024c36008276ed13caefc9a9809bfa363428e7c4884240e7f3f055434fdf76dfb4
7
- data.tar.gz: a1658dfc041cb48eb30f7eca5c762b2f4940f0ffd1dc7d1e03fe16e25075c650d0a0a1f6752ebab387b83f01a047c720aafebf6f6b1b56d1c68b62e35a0feeca
6
+ metadata.gz: 3847524b19036ca598ae119613fd49a9983ce54cdcd37f233b02fead3c636de0f4dfb2c5f80c459c1bc9d8eda82aa8ac22ddc12326fbbcb3cc13e21f9b159804
7
+ data.tar.gz: 15758df4fb112cf71614d11315a6477ebc5506a9176c4c29867dfc7776ea549d7a15ffe38ca1b3edab2c7993c09ae3d89ef82ef0fea01fde89538854ae4a984c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## LucaSalary 0.1.24
2
+
3
+ * Fix: remove null record from `luca-salary export` JSON
4
+
5
+ ## LucaSalary 0.1.23
6
+
7
+ * Breaking change: move sum_code() to Class method
8
+
9
+ ## LucaSalary 0.1.22
10
+
11
+ * Add `luca-salary payments total` command for year total
12
+ * Fix: call localcode with calculation date
13
+
1
14
  ## LucaSalary 0.1.20
2
15
 
3
16
  * 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,10 @@ 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
+ LucaSalary::Payment.year_total(args.first.to_i)
45
+ end
42
46
  end
43
47
  end
44
48
 
@@ -80,6 +84,12 @@ when /payments?/
80
84
  args = opt.parse(ARGV)
81
85
  LucaCmd::Payment.list(args, params)
82
86
  end
87
+ when 'total'
88
+ OptionParser.new do |opt|
89
+ opt.banner = 'Usage: luca-salary payments total year'
90
+ args = opt.parse(ARGV)
91
+ LucaCmd::Payment.total(args)
92
+ end
83
93
  else
84
94
  puts 'Proper subcommand needed.'
85
95
  puts
@@ -37,13 +37,13 @@ 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
48
  target = target.reject { |k, _v| exclude.include?(k) } if exclude
49
49
  target.values.inject(:+) || 0
@@ -59,7 +59,7 @@ module LucaSalary
59
59
  code = CONFIG['country']
60
60
  if code
61
61
  require "luca_salary/#{code.downcase}"
62
- Kernel.const_get "LucaSalary::#{code.capitalise}"
62
+ Kernel.const_get "LucaSalary::#{code.capitalize}"
63
63
  else
64
64
  nil
65
65
  end
@@ -62,18 +62,19 @@ module LucaSalary
62
62
  end
63
63
  end
64
64
  end
65
- payment = local_convert(payment)
66
- create(payment, date: Date.new(year, 12, 31), codes: [id], basedir: 'payments/total')
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
 
@@ -99,8 +100,8 @@ module LucaSalary
99
100
  [].tap do |res|
100
101
  {}.tap do |item|
101
102
  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 } }
103
+ item['debit'] = h[:debit].reject { |_k, v| v.nil? }.map { |k, v| { 'label' => k, 'amount' => v } }
104
+ item['credit'] = h[:credit].reject { |_k, v| v.nil? }.map { |k, v| { 'label' => k, 'amount' => v } }
104
105
  item['x-editor'] = 'LucaSalary'
105
106
  res << item
106
107
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LucaSalary
4
- VERSION = '0.1.20'
4
+ VERSION = '0.1.24'
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.20
4
+ version: 0.1.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chuma Takahiro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-12 00:00:00.000000000 Z
11
+ date: 2022-05-19 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:
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  requirements: []
111
- rubygems_version: 3.2.3
111
+ rubygems_version: 3.3.5
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: Salary calculation framework