Create a gist now

Instantly share code, notes, and snippets.

@thephw /gist:4743827
Last active Nov 15, 2016

What would you like to do?
Taxes 2016 for IRB
################
## Taxes 2016 ##
################
SINGLE_STD_DEDUCTION = 6300
MARRIED_STD_DEDUCTION = 12600
FEDERAL_INDIVIDUAL_INCOME_TAX_RATES = {
9225 => 0.10,
37450 => 0.15,
90750 => 0.25,
189300 => 0.28,
411500 => 0.33,
413200 => 0.35,
Float::INFINITY => 0.396
}
FEDERAL_MARRIED_INCOME_TAX_RATES = {
18450 => 0.10,
74900 => 0.15,
151200 => 0.25,
230450 => 0.28,
411500 => 0.33,
464850 => 0.35,
Float::INFINITY => 0.396
}
GEORGIA_INCOME_TAX_RATES = {
750 => 0.01,
1000 => 0.02,
3000 => 0.03,
5000 => 0.04,
7000 => 0.05,
Float::INFINITY => 0.06
}
SOCIAL_SECURITY_TAX_RATE = 0.124
MEDICARE_TAX_RATE = 0.029
SELF_EMPLOYMENT_TAX_RATE = SOCIAL_SECURITY_TAX_RATE + MEDICARE_TAX_RATE
PAYROLL_TAX_RATE = SELF_EMPLOYMENT_TAX_RATE / 2.0
SOCIAL_SECURITY_WAGE_BASE = 118500
def taxes(income, deductions=0)
self_employment_taxes = self_employment_taxes(income, 0)
deductions = deductions + self_employment_taxes / 2.0 #Can deduct half of self-employment from personal income tax
federal_income_taxes = marginal_taxes(income, (SINGLE_STD_DEDUCTION < deductions ? deductions : SINGLE_STD_DEDUCTION), FEDERAL_INDIVIDUAL_INCOME_TAX_RATES)
state_income_taxes = marginal_taxes(income, (SINGLE_STD_DEDUCTION > deductions ? 0 : deductions), GEORGIA_INCOME_TAX_RATES)
# Total
total = federal_income_taxes + state_income_taxes + self_employment_taxes
end
def compound(amount, rate, num_times)
percentage_growth = rate/100.0 + 1.0
num_times.times do |i|
amount = amount * percentage_growth
if defined? Rails
puts "Period #{i}:\t#{helper.number_to_currency amount}"
else
puts "Period #{i}:\t#{amount}"
end
end
amount
end
def marginal_taxes(income, deductions, rates)
#Calculate AGI
income = income - deductions
#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
def self_employment_taxes(income, deductions=0)
taxes = 2 * (medicare_taxes(income, deductions) + social_security_taxes(income, deductions))
end
def social_security_taxes(income, deductions=0)
income = income - deductions
#Calculate Self-Employment Tax
if income < SOCIAL_SECURITY_WAGE_BASE
taxes = income * SOCIAL_SECURITY_TAX_RATE / 2.0
else
taxes = SOCIAL_SECURITY_WAGE_BASE * SOCIAL_SECURITY_TAX_RATE / 2.0
end
end
def medicare_taxes(income, deductions=0)
income = income - deductions
taxes = MEDICARE_TAX_RATE * income / 2.0
end
def effective_tax_rate(income)
taxes(income)*100.0/income
end
def actual_income(income)
income - taxes(income)
end
def take_home(income)
actual_income(income)
end
def employee_take_home(income)
actual_income(income) + self_employment_taxes(income)/2
end
def estimated_tax_payment(income, deductions=0)
taxes(income, deductions) / 4.0
end
AVERAGE_SINGLE_EMPLOYEE_HEALTHCARE_COSTS_IN_GEORGIA = 4786.0
GEORGIA_UNEMPLOYMENT_INSURANCE_TAX_RATE = 0.0038
GEORGIA_WORKERS_COMP_TAX_RATE = 0.0202
def employee_cost(salary, days_off = 14.0, health_insurance = AVERAGE_SINGLE_EMPLOYEE_HEALTHCARE_COSTS_IN_GEORGIA, unemployment_insurance_tax_rate = GEORGIA_UNEMPLOYMENT_INSURANCE_TAX_RATE, workers_comp_tax_rate = GEORGIA_WORKERS_COMP_TAX_RATE, payroll_tax_rate = PAYROLL_TAX_RATE, retirement_contribution_percentage = 0.05)
cost = salary / ((260.0 - days_off) / 260.0)
cost = cost + health_insurance / 2.0
cost = cost + (payroll_tax_rate + unemployment_insurance_tax_rate + workers_comp_tax_rate + retirement_contribution_percentage) * salary
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment