class TaxablePerson
Attributes
federal_deduction[RW]
federal_tax_rates[RW]
income[RW]
medicare_deduction[RW]
medicare_tax_rates[RW]
state[RW]
state_deduction[RW]
state_tax_rates[RW]
tax_type[RW]
Public Class Methods
married(state, income, opts = {})
click to toggle source
# File lib/take_home.rb, line 12 def self.married(state, income, opts = {}) new(:married, state, income, opts) end
new(tax_type, state, income, opts)
click to toggle source
# File lib/take_home.rb, line 76 def initialize(tax_type, state, income, opts) self.tax_type = tax_type.downcase.to_sym self.state = state.downcase.to_sym self.income = income.to_f configure(opts) end
single(state, income, opts = {})
click to toggle source
# File lib/take_home.rb, line 8 def self.single(state, income, opts = {}) new(:single, state, income, opts) end
Public Instance Methods
effective_tax_rate()
click to toggle source
# File lib/take_home.rb, line 40 def effective_tax_rate taxes * 100.0 / income end
federal_income_taxes()
click to toggle source
# File lib/take_home.rb, line 20 def federal_income_taxes marginal_taxes(income, federal_deduction, federal_tax_rates) end
medicare_taxes()
click to toggle source
# File lib/take_home.rb, line 36 def medicare_taxes marginal_taxes(income, medicare_deduction, medicare_tax_rates) end
payroll_taxes()
click to toggle source
# File lib/take_home.rb, line 28 def payroll_taxes social_security_taxes + medicare_taxes end
state_income_taxes()
click to toggle source
# File lib/take_home.rb, line 24 def state_income_taxes marginal_taxes(income, state_deduction, state_tax_rates) end
take_home()
click to toggle source
# File lib/take_home.rb, line 44 def take_home income - taxes end
taxes()
click to toggle source
# File lib/take_home.rb, line 16 def taxes federal_income_taxes + state_income_taxes + payroll_taxes end
Private Instance Methods
configure(opts)
click to toggle source
# File lib/take_home.rb, line 62 def configure(opts) constants = TaxConstants::FY2020::LOOKUP[tax_type] self.state_tax_rates = opts[:state_tax_rates] || constants[state][:rates] self.federal_tax_rates = opts[:federal_tax_rates] || constants[:federal][:rates] self.social_security_tax_rates = opts[:social_security_tax_rate] || constants[:social_security][:rates] self.medicare_tax_rates = opts[:medicare_tax_rate] || constants[:medicare][:rates] self.federal_deduction = opts[:federal_deduction] || constants[:federal][:deduction] self.state_deduction = opts[:state_deduction] || constants[state][:deduction] self.social_security_deduction = opts[:social_security_deduction] || constants[:social_security][:deduction] self.medicare_deduction = opts[:medicare_deduction] || constants[:medicare][:deduction] nil end
marginal_taxes(income, deduction, rates)
click to toggle source
# File lib/take_home.rb, line 83 def marginal_taxes(income, deduction, rates) #Calculate AGI income = income - deduction #Calculate Income Taxes taxes = 0 last_cap = 0 rates.each do |cap, rate| amt = [income, cap].min taxes += [(amt - last_cap), 0].max * rate last_cap = cap end taxes end