Skip to content

Commit

Permalink
Add fica. (#24)
Browse files Browse the repository at this point in the history
Add part in incomes for bi-weekly.
  • Loading branch information
neb417 authored Jan 8, 2024
1 parent bc7b1dc commit 4b2fb51
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
8 changes: 7 additions & 1 deletion app/services/income_tax_calculator_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class IncomeTaxCalculatorService
attr_reader :income,
:annual_income,
:federal_tax,
:fica_tax,
:net_after_fed_tax,
:state_tax,
:total_net_income,
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/incomes/_index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<strong>Net Income</strong>
<h3>Net Income</h3>
<div class="grid grid-cols-5">
<% income_headings = ["Income Type", "Rate", "Hours", "Weekly Gross"] %>
<% income_headings.each do |income_heading| %>
Expand Down
18 changes: 14 additions & 4 deletions app/views/shared/_taxed_income.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
<div class="px-5"><%= humanized_money_with_symbol(taxed_income.federal_tax) %></div>
<div class="px-5"><%= humanized_money_with_symbol(taxed_income.state_tax) %></div>
<div class="px-5"><%= humanized_money_with_symbol(taxed_income.total_net_income) %></div>
<div class="px-5"><%= humanized_money_with_symbol(taxed_income.bi_weekly_net_income) %></div>
<!--<div class="px-5"><%#= humanized_money_with_symbol(taxed_income.federal_tax) %></div>-->
<!--<div class="px-5"><%#= humanized_money_with_symbol(taxed_income.fica_tax) %></div>-->
<!--<div class="px-5"><%#= humanized_money_with_symbol(taxed_income.state_tax) %></div>-->
<!--<div class="px-5"><%#= humanized_money_with_symbol(taxed_income.total_net_income) %></div>-->

<% 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 %>
<div class="px-5"><%= humanized_money_with_symbol(tax) %></div>
<% else %>
<div class="px-5"><%= humanized_money_with_symbol(tax / 26) %></div>
<% end %>
<% end %>
28 changes: 24 additions & 4 deletions app/views/shared/_taxed_incomes.html.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
<strong>Gross Income</strong>
<h3>Gross Income Annual</h3>
<div class="grid grid-cols-5">
<% 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| %>
<div class="px-5"><strong><%= fixed_heading %></strong></div>
<% end %>
</div>

<div class="grid grid-cols-5">
<div class="px-5">Salary</div>
<%= render partial: "shared/taxed_income", locals: { taxed_income: salary_taxed} %>
<%= render partial: "shared/taxed_income", locals: { taxed_income: salary_taxed, annual: true } %>
</div>

<div class="grid grid-cols-5">
<div class="px-5">Hourly</div>
<%= render partial: "shared/taxed_income", locals: { taxed_income: hourly_taxed} %>
<%= render partial: "shared/taxed_income", locals: { taxed_income: hourly_taxed, annual: true } %>
</div>

<br>

<h3>Gross Income Bi-Weekly</h3>
<div class="grid grid-cols-5">
<% fixed_headings = ["Income Type", "Federal Tax", "Fica Tax", "State Tax", "Bi-weekly"] %>
<% fixed_headings.each do |fixed_heading| %>
<div class="px-5"><strong><%= fixed_heading %></strong></div>
<% end %>
</div>

<div class="grid grid-cols-5">
<div class="px-5">Salary</div>
<%= render partial: "shared/taxed_income", locals: { taxed_income: salary_taxed, annual: false } %>
</div>

<div class="grid grid-cols-5">
<div class="px-5">Hourly</div>
<%= render partial: "shared/taxed_income", locals: { taxed_income: hourly_taxed, annual: false } %>
</div>

0 comments on commit 4b2fb51

Please sign in to comment.