inss_calculator 0.2.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +24 -0
- data/lib/inss_calculator/discount_previdence_calculator.rb +2 -2
- data/lib/inss_calculator/first_discount_calculator.rb +20 -5
- data/lib/inss_calculator/fourth_discount_calculator.rb +21 -6
- data/lib/inss_calculator/second_discount_calculator.rb +21 -6
- data/lib/inss_calculator/third_discount_calculator.rb +21 -6
- data/lib/inss_calculator/version.rb +1 -1
- data/lib/inss_calculator.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 930151d58edfe02aeb3b597a2b51b569cba243a6560c56a5d345869f498570ab
|
4
|
+
data.tar.gz: 665e637c5662127e28ddd1785fde22697f315f71954106b03a3d33d52b764ae7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca58062897e260e5c1c4e8863d95f16d9cbc9179645119ecdf5bd7b3af1d1b279577cf8b7602a0ad2292b496b095c0431123725f5b904aef639b8bff1ff75c28
|
7
|
+
data.tar.gz: 4a8f8ef91bbab45fc4dd03b3169a962d98a075dfed9ddc90f2c681ec66f1e43fb6a231712e8b54188d62be2b4c224bac2206df8e9bfeb2d6d29c810699b05014
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -19,6 +19,30 @@ calculator.contribution => 258.81
|
|
19
19
|
calculator.salary => 3000.0
|
20
20
|
calculator.net_salary => 2741.19
|
21
21
|
```
|
22
|
+
### Precisas realizar uma query ao Banco de Dados por grupo de faixa salarial?
|
23
|
+
|
24
|
+
InssCalculator providencia as seguintes constantes:
|
25
|
+
|
26
|
+
```
|
27
|
+
InssCalculator::FIRST_SALARY_BASE = 0.0
|
28
|
+
InssCalculator::FIRST_SALARY_LIMIT = 1412.0
|
29
|
+
|
30
|
+
InssCalculator::SECOND_SALARY_BASE = 1412.01
|
31
|
+
InssCalculator::SECOND_SALARY_LIMIT = 2666.68
|
32
|
+
|
33
|
+
InssCalculator::THIRD_SALARY_BASE = 2666.69
|
34
|
+
InssCalculator::THIRD_SALARY_LIMIT = 4000.03
|
35
|
+
|
36
|
+
InssCalculator::FOURTH_SALARY_BASE = 4000.04
|
37
|
+
InssCalculator::FOURTH_SALARY_LIMIT = 7786.02
|
38
|
+
|
39
|
+
```
|
40
|
+
|
41
|
+
Desta forma, uma requisição que busca somente a primeira faixa salarial seria:
|
42
|
+
|
43
|
+
```
|
44
|
+
YourModel.where("salary <= ?", InssCalculator::FIRST_SALARY_LIMIT)
|
45
|
+
```
|
22
46
|
|
23
47
|
## Nota sobre trabalhar com números decimais em Ruby
|
24
48
|
|
@@ -15,11 +15,11 @@ module InssCalculator
|
|
15
15
|
SecondDiscountCalculator.new(salary).contribution,
|
16
16
|
ThirdDiscountCalculator.new(salary).contribution,
|
17
17
|
FourthDiscountCalculator.new(salary).contribution
|
18
|
-
].reduce(:+).
|
18
|
+
].reduce(:+).round(2)
|
19
19
|
end
|
20
20
|
|
21
21
|
def net_salary
|
22
|
-
salary - contribution
|
22
|
+
(salary - contribution).round(2)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -5,14 +5,29 @@ module InssCalculator
|
|
5
5
|
# In case the salary is beyond this limit, it will use its quotation apply inside the range salary limit
|
6
6
|
class FirstDiscountCalculator < DiscountCalculatorBase
|
7
7
|
QUOTATION = 0.075
|
8
|
-
SALARY_BASE = 0.00
|
9
|
-
SALARY_LIMIT = 1412.0
|
10
|
-
FULL_CONTRIBUTION = ((SALARY_LIMIT - SALARY_BASE) * QUOTATION).truncate(2)
|
11
8
|
|
12
9
|
def contribution
|
13
|
-
return
|
10
|
+
return full_contribution if salary > salary_limit
|
14
11
|
|
15
|
-
|
12
|
+
calculate_contribution
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def calculate_contribution
|
18
|
+
((salary - salary_base) * QUOTATION).truncate(2)
|
19
|
+
end
|
20
|
+
|
21
|
+
def full_contribution
|
22
|
+
((salary_limit - salary_base) * QUOTATION).truncate(2)
|
23
|
+
end
|
24
|
+
|
25
|
+
def salary_limit
|
26
|
+
InssCalculator::FIRST_SALARY_LIMIT
|
27
|
+
end
|
28
|
+
|
29
|
+
def salary_base
|
30
|
+
InssCalculator::FIRST_SALARY_BASE
|
16
31
|
end
|
17
32
|
end
|
18
33
|
end
|
@@ -5,16 +5,31 @@ module InssCalculator
|
|
5
5
|
# In case the salary is beyond this limit, it will use its quotation apply inside the range salary limit
|
6
6
|
class FourthDiscountCalculator < DiscountCalculatorBase
|
7
7
|
QUOTATION = 0.14
|
8
|
-
SALARY_BASE = 4000.04
|
9
|
-
SALARY_LIMIT = 7786.02
|
10
|
-
FULL_CONTRIBUTION = ((SALARY_LIMIT - SALARY_BASE) * QUOTATION).truncate(2)
|
11
8
|
|
12
9
|
def contribution
|
13
|
-
return NO_CONTRIBUTION if salary
|
10
|
+
return NO_CONTRIBUTION if salary < salary_base
|
14
11
|
|
15
|
-
return
|
12
|
+
return full_contribution if salary > salary_limit
|
16
13
|
|
17
|
-
|
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::FOURTH_SALARY_LIMIT
|
29
|
+
end
|
30
|
+
|
31
|
+
def salary_base
|
32
|
+
InssCalculator::FOURTH_SALARY_BASE
|
18
33
|
end
|
19
34
|
end
|
20
35
|
end
|
@@ -5,16 +5,31 @@ module InssCalculator
|
|
5
5
|
# In case the salary is beyond this limit, it will use its quotation apply inside the range salary limit
|
6
6
|
class SecondDiscountCalculator < DiscountCalculatorBase
|
7
7
|
QUOTATION = 0.09
|
8
|
-
SALARY_BASE = 1412.0
|
9
|
-
SALARY_LIMIT = 2666.68
|
10
|
-
FULL_CONTRIBUTION = ((SALARY_LIMIT - SALARY_BASE) * QUOTATION).truncate(2)
|
11
8
|
|
12
9
|
def contribution
|
13
|
-
return NO_CONTRIBUTION if salary
|
10
|
+
return NO_CONTRIBUTION if salary < salary_base
|
14
11
|
|
15
|
-
return
|
12
|
+
return full_contribution if salary > salary_limit
|
16
13
|
|
17
|
-
|
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::SECOND_SALARY_LIMIT
|
29
|
+
end
|
30
|
+
|
31
|
+
def salary_base
|
32
|
+
InssCalculator::SECOND_SALARY_BASE
|
18
33
|
end
|
19
34
|
end
|
20
35
|
end
|
@@ -5,16 +5,31 @@ module InssCalculator
|
|
5
5
|
# In case the salary is beyond this limit, it will use its quotation apply inside the range salary limit
|
6
6
|
class ThirdDiscountCalculator < DiscountCalculatorBase
|
7
7
|
QUOTATION = 0.12
|
8
|
-
SALARY_BASE = 2666.68
|
9
|
-
SALARY_LIMIT = 4000.03
|
10
|
-
FULL_CONTRIBUTION = ((SALARY_LIMIT - SALARY_BASE) * QUOTATION).truncate(2)
|
11
8
|
|
12
9
|
def contribution
|
13
|
-
return NO_CONTRIBUTION if salary
|
10
|
+
return NO_CONTRIBUTION if salary < salary_base
|
14
11
|
|
15
|
-
return
|
12
|
+
return full_contribution if salary > salary_limit
|
16
13
|
|
17
|
-
|
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::THIRD_SALARY_LIMIT
|
29
|
+
end
|
30
|
+
|
31
|
+
def salary_base
|
32
|
+
InssCalculator::THIRD_SALARY_BASE
|
18
33
|
end
|
19
34
|
end
|
20
35
|
end
|
data/lib/inss_calculator.rb
CHANGED
@@ -11,4 +11,15 @@ require_relative 'inss_calculator/fourth_discount_calculator'
|
|
11
11
|
module InssCalculator
|
12
12
|
class Error < StandardError; end
|
13
13
|
# Your code goes here...
|
14
|
+
FIRST_SALARY_BASE = 0.0
|
15
|
+
FIRST_SALARY_LIMIT = 1412.0
|
16
|
+
|
17
|
+
SECOND_SALARY_BASE = 1412.01
|
18
|
+
SECOND_SALARY_LIMIT = 2666.68
|
19
|
+
|
20
|
+
THIRD_SALARY_BASE = 2666.69
|
21
|
+
THIRD_SALARY_LIMIT = 4000.03
|
22
|
+
|
23
|
+
FOURTH_SALARY_BASE = 4000.04
|
24
|
+
FOURTH_SALARY_LIMIT = 7786.02
|
14
25
|
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.
|
4
|
+
version: 0.3.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: 2024-07-
|
11
|
+
date: 2024-07-09 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.
|