inss_calculator 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: '081930097824d4c7e1e4efcf7c5a6c7990d9924623aa7ec639bd336a117ef5c1'
4
+ data.tar.gz: b8e8198725de7d98ea26d3cef88a67686264237e64c6f009db56c4893bdc092a
5
+ SHA512:
6
+ metadata.gz: f1cd887972ba503b1ceb5e944b185b19fa1d6bad72e5796643bdcb8328a2831a5d87ae7797105d99c0bd6d31998c65be6d76cae72a9afc3e5c79e56567ce4120
7
+ data.tar.gz: 1b2891ffac9e28121aafd6253eda8f89a6b53db2dba71ec2c0cb5699e4110679ea8821d65293727ccd4f2ab7ac8c433758bcbf2928e8b9c6179429088ac66b94
data/.idea/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Editor-based HTTP Client requests
5
+ /httpRequests/
6
+ # Datasource local storage ignored files
7
+ /dataSources/
8
+ /dataSources.local.xml
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,15 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.2.2
3
+ Include:
4
+ - 'lib/**/*.rb'
5
+
6
+ Style/StringLiterals:
7
+ Enabled: true
8
+ EnforcedStyle: single_quotes
9
+
10
+ Style/StringLiteralsInInterpolation:
11
+ Enabled: true
12
+ EnforcedStyle: double_quotes
13
+
14
+ Layout/LineLength:
15
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-06-26
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at alparakleto@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in inss_calculator.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
9
+
10
+ gem 'rspec', '~> 3.0'
11
+
12
+ gem 'rubocop', '~> 1.21'
data/Gemfile.lock ADDED
@@ -0,0 +1,63 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ inss_calculator (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ diff-lcs (1.5.1)
11
+ json (2.7.2)
12
+ language_server-protocol (3.17.0.3)
13
+ parallel (1.25.1)
14
+ parser (3.3.3.0)
15
+ ast (~> 2.4.1)
16
+ racc
17
+ racc (1.8.0)
18
+ rainbow (3.1.1)
19
+ rake (13.2.1)
20
+ regexp_parser (2.9.2)
21
+ rexml (3.3.1)
22
+ strscan
23
+ rspec (3.13.0)
24
+ rspec-core (~> 3.13.0)
25
+ rspec-expectations (~> 3.13.0)
26
+ rspec-mocks (~> 3.13.0)
27
+ rspec-core (3.13.0)
28
+ rspec-support (~> 3.13.0)
29
+ rspec-expectations (3.13.1)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.13.0)
32
+ rspec-mocks (3.13.1)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.13.0)
35
+ rspec-support (3.13.1)
36
+ rubocop (1.64.1)
37
+ json (~> 2.3)
38
+ language_server-protocol (>= 3.17.0)
39
+ parallel (~> 1.10)
40
+ parser (>= 3.3.0.2)
41
+ rainbow (>= 2.2.2, < 4.0)
42
+ regexp_parser (>= 1.8, < 3.0)
43
+ rexml (>= 3.2.5, < 4.0)
44
+ rubocop-ast (>= 1.31.1, < 2.0)
45
+ ruby-progressbar (~> 1.7)
46
+ unicode-display_width (>= 2.4.0, < 3.0)
47
+ rubocop-ast (1.31.3)
48
+ parser (>= 3.3.1.0)
49
+ ruby-progressbar (1.13.0)
50
+ strscan (3.1.0)
51
+ unicode-display_width (2.5.0)
52
+
53
+ PLATFORMS
54
+ x86_64-linux
55
+
56
+ DEPENDENCIES
57
+ inss_calculator!
58
+ rake (~> 13.0)
59
+ rspec (~> 3.0)
60
+ rubocop (~> 1.21)
61
+
62
+ BUNDLED WITH
63
+ 2.4.10
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Paulo Felipe Souza
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1 @@
1
+ # InssCalculator
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/inss_calculator/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'inss_calculator'
7
+ spec.version = InssCalculator::VERSION
8
+ spec.authors = ['Paulo Felipe Souza']
9
+ spec.email = ['alparakleto@gmail.com']
10
+
11
+ spec.summary = 'Calculadora de desconto do INSS'
12
+ spec.description = 'Calcula o valor a descontar de acordo com a faixa salarial. Os novos valores corrente em 2024.'
13
+ spec.homepage = 'https://github.com/Pauloparakleto/inss_calculator'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = '>= 2.6.0'
16
+
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = 'https://github.com/Pauloparakleto/inss_calculator'
19
+ spec.metadata['changelog_uri'] = 'https://github.com/Pauloparakleto/inss_calculator/blob/main/CHANGELOG.md'
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(__dir__) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
26
+ end
27
+ end
28
+ spec.bindir = 'exe'
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ['lib']
31
+
32
+ # Uncomment to register a new dependency of your gem
33
+ # spec.add_dependency "example-gem", "~> 1.0"
34
+
35
+ # For more information and examples about making a new gem, check out our
36
+ # guide at: https://bundler.io/guides/creating_gem.html
37
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InssCalculator
4
+ # DiscountCalculatorBase provide the common initializer
5
+ # for First, Second, Third and Fourth Discount calculators
6
+ class DiscountCalculatorBase
7
+ attr_reader :salary
8
+
9
+ NO_CONTRIBUTION = 0.0
10
+ SALARY_BASE = 0.0
11
+
12
+ def initialize(salary)
13
+ @salary = salary.to_f
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,21 @@
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
+ class DiscountPrevidenceCalculator
6
+ attr_reader :salary
7
+
8
+ def initialize(salary)
9
+ @salary = salary.to_f
10
+ end
11
+
12
+ def contribution
13
+ [
14
+ FirstDiscountCalculator.new(salary).contribution,
15
+ SecondDiscountCalculator.new(salary).contribution,
16
+ ThirdDiscountCalculator.new(salary).contribution,
17
+ FourthDiscountCalculator.new(salary).contribution
18
+ ].reduce(:+).truncate(2)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InssCalculator
4
+ # FirstDiscountCalculator 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 FirstDiscountCalculator < DiscountCalculatorBase
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
+
12
+ def contribution
13
+ return FULL_CONTRIBUTION if salary > SALARY_LIMIT
14
+
15
+ (salary * QUOTATION).truncate(2)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InssCalculator
4
+ # FourthDiscountCalculator 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 FourthDiscountCalculator < DiscountCalculatorBase
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
+
12
+ def contribution
13
+ return NO_CONTRIBUTION if salary <= SALARY_BASE
14
+
15
+ return FULL_CONTRIBUTION if salary > SALARY_LIMIT
16
+
17
+ ((salary - SALARY_BASE) * QUOTATION).truncate(2)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InssCalculator
4
+ # SecondDiscountCalculator 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 SecondDiscountCalculator < DiscountCalculatorBase
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
+
12
+ def contribution
13
+ return NO_CONTRIBUTION if salary <= SALARY_BASE
14
+
15
+ return FULL_CONTRIBUTION if salary > SALARY_LIMIT
16
+
17
+ ((salary - SALARY_BASE) * QUOTATION).truncate(2)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InssCalculator
4
+ # ThirdDiscountCalculator 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 ThirdDiscountCalculator < DiscountCalculatorBase
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
+
12
+ def contribution
13
+ return NO_CONTRIBUTION if salary <= SALARY_BASE
14
+
15
+ return FULL_CONTRIBUTION if salary > SALARY_LIMIT
16
+
17
+ ((salary - SALARY_BASE) * QUOTATION).truncate(2)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InssCalculator
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'inss_calculator/version'
4
+ require_relative 'inss_calculator/discount_calculator_base'
5
+ require_relative 'inss_calculator/discount_previdence_calculator'
6
+ require_relative 'inss_calculator/first_discount_calculator'
7
+ require_relative 'inss_calculator/second_discount_calculator'
8
+ require_relative 'inss_calculator/third_discount_calculator'
9
+ require_relative 'inss_calculator/fourth_discount_calculator'
10
+
11
+ module InssCalculator
12
+ class Error < StandardError; end
13
+ # Your code goes here...
14
+ end
@@ -0,0 +1,4 @@
1
+ module InssCalculator
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: inss_calculator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Paulo Felipe Souza
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-06-27 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Calcula o valor a descontar de acordo com a faixa salarial. Os novos
14
+ valores corrente em 2024.
15
+ email:
16
+ - alparakleto@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".idea/.gitignore"
22
+ - ".rspec"
23
+ - ".rubocop.yml"
24
+ - CHANGELOG.md
25
+ - CODE_OF_CONDUCT.md
26
+ - Gemfile
27
+ - Gemfile.lock
28
+ - LICENSE.txt
29
+ - README.md
30
+ - Rakefile
31
+ - inss_calculator.gemspec
32
+ - lib/inss_calculator.rb
33
+ - lib/inss_calculator/discount_calculator_base.rb
34
+ - lib/inss_calculator/discount_previdence_calculator.rb
35
+ - lib/inss_calculator/first_discount_calculator.rb
36
+ - lib/inss_calculator/fourth_discount_calculator.rb
37
+ - lib/inss_calculator/second_discount_calculator.rb
38
+ - lib/inss_calculator/third_discount_calculator.rb
39
+ - lib/inss_calculator/version.rb
40
+ - sig/inss_calculator.rbs
41
+ homepage: https://github.com/Pauloparakleto/inss_calculator
42
+ licenses:
43
+ - MIT
44
+ metadata:
45
+ homepage_uri: https://github.com/Pauloparakleto/inss_calculator
46
+ source_code_uri: https://github.com/Pauloparakleto/inss_calculator
47
+ changelog_uri: https://github.com/Pauloparakleto/inss_calculator/blob/main/CHANGELOG.md
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 2.6.0
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubygems_version: 3.4.10
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: Calculadora de desconto do INSS
67
+ test_files: []