tax_calculator 0.1.0 → 0.2.0

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: f2a6c3c3c7b50991247d46866231aac1cc4eaa2b026ba32c2c52c3d39ae62833
4
- data.tar.gz: 5a5d2070f1a047b3f20c0e109dc48738bb4ffeae2352175f9ba6f830093246be
3
+ metadata.gz: 053db0ef4d3e0e24ab17d7e8ff91e2c3285c4f07b047c82010d97654139583d1
4
+ data.tar.gz: 52bbbcbffbcac67e5061e163a068ef41456c51b635da0987d2deb77eec1b8f6e
5
5
  SHA512:
6
- metadata.gz: db9da7ddc61b811e1b0dcf2ac35ce9b230b256ad7ecc66b2e91aa7764428e777ce46152772435012b3dcfd3c6f0621746d5e76bf472f04a1423c6bf15f8ba925
7
- data.tar.gz: ccefa4ba455ef1ed97885fcf4e041fee9fc9d33e3295b03b68dbfdbe8979e212360349e4e194a7c4719d3de449d113cdc79873e874607b23c88b1cefcba457c9
6
+ metadata.gz: 851910b922fca7dfa40bba1d2a81e1e95651e4a3e27b479093ba9afc0dae4223a93038f2c58a7870853881c05604e53aa12340e9cc74c1b046d1bef9b6e43fa6
7
+ data.tar.gz: f9b4a16eabfc99cc6e24f34b361a40d39088dc775b292ebf423cfe497185cbc6953684a24e64690f3d090e41d901de331462733916b31ae8d836b620eafbcda7
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Lint
3
+
4
+ on:
5
+ pull_request:
6
+ branches: [ master ]
7
+
8
+ jobs:
9
+ lint:
10
+
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Set up Ruby
16
+ uses: ruby/setup-ruby@v1
17
+ - name: Install dependencies
18
+ run: bundle install
19
+ - name: Run lint
20
+ run: bundle exec rubocop
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: Test
3
+
4
+ on:
5
+ push:
6
+ branches: [ master ]
7
+ pull_request:
8
+ branches: [ master ]
9
+
10
+ jobs:
11
+ test:
12
+
13
+ runs-on: ubuntu-latest
14
+
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - name: Set up Ruby
18
+ uses: ruby/setup-ruby@v1
19
+ - name: Install dependencies
20
+ run: bundle install
21
+ - name: Run tests
22
+ run: bundle exec rspec
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ *.lock
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
@@ -0,0 +1,31 @@
1
+ ---
2
+
3
+ Style/StringLiterals:
4
+ EnforcedStyle: double_quotes
5
+
6
+ Style/HashSyntax:
7
+ EnforcedStyle: hash_rockets
8
+
9
+ Style/Documentation:
10
+ Enabled: false
11
+
12
+ Metrics/AbcSize:
13
+ Enabled: false
14
+
15
+ Metrics/MethodLength:
16
+ Enabled: false
17
+
18
+ Metrics/PerceivedComplexity:
19
+ Enabled: false
20
+
21
+ Lint/UselessAccessModifier:
22
+ Enabled: false
23
+
24
+ Lint/IneffectiveAccessModifier:
25
+ Enabled: false
26
+
27
+ Lint/AssignmentInCondition:
28
+ Enabled: false
29
+
30
+ Style/SelfAssignment:
31
+ Enabled: false
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  # Specify your gem's dependencies in tax_calculator.gemspec
4
6
  gemspec
