Skip to content

Commit

Permalink
Find and replace all @totals
Browse files Browse the repository at this point in the history
  • Loading branch information
neb417 committed Nov 16, 2023
1 parent 25a482a commit 35aa50a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 15 deletions.
13 changes: 10 additions & 3 deletions app/controllers/fixed_expenses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ def create

respond_to do |format|
if @fixed_expense.save
@totals = FixedExpense.total_costs
@fixed_expenses = FixedExpense.get_ordered
@total_annual_cost = FixedExpense.total_annual_cost
@total_monthly_cost = FixedExpense.total_monthly_cost
@total_bi_weekly_cost = FixedExpense.total_bi_weekly_cost
@fixed_expenses = FixedExpense.get_ordered
@salary_taxed = Income.tax_on_income(income_type: "Salary")
@hourly_taxed = Income.tax_on_income(income_type: "Hourly")
Expand All @@ -42,7 +45,9 @@ def create
def update
respond_to do |format|
if @fixed_expense.update_from_dashboard(params: params[:fixed_expense])
@totals = FixedExpense.total_costs
@total_annual_cost = FixedExpense.total_annual_cost
@total_monthly_cost = FixedExpense.total_monthly_cost
@total_bi_weekly_cost = FixedExpense.total_bi_weekly_cost
@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." }
Expand All @@ -57,7 +62,9 @@ def update
# DELETE /fixed_expenses/1 or /fixed_expenses/1.json
def destroy
@fixed_expense.destroy
@totals = FixedExpense.total_costs
@total_annual_cost = FixedExpense.total_annual_cost
@total_monthly_cost = FixedExpense.total_monthly_cost
@total_bi_weekly_cost = FixedExpense.total_bi_weekly_cost
@fixed_expenses = FixedExpense.get_ordered
@salary_taxed = Income.tax_on_income(income_type: "Salary")
@hourly_taxed = Income.tax_on_income(income_type: "Hourly")
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/incomes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ 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
@fixed_expenses = FixedExpense.get_ordered
@total_annual_cost = FixedExpense.total_annual_cost
@total_monthly_cost = FixedExpense.total_monthly_cost
@total_bi_weekly_cost = FixedExpense.total_bi_weekly_cost
format.html { redirect_to root_path, notice: "Income was successfully updated." }
format.turbo_stream
else
Expand Down
6 changes: 3 additions & 3 deletions app/views/fixed_expenses/create.turbo_stream.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<% end %>

<%= turbo_stream.replace "total_costs" do %>
<%= render partial: "shared/total_costs", locals: { totals: @totals } %>
<%= render partial: "shared/total_costs", locals: { total_annual_cost: @total_annual_cost, total_monthly_cost: @total_monthly_cost, total_bi_weekly_cost: @total_bi_weekly_cost } %>
<% end %>

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

<%= turbo_stream.replace "hourly_budget" do %>
<%= render partial: "budget/hourly_budget", locals: {totals: @totals, income: @hourly_taxed} %>
<%= render partial: "budget/hourly_budget", locals: {total_annual_cost: @total_annual_cost, total_monthly_cost: @total_monthly_cost, total_bi_weekly_cost: @total_bi_weekly_cost, income: @hourly_taxed} %>
<% end %>
6 changes: 3 additions & 3 deletions app/views/fixed_expenses/destroy.turbo_stream.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<%= turbo_stream.remove @fixed_expense %>

<%= turbo_stream.replace "total_costs" do %>
<%= render partial: "shared/total_costs", locals: { totals: @totals } %>
<%= render partial: "shared/total_costs", locals: { total_annual_cost: @total_annual_cost, total_monthly_cost: @total_monthly_cost, total_bi_weekly_cost: @total_bi_weekly_cost } %>
<% end %>

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

<%= turbo_stream.replace "hourly_budget" do %>
<%= render partial: "budget/hourly_budget", locals: {totals: @totals, income: @hourly_taxed} %>
<%= render partial: "budget/hourly_budget", locals: {total_annual_cost: @total_annual_cost, total_monthly_cost: @total_monthly_cost, total_bi_weekly_cost: @total_bi_weekly_cost, income: @hourly_taxed} %>
<% end %>
6 changes: 3 additions & 3 deletions app/views/fixed_expenses/update.turbo_stream.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<%= turbo_stream.update @fixed_expense %>

<%= turbo_stream.replace "total_costs" do %>
<%= render partial: "shared/total_costs", locals: { totals: @totals } %>
<%= render partial: "shared/total_costs", locals: { total_annual_cost: @total_annual_cost, total_monthly_cost: @total_monthly_cost, total_bi_weekly_cost: @total_bi_weekly_cost } %>
<% end %>

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

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

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

<%= turbo_stream.replace "hourly_budget" do %>
<%= render partial: "budget/hourly_budget", locals: {totals: @totals, income: @hourly_taxed} %>
<%= render partial: "budget/hourly_budget", locals: {total_annual_cost: @total_annual_cost, total_monthly_cost: @total_monthly_cost, total_bi_weekly_cost: @total_bi_weekly_cost, income: @hourly_taxed} %>
<% end %>

0 comments on commit 35aa50a

Please sign in to comment.