Skip to content

Commit

Permalink
Merge pull request #17 from Pauloparakleto/fix_1500_salary
Browse files Browse the repository at this point in the history
Fix 1500 salary
  • Loading branch information
Pauloparakleto authored Jul 14, 2024
2 parents 11b3889 + 645913f commit 2c48e13
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
inss_calculator (0.3.1)
inss_calculator (0.3.2)

GEM
remote: https://rubygems.org/
Expand Down
4 changes: 2 additions & 2 deletions lib/inss_calculator/fourth_discount_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class FourthDiscountCalculator < DiscountCalculatorBase
QUOTATION = 0.14

def contribution
return NO_CONTRIBUTION if salary < salary_base
return NO_CONTRIBUTION if salary <= salary_base

return full_contribution if salary > salary_limit

Expand All @@ -29,7 +29,7 @@ def salary_limit
end

def salary_base
InssCalculator::FOURTH_SALARY_BASE
InssCalculator::THIRD_SALARY_LIMIT
end
end
end
4 changes: 2 additions & 2 deletions lib/inss_calculator/second_discount_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class SecondDiscountCalculator < DiscountCalculatorBase
QUOTATION = 0.09

def contribution
return NO_CONTRIBUTION if salary < salary_base
return NO_CONTRIBUTION if salary <= salary_base

return full_contribution if salary > salary_limit

Expand All @@ -29,7 +29,7 @@ def salary_limit
end

def salary_base
InssCalculator::SECOND_SALARY_BASE
InssCalculator::FIRST_SALARY_LIMIT
end
end
end
4 changes: 2 additions & 2 deletions lib/inss_calculator/third_discount_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ThirdDiscountCalculator < DiscountCalculatorBase
QUOTATION = 0.12

def contribution
return NO_CONTRIBUTION if salary < salary_base
return NO_CONTRIBUTION if salary <= salary_base

return full_contribution if salary > salary_limit

Expand All @@ -29,7 +29,7 @@ def salary_limit
end

def salary_base
InssCalculator::THIRD_SALARY_BASE
InssCalculator::SECOND_SALARY_LIMIT
end
end
end
2 changes: 1 addition & 1 deletion lib/inss_calculator/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module InssCalculator
VERSION = '0.3.1'
VERSION = '0.3.2'
end
12 changes: 12 additions & 0 deletions spec/inss_calculator/discount_previdence_calculator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,24 @@
end
end

context 'when salary is 1500' do
it 'is 113.82' do
expect(described_class.new('1500').contribution).to eq(113.82)
end
end

context 'when salary is 2666.68' do
it 'is 112.92 + first full contribution' do
expect(described_class.new('2666.68').contribution).to eq(112.92 + 105.9)
end
end

context 'when salary is 2800' do
it 'is 234.81' do
expect(described_class.new('2666.68').contribution).to eq(112.92 + 105.9)
end
end

context 'when salary is 4000.03' do
it 'is 378.82' do
expect(described_class.new('4000.03').contribution).to eq(378.82)
Expand Down
6 changes: 6 additions & 0 deletions spec/inss_calculator/first_discount_calculator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
end
end

context 'when salary is 1100.0' do
it 'is 105.9' do
expect(described_class.new('1100.0').contribution).to eq(82.5)
end
end

context 'when salary is above 1412.0' do
it 'is 105.9' do
expect(described_class.new('3412.01').contribution).to eq(105.9)
Expand Down
6 changes: 6 additions & 0 deletions spec/inss_calculator/fourth_discount_calculator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
end
end

context 'when salary is 5000' do
it 'is 518.81' do
expect(described_class.new('5000').contribution).to eq(139.99)
end
end

context 'when salary is beyond salary level' do
it 'is 530.03' do
expect(described_class.new('10000').contribution).to eq(530.03)
Expand Down
6 changes: 6 additions & 0 deletions spec/inss_calculator/second_discount_calculator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
expect(described_class.new('1412.0').contribution).to eq(0.0)
end
end

context 'when salary is 1500' do
it 'is 113.82' do
expect(described_class.new('1500').contribution).to eq(7.92)
end
end

context 'when salary is 2666.68' do
it 'is 112.92' do
Expand Down
6 changes: 6 additions & 0 deletions spec/inss_calculator/third_discount_calculator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
end
end

context 'when salary is 2800' do
it 'is 15.99' do
expect(described_class.new('2800').contribution).to eq(15.99)
end
end

context 'when salary fills entirely the class level' do
it 'is 160.0' do
expect(described_class.new(4000.03).contribution).to eq(160.0)
Expand Down

0 comments on commit 2c48e13

Please sign in to comment.