inss_calculator 0.3.1 → 0.4.0

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: 930151d58edfe02aeb3b597a2b51b569cba243a6560c56a5d345869f498570ab
4
- data.tar.gz: 665e637c5662127e28ddd1785fde22697f315f71954106b03a3d33d52b764ae7
3
+ metadata.gz: a05163c92393153a574007ef8c0f932f0f203d94563ba4757c94b8250ae019b5
4
+ data.tar.gz: cc17641c475339eb14d34b8a66d6f691d5a16afc00773c2da021b742249a5d1c
5
5
  SHA512:
6
- metadata.gz: ca58062897e260e5c1c4e8863d95f16d9cbc9179645119ecdf5bd7b3af1d1b279577cf8b7602a0ad2292b496b095c0431123725f5b904aef639b8bff1ff75c28
7
- data.tar.gz: 4a8f8ef91bbab45fc4dd03b3169a962d98a075dfed9ddc90f2c681ec66f1e43fb6a231712e8b54188d62be2b4c224bac2206df8e9bfeb2d6d29c810699b05014
6
+ metadata.gz: 1dbe2a8d65e5c6c6bc96fc31a5bdafa456b5cb216bb8758b0076ba8651e5b44e73de7355a9bfd84b582d285c3be1b345aab4255838942a1739fb5045ad5c4da1
7
+ data.tar.gz: 42a4e83b651b23f20108dd414a93ac2ec308a8e03e686e13ab1c61f5b24c8e534d734ce5b55658a82c0e33a3634e428d63c57670091d0db3a87e893bed7c5f32
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- inss_calculator (0.3.0)
4
+ inss_calculator (0.3.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -10,15 +10,15 @@ GEM
10
10
  diff-lcs (1.5.1)
11
11
  json (2.7.2)
12
12
  language_server-protocol (3.17.0.3)
13
- parallel (1.25.1)
14
- parser (3.3.3.0)
13
+ parallel (1.26.0)
14
+ parser (3.3.4.2)
15
15
  ast (~> 2.4.1)
16
16
  racc
17
- racc (1.8.0)
17
+ racc (1.8.1)
18
18
  rainbow (3.1.1)
19
19
  rake (13.2.1)
20
20
  regexp_parser (2.9.2)
21
- rexml (3.3.1)
21
+ rexml (3.3.4)
22
22
  strscan
23
23
  rspec (3.13.0)
24
24
  rspec-core (~> 3.13.0)
@@ -33,24 +33,25 @@ GEM
33
33
  diff-lcs (>= 1.2.0, < 2.0)
34
34
  rspec-support (~> 3.13.0)
35
35
  rspec-support (3.13.1)
36
- rubocop (1.64.1)
36
+ rubocop (1.65.1)
37
37
  json (~> 2.3)
38
38
  language_server-protocol (>= 3.17.0)
39
39
  parallel (~> 1.10)
40
40
  parser (>= 3.3.0.2)
41
41
  rainbow (>= 2.2.2, < 4.0)
42
- regexp_parser (>= 1.8, < 3.0)
42
+ regexp_parser (>= 2.4, < 3.0)
43
43
  rexml (>= 3.2.5, < 4.0)
44
44
  rubocop-ast (>= 1.31.1, < 2.0)
45
45
  ruby-progressbar (~> 1.7)
46
46
  unicode-display_width (>= 2.4.0, < 3.0)
47
- rubocop-ast (1.31.3)
47
+ rubocop-ast (1.32.0)
48
48
  parser (>= 3.3.1.0)
49
49
  ruby-progressbar (1.13.0)
50
50
  strscan (3.1.0)
51
51
  unicode-display_width (2.5.0)
52
52
 
53
53
  PLATFORMS
54
+ ruby
54
55
  x86_64-linux
55
56
 
56
57
  DEPENDENCIES
@@ -60,4 +61,4 @@ DEPENDENCIES
60
61
  rubocop (~> 1.21)
61
62
 
62
63
  BUNDLED WITH
63
- 2.4.10
64
+ 2.5.17
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # InssCalculator
2
2
 
3
- Calculadora do desconto do INSS sobre o salário bruto 2024
3
+ Calculadora do desconto do INSS sobre o salário bruto 2024 de acordo com a [Portaria Inter Ministerial
4
+ número 2 de 11 de Janeiro de 2024](https://www.in.gov.br/en/web/dou/-/portaria-interministerial-mps/mf-n-2-de-11-de-janeiro-de-2024-537035232).
5
+
6
+ Esta mesma portaria discorre tanto sobre a contribuição do trabalhador do setor público quanto do setor privado.
4
7
 
5
8
  ## Instalation
6
9
 
@@ -12,12 +15,28 @@ Não conhecia [esse comando?](https://bundler.io/v2.5/man/bundle-add.1.html) Ele
12
15
 
13
16
  ## Usage
14
17
 
18
+ Para calcular a contribuição do trabalhador no setor privado:
19
+
15
20
  ```
16
21
  gross_salary = 3000
17
22
  calculator = InssCalculator::DiscountPrevidenceCalculator.new(gross_salary)
18
23
  calculator.contribution => 258.81
19
24
  calculator.salary => 3000.0
20
25
  calculator.net_salary => 2741.19
26
+
27
+ ```
28
+ Para calcular a contribuição do trabalhador no setor público:
29
+
30
+ ```
31
+
32
+ gross_salary = 52000.54
33
+ calculator = InssCalculator::PublicInssCalculator.new(gross_salary)
34
+ calculator.contribution => 8726.63
35
+ calculator.salary => 52000.54
36
+ calculator.net_salary => 43273.91
37
+
38
+ ```
39
+ ```
21
40
  ```
22
41
  ### Precisas realizar uma query ao Banco de Dados por grupo de faixa salarial?
23
42
 
@@ -36,6 +55,21 @@ InssCalculator providencia as seguintes constantes:
36
55
  InssCalculator::FOURTH_SALARY_BASE = 4000.04
37
56
  InssCalculator::FOURTH_SALARY_LIMIT = 7786.02
38
57
 
58
+ # Abaixo as bases e os limites do setor público
59
+
60
+ InssCalculator::FIFTH_SALARY_BASE = 7786.03
61
+ InssCalculator::FIFTH_SALARY_LIMIT = 13_333.48
62
+
63
+ InssCalculator::SIXTH_SALARY_BASE = 13_333.49
64
+ InssCalculator::SIXTH_SALARY_LIMIT = 26_666.94
65
+
66
+ InssCalculator::SEVENTH_SALARY_BASE = 26_666.95
67
+ InssCalculator::SEVENTH_SALARY_LIMIT = 52_000.54
68
+
69
+ InssCalculator::EIGTH_SALARY_BASE = 52_000.55
70
+ InssCalculator::EIGTH_SALARY_LIMIT = Float::INFINITY
71
+
72
+
39
73
  ```
40
74
 
41
75
  Desta forma, uma requisição que busca somente a primeira faixa salarial seria:
@@ -54,5 +88,8 @@ Por isso o uso do método `.truncate` ao invés de um arredondamento ao final de
54
88
 
55
89
  Para mais detalhes, veja a regra e o exemplo [deste site](https://www.contabilizei.com.br/contabilidade-online/desconto-inss/)
56
90
 
91
+ ### Vídeo de apresentação
92
+
93
+ [Assista](https://youtu.be/Eu5htw8qb4k?si=mpog6q0PJpxxuEjX) este vídeo no qual apresento um exemplo de uso da gem.
57
94
 
58
95
  ### Feito com amor, feito com Ruby S2
@@ -2,6 +2,7 @@
2
2
 
3
3
  module InssCalculator
4
4
  # Based on this insecure protocoll site https://www.coalize.com.br/calculadora-de-inss
5
+ # Check also the official law https://www.in.gov.br/en/web/dou/-/portaria-interministerial-mps/mf-n-2-de-11-de-janeiro-de-2024-537035232
5
6
  class DiscountPrevidenceCalculator
6
7
  attr_reader :salary
7
8
 
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InssCalculator
4
+ # EigthDiscountCalculator calculates between its range limit
5
+ # As the limit is infinity, it always eacrease the contribution.
6
+ class EigthDiscountCalculator < DiscountCalculatorBase
7
+ QUOTATION = 0.22
8
+
9
+ def contribution
10
+ return NO_CONTRIBUTION if salary <= salary_base
11
+
12
+ return full_contribution if salary > salary_limit
13
+
14
+ calculate_contribution
15
+ end
16
+
17
+ private
18
+
19
+ def calculate_contribution
20
+ ((salary - salary_base) * QUOTATION).truncate(2)
21
+ end
22
+
23
+ def full_contribution
24
+ ((salary_limit - salary_base) * QUOTATION).truncate(2)
25
+ end
26
+
27
+ def salary_limit
28
+ InssCalculator::EIGTH_SALARY_LIMIT
29
+ end
30
+
31
+ def salary_base
32
+ InssCalculator::SEVENTH_SALARY_LIMIT
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InssCalculator
4
+ # FifthDiscountCalculator calculates between its range limit
5
+ # In case the salary is beyond this limit, it will use its quotation apply inside the range salary limit
6
+ class FifthDiscountCalculator < DiscountCalculatorBase
7
+ QUOTATION = 0.145
8
+
9
+ def contribution
10
+ return NO_CONTRIBUTION if salary <= salary_base
11
+
12
+ return full_contribution if salary > salary_limit
13
+
14
+ calculate_contribution
15
+ end
16
+
17
+ private
18
+
19
+ def calculate_contribution
20
+ ((salary - salary_base) * QUOTATION).truncate(2)
21
+ end
22
+
23
+ def full_contribution
24
+ ((salary_limit - salary_base) * QUOTATION).truncate(2)
25
+ end
26
+
27
+ def salary_limit
28
+ InssCalculator::FIFTH_SALARY_LIMIT
29
+ end
30
+
31
+ def salary_base
32
+ InssCalculator::FOURTH_SALARY_LIMIT
33
+ end
34
+ end
35
+ end
@@ -7,7 +7,7 @@ module InssCalculator
7
7
  QUOTATION = 0.14
8
8
 
9
9
  def contribution
10
- return NO_CONTRIBUTION if salary < salary_base
10
+ return NO_CONTRIBUTION if salary <= salary_base
11
11
 
12
12
  return full_contribution if salary > salary_limit
13
13
 
@@ -29,7 +29,7 @@ module InssCalculator
29
29
  end
30
30
 
31
31
  def salary_base
32
- InssCalculator::FOURTH_SALARY_BASE
32
+ InssCalculator::THIRD_SALARY_LIMIT
33
33
  end
34
34
  end
35
35
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InssCalculator
4
+ # Based on this insecure protocoll site https://www.coalize.com.br/calculadora-de-inss
5
+ # Check also the official law https://www.in.gov.br/en/web/dou/-/portaria-interministerial-mps/mf-n-2-de-11-de-janeiro-de-2024-537035232
6
+ # The public contribution is an extension of the private contribution.
7
+ # They have the same rules and quotes percentagen until the fourth salary level.
8
+ class PublicInssCalculator < InssCalculator::DiscountPrevidenceCalculator
9
+ def contribution
10
+ super + public_contribution
11
+ end
12
+
13
+ private
14
+
15
+ def public_contribution
16
+ [
17
+ FifthDiscountCalculator.new(salary).contribution,
18
+ SixthDiscountCalculator.new(salary).contribution,
19
+ SeventhDiscountCalculator.new(salary).contribution,
20
+ EigthDiscountCalculator.new(salary).contribution
21
+ ].reduce(:+).round(2)
22
+ end
23
+ end
24
+ end
@@ -7,7 +7,7 @@ module InssCalculator
7
7
  QUOTATION = 0.09
8
8
 
9
9
  def contribution
10
- return NO_CONTRIBUTION if salary < salary_base
10
+ return NO_CONTRIBUTION if salary <= salary_base
11
11
 
12
12
  return full_contribution if salary > salary_limit
13
13
 
@@ -29,7 +29,7 @@ module InssCalculator
29
29
  end
30
30
 
31
31
  def salary_base
32
- InssCalculator::SECOND_SALARY_BASE
32
+ InssCalculator::FIRST_SALARY_LIMIT
33
33
  end
34
34
  end
35
35
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InssCalculator
4
+ # SeventhDiscountCalculator calculates between its range limit
5
+ # In case the salary is beyond this limit, it will use its quotation apply inside the range salary limit
6
+ class SeventhDiscountCalculator < DiscountCalculatorBase
7
+ QUOTATION = 0.19
8
+
9
+ def contribution
10
+ return NO_CONTRIBUTION if salary <= salary_base
11
+
12
+ return full_contribution if salary > salary_limit
13
+
14
+ calculate_contribution
15
+ end
16
+
17
+ private
18
+
19
+ def calculate_contribution
20
+ ((salary - salary_base) * QUOTATION).truncate(2)
21
+ end
22
+
23
+ def full_contribution
24
+ ((salary_limit - salary_base) * QUOTATION).truncate(2)
25
+ end
26
+
27
+ def salary_limit
28
+ InssCalculator::SEVENTH_SALARY_LIMIT
29
+ end
30
+
31
+ def salary_base
32
+ InssCalculator::SIXTH_SALARY_LIMIT
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InssCalculator
4
+ # SixthDiscountCalculator calculates between its range limit
5
+ # In case the salary is beyond this limit, it will use its quotation apply inside the range salary limit
6
+ class SixthDiscountCalculator < DiscountCalculatorBase
7
+ QUOTATION = 0.165
8
+
9
+ def contribution
10
+ return NO_CONTRIBUTION if salary <= salary_base
11
+
12
+ return full_contribution if salary > salary_limit
13
+
14
+ calculate_contribution
15
+ end
16
+
17
+ private
18
+
19
+ def calculate_contribution
20
+ ((salary - salary_base) * QUOTATION).truncate(2)
21
+ end
22
+
23
+ def full_contribution
24
+ ((salary_limit - salary_base) * QUOTATION).truncate(2)
25
+ end
26
+
27
+ def salary_limit
28
+ InssCalculator::SIXTH_SALARY_LIMIT
29
+ end
30
+
31
+ def salary_base
32
+ InssCalculator::FIFTH_SALARY_LIMIT
33
+ end
34
+ end
35
+ end
@@ -7,7 +7,7 @@ module InssCalculator
7
7
  QUOTATION = 0.12
8
8
 
9
9
  def contribution
10
- return NO_CONTRIBUTION if salary < salary_base
10
+ return NO_CONTRIBUTION if salary <= salary_base
11
11
 
12
12
  return full_contribution if salary > salary_limit
13
13
 
@@ -29,7 +29,7 @@ module InssCalculator
29
29
  end
30
30
 
31
31
  def salary_base
32
- InssCalculator::THIRD_SALARY_BASE
32
+ InssCalculator::SECOND_SALARY_LIMIT
33
33
  end
34
34
  end
35
35
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InssCalculator
4
- VERSION = '0.3.1'
4
+ VERSION = '0.4.0'
5
5
  end
@@ -3,10 +3,15 @@
3
3
  require_relative 'inss_calculator/version'
4
4
  require_relative 'inss_calculator/discount_calculator_base'
5
5
  require_relative 'inss_calculator/discount_previdence_calculator'
6
+ require_relative 'inss_calculator/public_inss_calculator'
6
7
  require_relative 'inss_calculator/first_discount_calculator'
7
8
  require_relative 'inss_calculator/second_discount_calculator'
8
9
  require_relative 'inss_calculator/third_discount_calculator'
9
10
  require_relative 'inss_calculator/fourth_discount_calculator'
11
+ require_relative 'inss_calculator/fifth_discount_calculator'
12
+ require_relative 'inss_calculator/sixth_discount_calculator'
13
+ require_relative 'inss_calculator/seventh_discount_calculator'
14
+ require_relative 'inss_calculator/eigth_discount_calculator'
10
15
 
11
16
  module InssCalculator
12
17
  class Error < StandardError; end
@@ -22,4 +27,16 @@ module InssCalculator
22
27
 
23
28
  FOURTH_SALARY_BASE = 4000.04
24
29
  FOURTH_SALARY_LIMIT = 7786.02
30
+
31
+ FIFTH_SALARY_BASE = 7786.03
32
+ FIFTH_SALARY_LIMIT = 13_333.48
33
+
34
+ SIXTH_SALARY_BASE = 13_333.49
35
+ SIXTH_SALARY_LIMIT = 26_666.94
36
+
37
+ SEVENTH_SALARY_BASE = 26_666.95
38
+ SEVENTH_SALARY_LIMIT = 52_000.54
39
+
40
+ EIGTH_SALARY_BASE = 52_000.55
41
+ EIGTH_SALARY_LIMIT = Float::INFINITY
25
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inss_calculator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paulo Felipe Souza
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-09 00:00:00.000000000 Z
11
+ date: 2024-08-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Calcula o valor a descontar de acordo com a faixa salarial. Os novos
14
14
  valores corrente em 2024.
@@ -32,9 +32,14 @@ files:
32
32
  - lib/inss_calculator.rb
33
33
  - lib/inss_calculator/discount_calculator_base.rb
34
34
  - lib/inss_calculator/discount_previdence_calculator.rb
35
+ - lib/inss_calculator/eigth_discount_calculator.rb
36
+ - lib/inss_calculator/fifth_discount_calculator.rb
35
37
  - lib/inss_calculator/first_discount_calculator.rb
36
38
  - lib/inss_calculator/fourth_discount_calculator.rb
39
+ - lib/inss_calculator/public_inss_calculator.rb
37
40
  - lib/inss_calculator/second_discount_calculator.rb
41
+ - lib/inss_calculator/seventh_discount_calculator.rb
42
+ - lib/inss_calculator/sixth_discount_calculator.rb
38
43
  - lib/inss_calculator/third_discount_calculator.rb
39
44
  - lib/inss_calculator/version.rb
40
45
  - sig/inss_calculator.rbs
@@ -60,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
65
  - !ruby/object:Gem::Version
61
66
  version: '0'
62
67
  requirements: []
63
- rubygems_version: 3.4.10
68
+ rubygems_version: 3.5.17
64
69
  signing_key:
65
70
  specification_version: 4
66
71
  summary: Calculadora de desconto do INSS