take_home 1.0.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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/lib/fy2020.rb +74 -0
  3. data/lib/take_home.rb +96 -0
  4. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6ef0b9d481af9511b01c69cc1a3ed5cf0ab65b3f75de1b5b25080b32b4eab8a8
4
+ data.tar.gz: 3a0b64465e22118f089e1443ffe279cd878c4c95b5c0637bd1fac2879f2686b5
5
+ SHA512:
6
+ metadata.gz: 9274ff308f3dbc684b2bd6e8a58a54eedfb23a316625fa7f25451c756f7744103bafec3a809c868bab872d11d4d5a8a873ec0b34189fdc1c9d5c38b0e7a1e95a
7
+ data.tar.gz: c2002eff81b440bc7c35c4843104f2bfef8ef69df45eec844f270745d4ba8235d510cb635f1c02c86ad71a4960ffa4a7618f6dadc653eeea3d29cef4e61d33f3
data/lib/fy2020.rb ADDED
@@ -0,0 +1,74 @@
1
+ module TaxConstants
2
+ module FY2020
3
+ SOCIAL_SECURITY_WAGE_BASE = 137700
4
+ SOCIAL_SECURITY_TAX_RATE = 0.062
5
+ MEDICARE_TAX_RATE = 0.0145
6
+
7
+ FEDERAL_SINGLE_STD_DEDUCTION = 12200
8
+ FEDERAL_MARRIED_STD_DEDUCTION = 24400
9
+
10
+ FEDERAL_SINGLE_INCOME_TAX_RATES = {
11
+ 9700 => 0.10,
12
+ 39475 => 0.12,
13
+ 84200 => 0.22,
14
+ 160725 => 0.24,
15
+ 204100 => 0.32,
16
+ 510300 => 0.35,
17
+ Float::INFINITY => 0.37
18
+ }
19
+
20
+ FEDERAL_MARRIED_INCOME_TAX_RATES = {
21
+ 19400 => 0.10,
22
+ 78950 => 0.12,
23
+ 168400 => 0.22,
24
+ 321450 => 0.24,
25
+ 408200 => 0.32,
26
+ 612350 => 0.35,
27
+ Float::INFINITY => 0.37
28
+ }
29
+
30
+ GEORGIA_SINGLE_STD_DEDUCTION = 4600
31
+ GEORGIA_MARRIED_STD_DEDUCTION = 6000
32
+
33
+ GEORGIA_SINGLE_INCOME_TAX_RATES = {
34
+ 750 => 0.01,
35
+ 2250 => 0.02,
36
+ 3750 => 0.03,
37
+ 5250 => 0.04,
38
+ 7000 => 0.05,
39
+ Float::INFINITY => 0.0575
40
+ }
41
+
42
+ GEORGIA_MARRIED_INCOME_TAX_RATES = {
43
+ 1000 => 0.01,
44
+ 3000 => 0.02,
45
+ 5000 => 0.03,
46
+ 7000 => 0.04,
47
+ 10000 => 0.05,
48
+ Float::INFINITY => 0.0575
49
+ }
50
+
51
+ LOOKUP = {
52
+ single: {
53
+ federal: {
54
+ deduction: FEDERAL_SINGLE_STD_DEDUCTION,
55
+ rates: FEDERAL_SINGLE_INCOME_TAX_RATES,
56
+ },
57
+ georgia: {
58
+ deduction: GEORGIA_SINGLE_STD_DEDUCTION,
59
+ rates: GEORGIA_SINGLE_INCOME_TAX_RATES,
60
+ },
61
+ },
62
+ married: {
63
+ federal: {
64
+ deduction: FEDERAL_MARRIED_STD_DEDUCTION,
65
+ rates: FEDERAL_MARRIED_INCOME_TAX_RATES,
66
+ },
67
+ georgia: {
68
+ deduction: GEORGIA_MARRIED_STD_DEDUCTION,
69
+ rates: GEORGIA_MARRIED_INCOME_TAX_RATES,
70
+ },
71
+ }
72
+ }
73
+ end
74
+ end
data/lib/take_home.rb ADDED
@@ -0,0 +1,96 @@
1
+ require_relative 'fy2020.rb'
2
+
3
+ class TaxablePerson
4
+ attr_reader :income
5
+ attr_reader :tax_type
6
+ attr_reader :state
7
+
8
+ def self.single(state, income, opts = {})
9
+ new(:single, state, income, opts)
10
+ end
11
+
12
+ def self.married(state, income, opts = {})
13
+ new(:married, state, income, opts)
14
+ end
15
+
16
+ def taxes
17
+ federal_income_taxes + state_income_taxes + payroll_taxes
18
+ end
19
+
20
+ def federal_income_taxes
21
+ marginal_taxes(income, federal_deductions, federal_tax_rates)
22
+ end
23
+
24
+ def state_income_taxes
25
+ marginal_taxes(income, state_deductions, state_tax_rates)
26
+ end
27
+
28
+ def payroll_taxes
29
+ social_security_taxes + medicare_taxes
30
+ end
31
+
32
+ def social_security_taxes
33
+ if income < social_security_wage_base
34
+ taxes = income * social_security_tax_rate
35
+ else
36
+ taxes = social_security_wage_base * social_security_tax_rate
37
+ end
38
+ end
39
+
40
+ def medicare_taxes
41
+ taxes = medicare_tax_rate * income
42
+ end
43
+
44
+ def effective_tax_rate
45
+ taxes * 100.0 / income
46
+ end
47
+
48
+ def take_home
49
+ income - taxes
50
+ end
51
+
52
+ private
53
+
54
+ attr_accessor :tax_type
55
+ attr_accessor :state
56
+ attr_accessor :income
57
+ attr_accessor :state_tax_rates
58
+ attr_accessor :federal_tax_rates
59
+ attr_accessor :medicare_tax_rate
60
+ attr_accessor :social_security_tax_rate
61
+ attr_accessor :social_security_wage_base
62
+ attr_accessor :federal_deductions
63
+ attr_accessor :state_deductions
64
+
65
+ def configure(opts)
66
+ self.state_deductions = opts[:state_deductions] || TaxConstants::FY2020::LOOKUP[tax_type][state][:deduction]
67
+ self.state_tax_rates = opts[:state_tax_rates] || TaxConstants::FY2020::LOOKUP[tax_type][state][:rates]
68
+ self.federal_deductions = opts[:federal_deductions] || TaxConstants::FY2020::LOOKUP[tax_type][:federal][:deduction]
69
+ self.federal_tax_rates = opts[:federal_tax_rates] || TaxConstants::FY2020::LOOKUP[tax_type][:federal][:rates]
70
+ self.social_security_tax_rate = opts[:social_security_tax_rate] || TaxConstants::FY2020::SOCIAL_SECURITY_TAX_RATE
71
+ self.social_security_wage_base = opts[:social_security_wage_base] || TaxConstants::FY2020::SOCIAL_SECURITY_WAGE_BASE
72
+ self.medicare_tax_rate = opts[:medicare_tax_rate] || TaxConstants::FY2020::MEDICARE_TAX_RATE
73
+ nil
74
+ end
75
+
76
+ def initialize(tax_type, state, income, opts)
77
+ self.tax_type = tax_type.downcase.to_sym
78
+ self.state = state.downcase.to_sym
79
+ self.income = income.to_f
80
+ configure(opts)
81
+ end
82
+
83
+ def marginal_taxes(income, deductions, rates)
84
+ #Calculate AGI
85
+ income = income - deductions
86
+ #Calculate Income Taxes
87
+ taxes = 0
88
+ last_cap = 0
89
+ rates.each do |cap, rate|
90
+ amt = [income, cap].min
91
+ taxes += [(amt - last_cap), 0].max * rate
92
+ last_cap = cap
93
+ end
94
+ taxes
95
+ end
96
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: take_home
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Patrick Wiseman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-01-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Help folks figure out their take home pay and taxes.
14
+ email: patrick.wiseman@deft.services
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/fy2020.rb
20
+ - lib/take_home.rb
21
+ homepage: https://rubygems.org/gems/take_home
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubygems_version: 3.0.3
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Calculate take home pay and taxes
44
+ test_files: []