Skip to content

Commit

Permalink
Revert 9 budget (#11)
Browse files Browse the repository at this point in the history
* Add Federal Tax Rates and test

* Lint Federal Tax Rates

* Add method and poro for calculating taxes on incomes

* Add tax brackets and taxed incomes to dashboard

* Display taxed incomes with turbo

* Update income form select box to display income type

* Lint

* Update test suit

* Lint

* Budget (#9)

* Create budget template

* Render budget on dashboard

* Update budget with turbo

* Lint

* Revert "Budget (#9)"

This reverts commit 050341f.

* Revert "Assign variables" (#12)

* Create budget template

* Render budget on dashboard

* Update budget with turbo

* Lint

* Assign variables (#10)

* Add concern to build instance variables

* Lint

* Revert "Assign variables (#10)"

This reverts commit 556a050.
  • Loading branch information
neb417 authored Nov 7, 2023
1 parent 0ef778d commit 8b64236
Show file tree
Hide file tree
Showing 13 changed files with 152 additions and 4 deletions.
6 changes: 6 additions & 0 deletions app/controllers/fixed_expenses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def create
if @fixed_expense.save
@totals = FixedExpense.total_costs
@fixed_expenses = FixedExpense.get_ordered
@salary_taxed = Income.tax_on_income(income_type: "Salary")
@hourly_taxed = Income.tax_on_income(income_type: "Hourly")
format.html { redirect_to root_path, notice: "Fixed expense was successfully created." }
format.turbo_stream
else
Expand All @@ -41,6 +43,8 @@ def update
respond_to do |format|
if @fixed_expense.update_from_dashboard(params: params[:fixed_expense])
@totals = FixedExpense.total_costs
@salary_taxed = Income.tax_on_income(income_type: "Salary")
@hourly_taxed = Income.tax_on_income(income_type: "Hourly")
format.html { redirect_to root_path, notice: "Fixed expense was successfully updated." }
format.turbo_stream
else
Expand All @@ -55,6 +59,8 @@ def destroy
@fixed_expense.destroy
@totals = FixedExpense.total_costs
@fixed_expenses = FixedExpense.get_ordered
@salary_taxed = Income.tax_on_income(income_type: "Salary")
@hourly_taxed = Income.tax_on_income(income_type: "Hourly")
respond_to do |format|
format.html { redirect_to fixed_expenses_path, notice: "Fixed expense was successfully destroyed." }
format.turbo_stream
Expand Down
1 change: 1 addition & 0 deletions app/controllers/incomes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def update
if @income.update_from_dashboard(params: params)
@salary_taxed = Income.tax_on_income(income_type: "Salary")
@hourly_taxed = Income.tax_on_income(income_type: "Hourly")
@totals = FixedExpense.total_costs
format.html { redirect_to root_path, notice: "Income was successfully updated." }
format.turbo_stream
else
Expand Down
17 changes: 17 additions & 0 deletions app/views/budget/_budget_headings.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div id="salary_budget_labels" class="grid grid-cols-6">
<div class="px-5 py-4 col-2">
Fixed Expense
</div>

<div class="px-5 py-4 col-1">
Investing
</div>

<div class="px-5 py-4 col-1">
Savings
</div>

<div class="px-5 py-4 col-1">
Guilt Free
</div>
</div>
5 changes: 5 additions & 0 deletions app/views/budget/_hourly_budget.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div id="hourly_budget" class="py-4">
<strong>Hourly</strong>
<%= render partial: "budget/budget_headings" %>
<%= render partial: "shared/budget", locals: {totals: totals, income: income} %>
</div>
5 changes: 5 additions & 0 deletions app/views/budget/_salary_budget.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div id="salary_budget" class="py-4">
<strong>Salary</strong>
<%= render partial: "budget/budget_headings" %>
<%= render partial: "shared/budget", locals: {totals: totals, income: income} %>
</div>
16 changes: 16 additions & 0 deletions app/views/dashboard/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@

<main>

<div class="bg-white shadow">
<div class="mx-auto max-w-7xl py-6 sm:px-6 lg:px-8">
<div class="mt-5">
<h3 class="text-2xl font-bold tracking-tight text-gray-900">Budget</h3>
</div>

<%= turbo_frame_tag "salary_budget" do %>
<%= render partial: "budget/salary_budget", locals: {totals: @totals, income: @salary_taxed} %>
<% end %>

<%= turbo_frame_tag "hourly_budget" do %>
<%= render partial: "budget/hourly_budget", locals: {totals: @totals, income: @hourly_taxed} %>
<% end %>
</div>
</div>

<div class="bg-white shadow">
<div class="mx-auto max-w-7xl py-6 sm:px-6 lg:px-8">
<%= turbo_frame_tag "income_header_frame" do %>
Expand Down
8 changes: 8 additions & 0 deletions app/views/fixed_expenses/create.turbo_stream.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@
<%= turbo_stream.replace "total_costs" do %>
<%= render partial: "shared/total_costs", locals: { totals: @totals } %>
<% end %>

<%= turbo_stream.replace "salary_budget" do %>
<%= render partial: "budget/salary_budget", locals: {totals: @totals, income: @salary_taxed} %>
<% end %>

<%= turbo_stream.replace "hourly_budget" do %>
<%= render partial: "budget/hourly_budget", locals: {totals: @totals, income: @hourly_taxed} %>
<% end %>
8 changes: 8 additions & 0 deletions app/views/fixed_expenses/destroy.turbo_stream.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@
<%= turbo_stream.replace "total_costs" do %>
<%= render partial: "shared/total_costs", locals: { totals: @totals } %>
<% end %>

<%= turbo_stream.replace "salary_budget" do %>
<%= render partial: "budget/salary_budget", locals: {totals: @totals, income: @salary_taxed} %>
<% end %>

<%= turbo_stream.replace "hourly_budget" do %>
<%= render partial: "budget/hourly_budget", locals: {totals: @totals, income: @hourly_taxed} %>
<% end %>
8 changes: 8 additions & 0 deletions app/views/fixed_expenses/update.turbo_stream.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@
<%= turbo_stream.replace "total_costs" do %>
<%= render partial: "shared/total_costs", locals: { totals: @totals } %>
<% end %>

<%= turbo_stream.replace "salary_budget" do %>
<%= render partial: "budget/salary_budget", locals: {totals: @totals, income: @salary_taxed} %>
<% end %>

<%= turbo_stream.replace "hourly_budget" do %>
<%= render partial: "budget/hourly_budget", locals: {totals: @totals, income: @hourly_taxed} %>
<% end %>
8 changes: 8 additions & 0 deletions app/views/incomes/update.turbo_stream.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@

<%= turbo_stream.replace "taxed_incomes" do %>
<%= render partial: "shared/taxed_incomes", locals: { salary_taxed: @salary_taxed, hourly_taxed: @hourly_taxed } %>
<% end %>

<%= turbo_stream.replace "salary_budget" do %>
<%= render partial: "budget/salary_budget", locals: {totals: @totals, income: @salary_taxed} %>
<% end %>

<%= turbo_stream.replace "hourly_budget" do %>
<%= render partial: "budget/hourly_budget", locals: {totals: @totals, income: @hourly_taxed} %>
<% end %>
60 changes: 60 additions & 0 deletions app/views/shared/_budget.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<div class="grid grid-cols-6">
<div>Daily</div>
<%= render partial: "shared/total", locals: { total: totals.total_annual_cost / 365 } %>
<div>0</div>
<div>0</div>
<div>
<%= humanized_money_with_symbol((income.total_net_income.fractional / 100) / 365 - totals.total_annual_cost / 365) %>
</div>
</div>

<div class="grid grid-cols-6">
<div>Weekly</div>
<%= render partial: "shared/total", locals: { total: totals.total_bi_weekly_cost / 2 } %>
<div>0</div>
<div>0</div>
<div>
<%= humanized_money_with_symbol((income.bi_weekly_net_income.fractional / 100) / 2 - totals.total_bi_weekly_cost / 2) %>
</div>
</div>

<div class="grid grid-cols-6">
<div>Bi-Weekly</div>
<%= render partial: "shared/total", locals: { total: totals.total_bi_weekly_cost } %>
<div>0</div>
<div>0</div>
<div>
<%= humanized_money_with_symbol((income.bi_weekly_net_income.fractional / 100) - totals.total_bi_weekly_cost) %>
</div>
</div>

<div class="grid grid-cols-6">
<div>Monthly</div>
<%= render partial: "shared/total", locals: { total: totals.total_monthly_cost } %>
<div>0</div>
<div>0</div>
<div>
<%= humanized_money_with_symbol((income.total_net_income.fractional / 100) / 12 - totals.total_monthly_cost) %>
</div>
</div>

<div class="grid grid-cols-6">
<div>Quarterly</div>
<%= render partial: "shared/total", locals: { total: totals.total_annual_cost / 4 } %>
<div>0</div>
<div>0</div>
<div>
<%= humanized_money_with_symbol((income.total_net_income.fractional / 100.0) / 4 - totals.total_annual_cost / 4) %>
</div>
</div>

<div class="grid grid-cols-6">
<div>Annually</div>
<%= render partial: "shared/total", locals: { total: totals.total_annual_cost } %>

<div>0</div>
<div>0</div>
<div>
<%= humanized_money_with_symbol(income.total_net_income.fractional.to_f / 100 - totals.total_annual_cost) %>
</div>
</div>
2 changes: 1 addition & 1 deletion app/views/shared/_total.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="px-5">
<span><strong><%= humanized_money_with_symbol(total) %></strong></span>
<span><%= humanized_money_with_symbol(total) %></span>
</div>
12 changes: 9 additions & 3 deletions app/views/shared/_total_costs.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@
</div>

<div>
<%= render partial: "shared/total", locals: { total: @totals.total_annual_cost } %>
<strong>
<%= render partial: "shared/total", locals: { total: @totals.total_annual_cost } %>
</strong>
</div>

<div>
<%= render partial: "shared/total", locals: { total: @totals.total_monthly_cost } %>
<strong>
<%= render partial: "shared/total", locals: { total: @totals.total_monthly_cost } %>
</strong>
</div>

<div>
<%= render partial: "shared/total", locals: { total: @totals.total_bi_weekly_cost } %>
<strong>
<%= render partial: "shared/total", locals: { total: @totals.total_bi_weekly_cost } %>
</strong>
</div>
</div>

0 comments on commit 8b64236

Please sign in to comment.