inss_calculator 0.4.2 → 1.0.1

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: b0c5d044bf05b0f50ac8c9b4b6fe0634e0f809fd18918fd84a8a15a5fcbfd09a
4
- data.tar.gz: 56906b9378630a07cb21ab2fab31caf77511a2808b78d347270ccde37df6ea08
3
+ metadata.gz: 7c26259d0d272ad367057ec25c168c35d6edf8c41be8ca592277ed1332d15bbb
4
+ data.tar.gz: 1fb285bc202d1fff36ff2d9660bb2a778fd1f5ff6a9f24301c6a6e8f4c5c34be
5
5
  SHA512:
6
- metadata.gz: 54a10e9bda6faff9e6ce0765aa5ae6ceb92dbd0fe333995312860acc68bb15a6c085eb0a17097a0937fdb56d392f4fb61f4912676ae77e80d2bfd387e17e244a
7
- data.tar.gz: 1ed31865a00db8bd38a9b782bcd0d7cd2e899e3743b221de2de85e8ffcf391e3dfaa5fb7308d7763c0df02c777fbbbad1554ecf82a6bf61b087f39166c732cd3
6
+ metadata.gz: d6102f683e8ea54d82e4798138c65857bb16d607a8bf09c6b8d3e47f46ed1ca89acdb484baa02aceec0e2bb4679c24793b41664fd2df9cc7c5707e9d05d19d0b
7
+ data.tar.gz: f7c1b79e52d493dde3770ba0e4d78725d912dc98efb16d27856d8a97af2ec716ea3cbed56e1d804e9f870e3fd64844920001c9496459d0eecd61483d21d1cfa0
data/Gemfile.lock CHANGED
@@ -1,54 +1,52 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- inss_calculator (0.4.1)
4
+ inss_calculator (1.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  ast (2.4.2)
10
10
  diff-lcs (1.5.1)
11
- json (2.7.2)
12
- language_server-protocol (3.17.0.3)
11
+ json (2.9.1)
12
+ language_server-protocol (3.17.0.4)
13
13
  parallel (1.26.3)
14
- parser (3.3.4.2)
14
+ parser (3.3.7.0)
15
15
  ast (~> 2.4.1)
16
16
  racc
17
17
  racc (1.8.1)
18
18
  rainbow (3.1.1)
19
19
  rake (13.2.1)
20
- regexp_parser (2.9.2)
21
- rexml (3.3.4)
22
- strscan
20
+ regexp_parser (2.10.0)
23
21
  rspec (3.13.0)
24
22
  rspec-core (~> 3.13.0)
25
23
  rspec-expectations (~> 3.13.0)
26
24
  rspec-mocks (~> 3.13.0)
27
- rspec-core (3.13.0)
25
+ rspec-core (3.13.2)
28
26
  rspec-support (~> 3.13.0)
29
- rspec-expectations (3.13.1)
27
+ rspec-expectations (3.13.3)
30
28
  diff-lcs (>= 1.2.0, < 2.0)
31
29
  rspec-support (~> 3.13.0)
32
- rspec-mocks (3.13.1)
30
+ rspec-mocks (3.13.2)
33
31
  diff-lcs (>= 1.2.0, < 2.0)
34
32
  rspec-support (~> 3.13.0)
35
- rspec-support (3.13.1)
36
- rubocop (1.65.1)
33
+ rspec-support (3.13.2)
34
+ rubocop (1.71.1)
37
35
  json (~> 2.3)
38
36
  language_server-protocol (>= 3.17.0)
39
37
  parallel (~> 1.10)
40
38
  parser (>= 3.3.0.2)
41
39
  rainbow (>= 2.2.2, < 4.0)
42
- regexp_parser (>= 2.4, < 3.0)
43
- rexml (>= 3.2.5, < 4.0)
44
- rubocop-ast (>= 1.31.1, < 2.0)
40
+ regexp_parser (>= 2.9.3, < 3.0)
41
+ rubocop-ast (>= 1.38.0, < 2.0)
45
42
  ruby-progressbar (~> 1.7)
46
- unicode-display_width (>= 2.4.0, < 3.0)
47
- rubocop-ast (1.32.0)
43
+ unicode-display_width (>= 2.4.0, < 4.0)
44
+ rubocop-ast (1.38.0)
48
45
  parser (>= 3.3.1.0)
49
46
  ruby-progressbar (1.13.0)
50
- strscan (3.1.0)
51
- unicode-display_width (2.5.0)
47
+ unicode-display_width (3.1.4)
48
+ unicode-emoji (~> 4.0, >= 4.0.4)
49
+ unicode-emoji (4.0.4)
52
50
 
53
51
  PLATFORMS
54
52
  ruby
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # InssCalculator
2
2
 
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).
3
+ Calculadora de desconto do INSS de 2025 de acordo com a [Portaria Interministerial n. 6 de 10 de Janeiro de 2025](https://www.in.gov.br/en/web/dou/-/portaria-interministerial-mps/mf-n-6-de-10-de-janeiro-de-2025-606526848)
5
4
 
6
5
  Esta mesma portaria discorre tanto sobre a contribuição do trabalhador do setor público quanto do setor privado.
7
6
 
@@ -18,11 +17,11 @@ Não conhecia [esse comando?](https://bundler.io/v2.5/man/bundle-add.1.html) Ele
18
17
  Para calcular a contribuição do trabalhador no setor privado:
19
18
 
20
19
  ```
21
- gross_salary = 3000
20
+ gross_salary = 1518.0
22
21
  calculator = InssCalculator::DiscountPrevidenceCalculator.new(gross_salary)
23
- calculator.contribution => 258.81
24
- calculator.salary => 3000.0
25
- calculator.net_salary => 2741.19
22
+ calculator.contribution => 113.85
23
+ calculator.salary => 1518.0
24
+ calculator.net_salary => 1404.15
26
25
 
27
26
  ```
28
27
  Para calcular a contribuição do trabalhador no setor público:
@@ -43,31 +42,31 @@ calculator.net_salary => 43273.91
43
42
  InssCalculator providencia as seguintes constantes:
44
43
 
45
44
  ```
46
- InssCalculator::FIRST_SALARY_BASE = 0.0
47
- InssCalculator::FIRST_SALARY_LIMIT = 1412.0
45
+ InssCalculator::SalaryLevels::FIRST_SALARY_BASE = 0.0
46
+ InssCalculator::SalaryLevels::FIRST_SALARY_LIMIT = 1518.0
48
47
 
49
- InssCalculator::SECOND_SALARY_BASE = 1412.01
50
- InssCalculator::SECOND_SALARY_LIMIT = 2666.68
48
+ InssCalculator::SalaryLevels::SECOND_SALARY_BASE = 1518.01
49
+ InssCalculator::SalaryLevels::SECOND_SALARY_LIMIT = 2793.88
51
50
 
52
- InssCalculator::THIRD_SALARY_BASE = 2666.69
53
- InssCalculator::THIRD_SALARY_LIMIT = 4000.03
51
+ InssCalculator::SalaryLevels::THIRD_SALARY_BASE = 2793.89
52
+ InssCalculator::SalaryLevels::THIRD_SALARY_LIMIT = 4190.83
54
53
 
55
- InssCalculator::FOURTH_SALARY_BASE = 4000.04
56
- InssCalculator::FOURTH_SALARY_LIMIT = 7786.02
54
+ InssCalculator::SalaryLevels::FOURTH_SALARY_BASE = 4190.84
55
+ InssCalculator::SalaryLevels::FOURTH_SALARY_LIMIT = 8157.41
57
56
 
58
57
  # Abaixo as bases e os limites do setor público
59
58
 
60
- InssCalculator::FIFTH_SALARY_BASE = 7786.03
61
- InssCalculator::FIFTH_SALARY_LIMIT = 13_333.48
59
+ InssCalculator::SalaryLevels::FIFTH_SALARY_BASE = 8157.42
60
+ InssCalculator::SalaryLevels::FIFTH_SALARY_LIMIT = 13969.49
62
61
 
63
- InssCalculator::SIXTH_SALARY_BASE = 13_333.49
64
- InssCalculator::SIXTH_SALARY_LIMIT = 26_666.94
62
+ InssCalculator::SalaryLevels::SIXTH_SALARY_BASE = 13969.5
63
+ InssCalculator::SalaryLevels::SIXTH_SALARY_LIMIT = 27938.95
65
64
 
66
- InssCalculator::SEVENTH_SALARY_BASE = 26_666.95
67
- InssCalculator::SEVENTH_SALARY_LIMIT = 52_000.54
65
+ InssCalculator::SalaryLevels::SEVENTH_SALARY_BASE = 27938.96
66
+ InssCalculator::SalaryLevels::SEVENTH_SALARY_LIMIT = 54480.97
68
67
 
69
- InssCalculator::EIGTH_SALARY_BASE = 52_000.55
70
- InssCalculator::EIGTH_SALARY_LIMIT = Float::INFINITY
68
+ InssCalculator::SalaryLevels::EIGTH_SALARY_BASE = 54480.98
69
+ InssCalculator::SalaryLevels::EIGTH_SALARY_LIMIT = Float::INFINITY
71
70
 
72
71
 
73
72
  ```
@@ -75,7 +74,7 @@ InssCalculator providencia as seguintes constantes:
75
74
  Desta forma, uma requisição que busca somente a primeira faixa salarial seria:
76
75
 
77
76
  ```
78
- YourModel.where("salary <= ?", InssCalculator::FIRST_SALARY_LIMIT)
77
+ YourModel.where("salary <= ?", InssCalculator::SalaryLevels::FIRST_SALARY_LIMIT)
79
78
  ```
80
79
 
81
80
  ## Decorators
@@ -87,7 +86,7 @@ Você ainda tem acesso à classe original com `#calculator`.
87
86
  ```
88
87
  calculator = InssCalculator::DiscountPrevidenceCalculator.new(3000)
89
88
  text_decorator = InssCalculator::Decorator::Text.new(calculator)
90
- text_decorator.present => "Com o salário de R$ 3.000,00, sua contribuição é de R$ 258,81. Seu salário líquido, portanto, é de R$ 2.741,19."
89
+ text_decorator.present => "Com o salário de R$ 3.000,00, sua contribuição é de R$ 253,40. Seu salário líquido, portanto, é de R$ 2.746,60."
91
90
 
92
91
  text_decorator.calculator => InssCalculator::DiscountPrevidenceCalculator.new(3000)
93
92
 
@@ -101,10 +100,13 @@ Cada faixa salarial trunca seu resultado final após aplicar a sua alíquota cor
101
100
 
102
101
  Por isso o uso do método `.truncate` ao invés de um arredondamento ao final de cada cálculo parcial.
103
102
 
104
- Para mais detalhes, veja a regra e o exemplo [deste site](https://www.contabilizei.com.br/contabilidade-online/desconto-inss/)
105
-
106
103
  ### Vídeo de apresentação
107
104
 
108
105
  [Assista](https://youtu.be/Eu5htw8qb4k?si=mpog6q0PJpxxuEjX) este vídeo no qual apresento um exemplo de uso da gem.
109
106
 
107
+ ## Ainda precisa da calculadora de 2024?
108
+
109
+ Calculadora do desconto do INSS sobre o salário bruto 2024 de acordo com a [Portaria Inter Ministerial
110
+ 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) foi movida para o módulo `InssCalculator::Legacy::DiscountPrevidenceCalculator`.
111
+
110
112
  ### Feito com amor, feito com Ruby S2
@@ -25,11 +25,11 @@ module InssCalculator
25
25
  end
26
26
 
27
27
  def salary_limit
28
- InssCalculator::EIGTH_SALARY_LIMIT
28
+ InssCalculator::SalaryLevels::EIGTH_SALARY_LIMIT
29
29
  end
30
30
 
31
31
  def salary_base
32
- InssCalculator::SEVENTH_SALARY_LIMIT
32
+ InssCalculator::SalaryLevels::SEVENTH_SALARY_LIMIT
33
33
  end
34
34
  end
35
35
  end
@@ -25,11 +25,11 @@ module InssCalculator
25
25
  end
26
26
 
27
27
  def salary_limit
28
- InssCalculator::FIFTH_SALARY_LIMIT
28
+ InssCalculator::SalaryLevels::FIFTH_SALARY_LIMIT
29
29
  end
30
30
 
31
31
  def salary_base
32
- InssCalculator::FOURTH_SALARY_LIMIT
32
+ InssCalculator::SalaryLevels::FOURTH_SALARY_LIMIT
33
33
  end
34
34
  end
35
35
  end
@@ -23,11 +23,11 @@ module InssCalculator
23
23
  end
24
24
 
25
25
  def salary_limit
26
- InssCalculator::FIRST_SALARY_LIMIT
26
+ InssCalculator::SalaryLevels::FIRST_SALARY_LIMIT
27
27
  end
28
28
 
29
29
  def salary_base
30
- InssCalculator::FIRST_SALARY_BASE
30
+ InssCalculator::SalaryLevels::FIRST_SALARY_BASE
31
31
  end
32
32
  end
33
33
  end
@@ -25,11 +25,11 @@ module InssCalculator
25
25
  end
26
26
 
27
27
  def salary_limit
28
- InssCalculator::FOURTH_SALARY_LIMIT
28
+ InssCalculator::SalaryLevels::FOURTH_SALARY_LIMIT
29
29
  end
30
30
 
31
31
  def salary_base
32
- InssCalculator::THIRD_SALARY_LIMIT
32
+ InssCalculator::SalaryLevels::THIRD_SALARY_LIMIT
33
33
  end
34
34
  end
35
35
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InssCalculator
4
+ module Legacy
5
+ # Based on this insecure protocoll site https://www.coalize.com.br/calculadora-de-inss
6
+ # 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
7
+ class DiscountPrevidenceCalculator
8
+ attr_reader :salary
9
+
10
+ def initialize(salary)
11
+ @salary = salary.to_f
12
+ end
13
+
14
+ def contribution
15
+ [
16
+ FirstDiscountCalculator.new(salary).contribution,
17
+ SecondDiscountCalculator.new(salary).contribution,
18
+ ThirdDiscountCalculator.new(salary).contribution,
19
+ FourthDiscountCalculator.new(salary).contribution
20
+ ].reduce(:+).round(2)
21
+ end
22
+
23
+ def net_salary
24
+ (salary - contribution).round(2)
25
+ end
26
+
27
+ def present
28
+ raise InssCalculator::NoMethodError, message: 'Use a decorator instead!'
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InssCalculator
4
+ module Legacy
5
+ # EigthDiscountCalculator calculates between its range limit
6
+ # As the limit is infinity, it always eacrease the contribution.
7
+ class EigthDiscountCalculator < DiscountCalculatorBase
8
+ QUOTATION = 0.22
9
+
10
+ def contribution
11
+ return NO_CONTRIBUTION if salary <= salary_base
12
+
13
+ return full_contribution if salary > salary_limit
14
+
15
+ calculate_contribution
16
+ end
17
+
18
+ private
19
+
20
+ def calculate_contribution
21
+ ((salary - salary_base) * QUOTATION).truncate(2)
22
+ end
23
+
24
+ def full_contribution
25
+ ((salary_limit - salary_base) * QUOTATION).truncate(2)
26
+ end
27
+
28
+ def salary_limit
29
+ InssCalculator::Legacy::SalaryLevels::EIGTH_SALARY_LIMIT
30
+ end
31
+
32
+ def salary_base
33
+ InssCalculator::Legacy::SalaryLevels::SEVENTH_SALARY_LIMIT
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InssCalculator
4
+ module Legacy
5
+ # FifthDiscountCalculator calculates between its range limit
6
+ # In case the salary is beyond this limit, it will use its quotation apply inside the range salary limit
7
+ class FifthDiscountCalculator < DiscountCalculatorBase
8
+ QUOTATION = 0.145
9
+
10
+ def contribution
11
+ return NO_CONTRIBUTION if salary <= salary_base
12
+
13
+ return full_contribution if salary > salary_limit
14
+
15
+ calculate_contribution
16
+ end
17
+
18
+ private
19
+
20
+ def calculate_contribution
21
+ ((salary - salary_base) * QUOTATION).truncate(2)
22
+ end
23
+
24
+ def full_contribution
25
+ ((salary_limit - salary_base) * QUOTATION).truncate(2)
26
+ end
27
+
28
+ def salary_limit
29
+ InssCalculator::Legacy::SalaryLevels::FIFTH_SALARY_LIMIT
30
+ end
31
+
32
+ def salary_base
33
+ InssCalculator::Legacy::SalaryLevels::FOURTH_SALARY_LIMIT
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InssCalculator
4
+ module Legacy
5
+ # FirstDiscountCalculator calculates between its range limit
6
+ # In case the salary is beyond this limit, it will use its quotation apply inside the range salary limit
7
+ class FirstDiscountCalculator < DiscountCalculatorBase
8
+ QUOTATION = 0.075
9
+
10
+ def contribution
11
+ return full_contribution if salary > salary_limit
12
+
13
+ calculate_contribution
14
+ end
15
+
16
+ private
17
+
18
+ def calculate_contribution
19
+ ((salary - salary_base) * QUOTATION).truncate(2)
20
+ end
21
+
22
+ def full_contribution
23
+ ((salary_limit - salary_base) * QUOTATION).truncate(2)
24
+ end
25
+
26
+ def salary_limit
27
+ InssCalculator::Legacy::SalaryLevels::FIRST_SALARY_LIMIT
28
+ end
29
+
30
+ def salary_base
31
+ InssCalculator::Legacy::SalaryLevels::FIRST_SALARY_BASE
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InssCalculator
4
+ module Legacy
5
+ # FourthDiscountCalculator calculates between its range limit
6
+ # In case the salary is beyond this limit, it will use its quotation apply inside the range salary limit
7
+ class FourthDiscountCalculator < DiscountCalculatorBase
8
+ QUOTATION = 0.14
9
+
10
+ def contribution
11
+ return NO_CONTRIBUTION if salary <= salary_base
12
+
13
+ return full_contribution if salary > salary_limit
14
+
15
+ calculate_contribution
16
+ end
17
+
18
+ private
19
+
20
+ def calculate_contribution
21
+ ((salary - salary_base) * QUOTATION).truncate(2)
22
+ end
23
+
24
+ def full_contribution
25
+ ((salary_limit - salary_base) * QUOTATION).truncate(2)
26
+ end
27
+
28
+ def salary_limit
29
+ InssCalculator::Legacy::SalaryLevels::FOURTH_SALARY_LIMIT
30
+ end
31
+
32
+ def salary_base
33
+ InssCalculator::Legacy::SalaryLevels::THIRD_SALARY_LIMIT
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InssCalculator
4
+ module Legacy
5
+ # Based on this insecure protocoll site https://www.coalize.com.br/calculadora-de-inss
6
+ # 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
7
+ # The public contribution is an extension of the private contribution.
8
+ # They have the same rules and quotes percentagen until the fourth salary level.
9
+ class PublicInssCalculator < InssCalculator::Legacy::DiscountPrevidenceCalculator
10
+ def contribution
11
+ super + public_contribution
12
+ end
13
+
14
+ private
15
+
16
+ def public_contribution
17
+ [
18
+ FifthDiscountCalculator.new(salary).contribution,
19
+ SixthDiscountCalculator.new(salary).contribution,
20
+ SeventhDiscountCalculator.new(salary).contribution,
21
+ EigthDiscountCalculator.new(salary).contribution
22
+ ].reduce(:+).round(2)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,29 @@
1
+ module InssCalculator
2
+ module Legacy
3
+ module SalaryLevels
4
+ FIRST_SALARY_BASE = 0.0
5
+ FIRST_SALARY_LIMIT = 1412.0
6
+
7
+ SECOND_SALARY_BASE = 1412.01
8
+ SECOND_SALARY_LIMIT = 2666.68
9
+
10
+ THIRD_SALARY_BASE = 2666.69
11
+ THIRD_SALARY_LIMIT = 4000.03
12
+
13
+ FOURTH_SALARY_BASE = 4000.04
14
+ FOURTH_SALARY_LIMIT = 7786.02
15
+
16
+ FIFTH_SALARY_BASE = 7786.03
17
+ FIFTH_SALARY_LIMIT = 13_333.48
18
+
19
+ SIXTH_SALARY_BASE = 13_333.49
20
+ SIXTH_SALARY_LIMIT = 26_666.94
21
+
22
+ SEVENTH_SALARY_BASE = 26_666.95
23
+ SEVENTH_SALARY_LIMIT = 52_000.54
24
+
25
+ EIGTH_SALARY_BASE = 52_000.55
26
+ EIGTH_SALARY_LIMIT = Float::INFINITY
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InssCalculator
4
+ module Legacy
5
+ # SecondDiscountCalculator calculates between its range limit
6
+ # In case the salary is beyond this limit, it will use its quotation apply inside the range salary limit
7
+ class SecondDiscountCalculator < DiscountCalculatorBase
8
+ QUOTATION = 0.09
9
+
10
+ def contribution
11
+ return NO_CONTRIBUTION if salary <= salary_base
12
+
13
+ return full_contribution if salary > salary_limit
14
+
15
+ calculate_contribution
16
+ end
17
+
18
+ private
19
+
20
+ def calculate_contribution
21
+ ((salary - salary_base) * QUOTATION).truncate(2)
22
+ end
23
+
24
+ def full_contribution
25
+ ((salary_limit - salary_base) * QUOTATION).truncate(2)
26
+ end
27
+
28
+ def salary_limit
29
+ InssCalculator::Legacy::SalaryLevels::SECOND_SALARY_LIMIT
30
+ end
31
+
32
+ def salary_base
33
+ InssCalculator::Legacy::SalaryLevels::FIRST_SALARY_LIMIT
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InssCalculator
4
+ module Legacy
5
+ # SeventhDiscountCalculator calculates between its range limit
6
+ # In case the salary is beyond this limit, it will use its quotation apply inside the range salary limit
7
+ class SeventhDiscountCalculator < DiscountCalculatorBase
8
+ QUOTATION = 0.19
9
+
10
+ def contribution
11
+ return NO_CONTRIBUTION if salary <= salary_base
12
+
13
+ return full_contribution if salary > salary_limit
14
+
15
+ calculate_contribution
16
+ end
17
+
18
+ private
19
+
20
+ def calculate_contribution
21
+ ((salary - salary_base) * QUOTATION).truncate(2)
22
+ end
23
+
24
+ def full_contribution
25
+ ((salary_limit - salary_base) * QUOTATION).truncate(2)
26
+ end
27
+
28
+ def salary_limit
29
+ InssCalculator::Legacy::SalaryLevels::SEVENTH_SALARY_LIMIT
30
+ end
31
+
32
+ def salary_base
33
+ InssCalculator::Legacy::SalaryLevels::SIXTH_SALARY_LIMIT
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InssCalculator
4
+ module Legacy
5
+ # SixthDiscountCalculator calculates between its range limit
6
+ # In case the salary is beyond this limit, it will use its quotation apply inside the range salary limit
7
+ class SixthDiscountCalculator < DiscountCalculatorBase
8
+ QUOTATION = 0.165
9
+
10
+ def contribution
11
+ return NO_CONTRIBUTION if salary <= salary_base
12
+
13
+ return full_contribution if salary > salary_limit
14
+
15
+ calculate_contribution
16
+ end
17
+
18
+ private
19
+
20
+ def calculate_contribution
21
+ ((salary - salary_base) * QUOTATION).truncate(2)
22
+ end
23
+
24
+ def full_contribution
25
+ ((salary_limit - salary_base) * QUOTATION).truncate(2)
26
+ end
27
+
28
+ def salary_limit
29
+ InssCalculator::Legacy::SalaryLevels::SIXTH_SALARY_LIMIT
30
+ end
31
+
32
+ def salary_base
33
+ InssCalculator::Legacy::SalaryLevels::FIFTH_SALARY_LIMIT
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InssCalculator
4
+ module Legacy
5
+ # ThirdDiscountCalculator calculates between its range limit
6
+ # In case the salary is beyond this limit, it will use its quotation apply inside the range salary limit
7
+ class ThirdDiscountCalculator < DiscountCalculatorBase
8
+ QUOTATION = 0.12
9
+
10
+ def contribution
11
+ return NO_CONTRIBUTION if salary <= salary_base
12
+
13
+ return full_contribution if salary > salary_limit
14
+
15
+ calculate_contribution
16
+ end
17
+
18
+ private
19
+
20
+ def calculate_contribution
21
+ ((salary - salary_base) * QUOTATION).truncate(2)
22
+ end
23
+
24
+ def full_contribution
25
+ ((salary_limit - salary_base) * QUOTATION).truncate(2)
26
+ end
27
+
28
+ def salary_limit
29
+ InssCalculator::Legacy::SalaryLevels::THIRD_SALARY_LIMIT
30
+ end
31
+
32
+ def salary_base
33
+ InssCalculator::Legacy::SalaryLevels::SECOND_SALARY_LIMIT
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InssCalculator
4
+ module SalaryLevels
5
+ FIRST_SALARY_BASE = 0.0
6
+ FIRST_SALARY_LIMIT = 1518.0
7
+
8
+ SECOND_SALARY_BASE = 1518.01
9
+ SECOND_SALARY_LIMIT = 2793.88
10
+
11
+ THIRD_SALARY_BASE = 2793.89
12
+ THIRD_SALARY_LIMIT = 4190.83
13
+
14
+ FOURTH_SALARY_BASE = 4190.84
15
+ FOURTH_SALARY_LIMIT = 8157.41
16
+
17
+ FIFTH_SALARY_BASE = 8157.42
18
+ FIFTH_SALARY_LIMIT = 13_969.49
19
+
20
+ SIXTH_SALARY_BASE = 13_969.50
21
+
22
+ SIXTH_SALARY_LIMIT = 27_938.95
23
+
24
+ SEVENTH_SALARY_BASE = 27_938.96
25
+ SEVENTH_SALARY_LIMIT = 54_480.97
26
+
27
+ EIGTH_SALARY_BASE = 54_480.98
28
+ EIGTH_SALARY_LIMIT = Float::INFINITY
29
+ end
30
+ end
@@ -25,11 +25,11 @@ module InssCalculator
25
25
  end
26
26
 
27
27
  def salary_limit
28
- InssCalculator::SECOND_SALARY_LIMIT
28
+ InssCalculator::SalaryLevels::SECOND_SALARY_LIMIT
29
29
  end
30
30
 
31
31
  def salary_base
32
- InssCalculator::FIRST_SALARY_LIMIT
32
+ InssCalculator::SalaryLevels::FIRST_SALARY_LIMIT
33
33
  end
34
34
  end
35
35
  end
@@ -25,11 +25,11 @@ module InssCalculator
25
25
  end
26
26
 
27
27
  def salary_limit
28
- InssCalculator::SEVENTH_SALARY_LIMIT
28
+ InssCalculator::SalaryLevels::SEVENTH_SALARY_LIMIT
29
29
  end
30
30
 
31
31
  def salary_base
32
- InssCalculator::SIXTH_SALARY_LIMIT
32
+ InssCalculator::SalaryLevels::SIXTH_SALARY_LIMIT
33
33
  end
34
34
  end
35
35
  end
@@ -25,11 +25,11 @@ module InssCalculator
25
25
  end
26
26
 
27
27
  def salary_limit
28
- InssCalculator::SIXTH_SALARY_LIMIT
28
+ InssCalculator::SalaryLevels::SIXTH_SALARY_LIMIT
29
29
  end
30
30
 
31
31
  def salary_base
32
- InssCalculator::FIFTH_SALARY_LIMIT
32
+ InssCalculator::SalaryLevels::FIFTH_SALARY_LIMIT
33
33
  end
34
34
  end
35
35
  end
@@ -25,11 +25,11 @@ module InssCalculator
25
25
  end
26
26
 
27
27
  def salary_limit
28
- InssCalculator::THIRD_SALARY_LIMIT
28
+ InssCalculator::SalaryLevels::THIRD_SALARY_LIMIT
29
29
  end
30
30
 
31
31
  def salary_base
32
- InssCalculator::SECOND_SALARY_LIMIT
32
+ InssCalculator::SalaryLevels::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.4.2'
4
+ VERSION = '1.0.1'
5
5
  end
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'inss_calculator/version'
4
- require_relative './dinheiro'
5
- require_relative 'inss_calculator/discount_calculator_base'
6
4
  require_relative 'inss_calculator/discount_previdence_calculator'
7
5
  require_relative 'inss_calculator/public_inss_calculator'
6
+ require_relative 'inss_calculator/salary_levels'
7
+ require_relative './dinheiro'
8
+ require_relative 'inss_calculator/discount_calculator_base'
8
9
  require_relative 'inss_calculator/first_discount_calculator'
9
10
  require_relative 'inss_calculator/second_discount_calculator'
10
11
  require_relative 'inss_calculator/third_discount_calculator'
@@ -13,34 +14,23 @@ require_relative 'inss_calculator/fifth_discount_calculator'
13
14
  require_relative 'inss_calculator/sixth_discount_calculator'
14
15
  require_relative 'inss_calculator/seventh_discount_calculator'
15
16
  require_relative 'inss_calculator/eigth_discount_calculator'
17
+ require_relative 'inss_calculator//legacy/salary_levels'
18
+ # for legacy calculator 2024
19
+ require_relative 'inss_calculator/legacy/discount_previdence_calculator'
20
+ require_relative 'inss_calculator/legacy/public_inss_calculator'
21
+ require_relative 'inss_calculator/legacy/first_discount_calculator'
22
+ require_relative 'inss_calculator/legacy/second_discount_calculator'
23
+ require_relative 'inss_calculator/legacy/third_discount_calculator'
24
+ require_relative 'inss_calculator/legacy/fourth_discount_calculator'
25
+ require_relative 'inss_calculator/legacy/fifth_discount_calculator'
26
+ require_relative 'inss_calculator/legacy/sixth_discount_calculator'
27
+ require_relative 'inss_calculator/legacy/seventh_discount_calculator'
28
+ require_relative 'inss_calculator/legacy/eigth_discount_calculator'
16
29
  require_relative 'inss_calculator/decorator/text'
17
30
 
18
31
  module InssCalculator
19
32
  class Error < StandardError; end
20
33
  # Your code goes here...
21
- FIRST_SALARY_BASE = 0.0
22
- FIRST_SALARY_LIMIT = 1412.0
23
-
24
- SECOND_SALARY_BASE = 1412.01
25
- SECOND_SALARY_LIMIT = 2666.68
26
-
27
- THIRD_SALARY_BASE = 2666.69
28
- THIRD_SALARY_LIMIT = 4000.03
29
-
30
- FOURTH_SALARY_BASE = 4000.04
31
- FOURTH_SALARY_LIMIT = 7786.02
32
-
33
- FIFTH_SALARY_BASE = 7786.03
34
- FIFTH_SALARY_LIMIT = 13_333.48
35
-
36
- SIXTH_SALARY_BASE = 13_333.49
37
- SIXTH_SALARY_LIMIT = 26_666.94
38
-
39
- SEVENTH_SALARY_BASE = 26_666.95
40
- SEVENTH_SALARY_LIMIT = 52_000.54
41
-
42
- EIGTH_SALARY_BASE = 52_000.55
43
- EIGTH_SALARY_LIMIT = Float::INFINITY
44
34
  end
45
35
 
46
36
  require_relative 'inss_calculator/error/no_method_error'
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.4.2
4
+ version: 1.0.1
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: 2025-01-19 00:00:00.000000000 Z
11
+ date: 2025-02-03 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.
@@ -39,7 +39,19 @@ files:
39
39
  - lib/inss_calculator/fifth_discount_calculator.rb
40
40
  - lib/inss_calculator/first_discount_calculator.rb
41
41
  - lib/inss_calculator/fourth_discount_calculator.rb
42
+ - lib/inss_calculator/legacy/discount_previdence_calculator.rb
43
+ - lib/inss_calculator/legacy/eigth_discount_calculator.rb
44
+ - lib/inss_calculator/legacy/fifth_discount_calculator.rb
45
+ - lib/inss_calculator/legacy/first_discount_calculator.rb
46
+ - lib/inss_calculator/legacy/fourth_discount_calculator.rb
47
+ - lib/inss_calculator/legacy/public_inss_calculator.rb
48
+ - lib/inss_calculator/legacy/salary_levels.rb
49
+ - lib/inss_calculator/legacy/second_discount_calculator.rb
50
+ - lib/inss_calculator/legacy/seventh_discount_calculator.rb
51
+ - lib/inss_calculator/legacy/sixth_discount_calculator.rb
52
+ - lib/inss_calculator/legacy/third_discount_calculator.rb
42
53
  - lib/inss_calculator/public_inss_calculator.rb
54
+ - lib/inss_calculator/salary_levels.rb
43
55
  - lib/inss_calculator/second_discount_calculator.rb
44
56
  - lib/inss_calculator/seventh_discount_calculator.rb
45
57
  - lib/inss_calculator/sixth_discount_calculator.rb