diff --git a/app/services/income_tax_calculator_service.rb b/app/services/income_tax_calculator_service.rb index a3fe483..ce7e99e 100644 --- a/app/services/income_tax_calculator_service.rb +++ b/app/services/income_tax_calculator_service.rb @@ -2,6 +2,7 @@ class IncomeTaxCalculatorService attr_reader :income, :annual_income, :federal_tax, + :fica_tax, :net_after_fed_tax, :state_tax, :total_net_income, @@ -16,6 +17,7 @@ def initialize(income:) @income = income @annual_income = income.weekly_income * 52 @federal_tax = calculate_fed_tax + @fica_tax = calculate_fica_tax @net_after_fed_tax = calculate_net_after_fed_tax @state_tax = calculate_state_tax @total_net_income = calculate_total_net_income @@ -36,6 +38,10 @@ def calculate_fed_tax rated + bracket.cumulative end + def calculate_fica_tax + @annual_income * 0.0765 + end + def calculate_state_tax @net_after_fed_tax * 0.0463 end @@ -45,7 +51,7 @@ def calculate_net_after_fed_tax end def calculate_total_net_income - @net_after_fed_tax - @state_tax + @net_after_fed_tax - @fica_tax - @state_tax end def calculate_bi_weekly_income diff --git a/app/views/incomes/_index.html.erb b/app/views/incomes/_index.html.erb index 4321b01..43645c5 100644 --- a/app/views/incomes/_index.html.erb +++ b/app/views/incomes/_index.html.erb @@ -1,4 +1,4 @@ -Net Income +

Net Income

<% income_headings = ["Income Type", "Rate", "Hours", "Weekly Gross"] %> <% income_headings.each do |income_heading| %> diff --git a/app/views/shared/_taxed_income.html.erb b/app/views/shared/_taxed_income.html.erb index c5bdd2a..e33ddad 100644 --- a/app/views/shared/_taxed_income.html.erb +++ b/app/views/shared/_taxed_income.html.erb @@ -1,4 +1,14 @@ -
<%= humanized_money_with_symbol(taxed_income.federal_tax) %>
-
<%= humanized_money_with_symbol(taxed_income.state_tax) %>
-
<%= humanized_money_with_symbol(taxed_income.total_net_income) %>
-
<%= humanized_money_with_symbol(taxed_income.bi_weekly_net_income) %>
\ No newline at end of file + + + + + +<% paid_taxes = [ taxed_income.federal_tax, taxed_income.fica_tax, taxed_income.state_tax, taxed_income.total_net_income ] %> + +<% paid_taxes.each do |tax| %> + <% if annual %> +
<%= humanized_money_with_symbol(tax) %>
+ <% else %> +
<%= humanized_money_with_symbol(tax / 26) %>
+ <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/shared/_taxed_incomes.html.erb b/app/views/shared/_taxed_incomes.html.erb index 2e6fe7e..9625da5 100644 --- a/app/views/shared/_taxed_incomes.html.erb +++ b/app/views/shared/_taxed_incomes.html.erb @@ -1,6 +1,6 @@ -Gross Income +

Gross Income Annual

- <% fixed_headings = ["Income Type", "Federal Tax", "State Tax", "Annual", "Bi-weekly"] %> + <% fixed_headings = ["Income Type", "Federal Tax", "Fica Tax", "State Tax", "Annual"] %> <% fixed_headings.each do |fixed_heading| %>
<%= fixed_heading %>
<% end %> @@ -8,10 +8,30 @@
Salary
- <%= render partial: "shared/taxed_income", locals: { taxed_income: salary_taxed} %> + <%= render partial: "shared/taxed_income", locals: { taxed_income: salary_taxed, annual: true } %>
Hourly
- <%= render partial: "shared/taxed_income", locals: { taxed_income: hourly_taxed} %> + <%= render partial: "shared/taxed_income", locals: { taxed_income: hourly_taxed, annual: true } %> +
+ +
+ +

Gross Income Bi-Weekly

+
+ <% fixed_headings = ["Income Type", "Federal Tax", "Fica Tax", "State Tax", "Bi-weekly"] %> + <% fixed_headings.each do |fixed_heading| %> +
<%= fixed_heading %>
+ <% end %> +
+ +
+
Salary
+ <%= render partial: "shared/taxed_income", locals: { taxed_income: salary_taxed, annual: false } %> +
+ +
+
Hourly
+ <%= render partial: "shared/taxed_income", locals: { taxed_income: hourly_taxed, annual: false } %>