tax_calculator 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/lint.yml +20 -0
- data/.github/workflows/ruby.yml +22 -0
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/.rubocop.yml +31 -0
- data/Gemfile +2 -2
- data/README.md +1 -0
- data/Rakefile +2 -0
- data/bin/console +2 -0
- data/lib/tax_calculator.rb +28 -2
- data/lib/tax_calculator/deductions.rb +34 -0
- data/lib/tax_calculator/federal.rb +40 -0
- data/lib/tax_calculator/fica.rb +17 -0
- data/lib/tax_calculator/ohio.rb +27 -0
- data/lib/tax_calculator/ohio/columbus.rb +13 -0
- data/lib/tax_calculator/version.rb +3 -1
- data/tax_calculator.gemspec +12 -3
- metadata +57 -6
- data/Gemfile.lock +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 053db0ef4d3e0e24ab17d7e8ff91e2c3285c4f07b047c82010d97654139583d1
|
4
|
+
data.tar.gz: 52bbbcbffbcac67e5061e163a068ef41456c51b635da0987d2deb77eec1b8f6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.rubocop.yml
ADDED
@@ -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
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
data/bin/console
CHANGED
data/lib/tax_calculator.rb
CHANGED
@@ -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
|
5
|
-
|
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
|
data/tax_calculator.gemspec
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
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 =
|
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
|
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.
|
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
|
-
|
14
|
-
|
15
|
-
|
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
|
data/Gemfile.lock
DELETED