5
-
6
- gem "rake", "~> 12.0"
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # TaxCalculator
2
+ ![Test](https://github.com/coreycarvalho/tax_calculator/workflows/Test/badge.svg)
2
3
 
3
4
  Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/tax_calculator`. To experiment with that code, run `bin/console` for an interactive prompt.
4
5
 
data/Rakefile CHANGED
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  task :default => :spec
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # frozen_string_literal: true
4
+
3
5
  require "bundler/setup"
4
6
  require "tax_calculator"
5
7
 
@@ -1,6 +1,32 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "tax_calculator/version"
4
+ require "tax_calculator/federal"
5
+ require "tax_calculator/fica"
6
+ require "tax_calculator/deductions"
7
+ require "tax_calculator/ohio"
8
+ require "tax_calculator/ohio/columbus"
2
9
 
3
10
  module TaxCalculator
4
- class Error < StandardError; end
5
- # Your code goes here...
11
+ class TaxCalculator
12
+ def initialize(income, four_01_k, ira, hsa, health_premiums)
13
+ @income = income.to_i
14
+ @four_01_k = four_01_k.to_i
15
+ @ira = ira.to_i
16
+ @hsa = hsa.to_i
17
+ @health_premiums = health_premiums.to_i
18
+ end
19
+
20
+ def calculate
21
+ deductions = Deductions.new(@income, @four_01_k, @ira, @hsa, @health_premiums)
22
+
23
+ federal = Federal.taxes_for(deductions.federal).round(2)
24
+ fica = FICA.taxes_for(deductions.fica).round(2)
25
+ state = Ohio.taxes_for(deductions.ohio).round(2)
26
+ county = Ohio::Columbus.taxes_for(deductions.columbus).round(2)
27
+ total = (federal + fica + state + county).round(2)
28
+
29
+ { :federal => federal, :fica => fica, :state => state, :county => county, :total => total }
30
+ end
31
+ end
6
32
  end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TaxCalculator
4
+ class Deductions
5
+ STANDARD_DEDUCTION = 24_800
6
+
7
+ attr_reader :federal, :fica, :ohio, :columbus
8
+
9
+ def initialize(income, four_01_k, ira, hsa, health_premiums)
10
+ @federal = for_federal(income, four_01_k, ira, hsa, health_premiums)
11
+ @fica = for_fica(income, hsa, health_premiums)
12
+ @ohio = for_ohio(income, four_01_k, ira, hsa, health_premiums)
13
+ @columbus = for_columbus(income, hsa, health_premiums)
14
+ end
15
+
16
+ def for_federal(income, four_01_k, ira, hsa, health_premiums)
17
+ (income - (four_01_k + ira + hsa + health_premiums + STANDARD_DEDUCTION))
18
+ end
19
+
20
+ def for_fica(income, hsa, health_premiums)
21
+ (income - (hsa + health_premiums))
22
+ end
23
+
24
+ def for_ohio(income, four_01_k, ira, hsa, health_premiums)
25
+ num_exemptions = 2
26
+ personal_exemption = 2_350 * num_exemptions
27
+ (income - (four_01_k + ira + hsa + health_premiums + personal_exemption))
28
+ end
29
+
30
+ def for_columbus(income, hsa, health_premiums)
31
+ income - (hsa + health_premiums)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TaxCalculator
4
+ module Federal
5
+ BRACKETS = {
6
+ :married => {
7
+ 10.0 => 19_750.00,
8
+ 12.0 => 80_250.00,
9
+ 22.0 => 171_050.00,
10
+ 24.0 => 326_600.00,
11
+ 32.0 => 414_700.00,
12
+ 35.0 => 622_050.00,
13
+ 37.0 => :remaining
14
+ }.freeze
15
+ }.freeze
16
+
17
+ def self.taxes_for(income)
18
+ previous_amount = 0
19
+ taxes_owed = 0
20
+
21
+ BRACKETS[:married].each_pair do |bracket, amount|
22
+ if amount == :remaining
23
+ taxes_owed = taxes_owed + ((income - previous_amount) * (bracket / 100))
24
+ break
25
+ end
26
+
27
+ if income < amount
28
+ taxes_owed = taxes_owed + ((income - previous_amount) * (bracket / 100))
29
+ break
30
+ end
31
+
32
+ taxes_owed = taxes_owed + ((amount - previous_amount) * (bracket / 100))
33
+ previous_amount = amount
34
+ break if amount == income
35
+ end
36
+
37
+ taxes_owed.round(2)
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TaxCalculator
4
+ module FICA
5
+ SOCIAL_SECURITY_RATE = 6.2
6
+ SOCIAL_SECURITY_CUTOFF = 275_400.00
7
+ MEDICARE_RATE = 1.45
8
+
9
+ def self.taxes_for(income)
10
+ if income >= SOCIAL_SECURITY_CUTOFF
11
+ owed = ((SOCIAL_SECURITY_CUTOFF * SOCIAL_SECURITY_RATE / 100) + (income * MEDICARE_RATE / 100))
12
+ elsif owed = ((income * SOCIAL_SECURITY_RATE / 100) + (income * MEDICARE_RATE / 100))
13
+ end
14
+ owed
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TaxCalculator
4
+ module Ohio
5
+ def self.taxes_for(income)
6
+ from_brackets(income).round(2)
7
+ end
8
+
9
+ private
10
+
11
+ def self.from_brackets(income)
12
+ if income <= 21_750
13
+ 0
14
+ elsif income <= 43_450
15
+ (income - 21_750) * 0.0285 + 310.47
16
+ elsif income <= 86_900
17
+ (income - 43_450) * 0.03326 + 928.92
18
+ elsif income <= 108_700
19
+ (income - 86_900) * 0.03802 + 2374.07
20
+ elsif income <= 217_400
21
+ (income - 108_700) * 0.04491 + 3202.91
22
+ elsif income > 217_400
23
+ (income - 217_400) * 0.04797 + 7999.84
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TaxCalculator
4
+ module Ohio
5
+ module Columbus
6
+ TAX_RATE = 2.5
7
+
8
+ def self.taxes_for(income)
9
+ (income * TAX_RATE / 100).round(2)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module TaxCalculator
2
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
3
5
  end
@@ -1,4 +1,6 @@
1
- require_relative 'lib/tax_calculator/version'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/tax_calculator/version"
2
4
 
3
5
  Gem::Specification.new do |spec|
4
6
  spec.name = "tax_calculator"
@@ -7,16 +9,23 @@ Gem::Specification.new do |spec|
7
9
  spec.email = ["coreycarvalho@fastmail.com"]
8
10
 
9
11
  spec.summary = "Calculate estimated income tax liability"
10
- spec.description = "This gem provides an easy way to estimate how much income tax you owe in a given year. This is to be used as an estimate only. This gem is not a replacement for CPA services. Please consult your CPA for anything tax related."
12
+ spec.description =
13
+ "This gem provides an easy way to estimate how much income tax you owe in a given year.
14
+ This is to be used as an estimate only. This gem is not a replacement for CPA services.
15
+ Please consult your CPA for anything tax related."
11
16
  spec.homepage = "https://github.com/coreycarvalho/tax_calculator.git"
12
17
  spec.license = "MIT"
13
18
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
19
 
15
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
16
21
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
22
  end
18
23
 
19
24
  spec.bindir = "exe"
20
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
26
  spec.require_paths = ["lib"]
27
+
28
+ spec.add_development_dependency "rake", "~> 13.0"
29
+ spec.add_development_dependency "rspec", "~> 3.0"
30
+ spec.add_development_dependency "rubocop", "~> 0.87"
22
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tax_calculator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Carvalho
@@ -9,26 +9,77 @@ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
11
  date: 2020-07-10 00:00:00.000000000 Z
12
- dependencies: []
13
- description: This gem provides an easy way to estimate how much income tax you owe
14
- in a given year. This is to be used as an estimate only. This gem is not a replacement
15
- for CPA services. Please consult your CPA for anything tax related.
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '13.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '13.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.87'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.87'
55
+ description: |-
56
+ This gem provides an easy way to estimate how much income tax you owe in a given year.
57
+ This is to be used as an estimate only. This gem is not a replacement for CPA services.
58
+ Please consult your CPA for anything tax related.
16
59
  email:
17
60
  - coreycarvalho@fastmail.com
18
61
  executables: []
19
62
  extensions: []
20
63
  extra_rdoc_files: []
21
64
  files:
65
+ - ".github/workflows/lint.yml"
66
+ - ".github/workflows/ruby.yml"
22
67
  - ".gitignore"
68
+ - ".rspec"
69
+ - ".rubocop.yml"
23
70
  - ".ruby-version"
24
71
  - Gemfile
25
- - Gemfile.lock
26
72
  - LICENSE.txt
27
73
  - README.md
28
74
  - Rakefile
29
75
  - bin/console
30
76
  - bin/setup
31
77
  - lib/tax_calculator.rb
78
+ - lib/tax_calculator/deductions.rb
79
+ - lib/tax_calculator/federal.rb
80
+ - lib/tax_calculator/fica.rb
81
+ - lib/tax_calculator/ohio.rb
82
+ - lib/tax_calculator/ohio/columbus.rb
32
83
  - lib/tax_calculator/version.rb
33
84
  - tax_calculator.gemspec
34
85
  homepage: https://github.com/coreycarvalho/tax_calculator.git
@@ -1,19 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- tax_calculator (0.1.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- rake (12.3.3)
10
-
11
- PLATFORMS
12
- ruby
13
-
14
- DEPENDENCIES
15
- rake (~> 12.0)
16
- tax_calculator!
17
-
18
- BUNDLED WITH
19
- 2.1.2