From 35aa50adb195828e2abcc90503628502cc3c0be7 Mon Sep 17 00:00:00 2001 From: "Benjamin Randolphgit config --global user.email neb417@gmail.comgit config --global init.defaultBranch maingit config --global core.editor atom" Date: Thu, 16 Nov 2023 09:47:36 -0700 Subject: [PATCH] Find and replace all @totals --- app/controllers/fixed_expenses_controller.rb | 13 ++++++++++--- app/controllers/incomes_controller.rb | 5 ++++- app/views/fixed_expenses/create.turbo_stream.erb | 6 +++--- app/views/fixed_expenses/destroy.turbo_stream.erb | 6 +++--- app/views/fixed_expenses/update.turbo_stream.erb | 6 +++--- app/views/incomes/update.turbo_stream.erb | 4 ++-- 6 files changed, 25 insertions(+), 15 deletions(-) diff --git a/app/controllers/fixed_expenses_controller.rb b/app/controllers/fixed_expenses_controller.rb index 08c7ba2..859af58 100644 --- a/app/controllers/fixed_expenses_controller.rb +++ b/app/controllers/fixed_expenses_controller.rb @@ -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") @@ -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." } @@ -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") diff --git a/app/controllers/incomes_controller.rb b/app/controllers/incomes_controller.rb index 87d3890..4fb2747 100644 --- a/app/controllers/incomes_controller.rb +++ b/app/controllers/incomes_controller.rb @@ -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 diff --git a/app/views/fixed_expenses/create.turbo_stream.erb b/app/views/fixed_expenses/create.turbo_stream.erb index 65e874d..8a9a854 100644 --- a/app/views/fixed_expenses/create.turbo_stream.erb +++ b/app/views/fixed_expenses/create.turbo_stream.erb @@ -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 %> diff --git a/app/views/fixed_expenses/destroy.turbo_stream.erb b/app/views/fixed_expenses/destroy.turbo_stream.erb index 5562d82..44ec110 100644 --- a/app/views/fixed_expenses/destroy.turbo_stream.erb +++ b/app/views/fixed_expenses/destroy.turbo_stream.erb @@ -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 %> diff --git a/app/views/fixed_expenses/update.turbo_stream.erb b/app/views/fixed_expenses/update.turbo_stream.erb index e9db543..b431b7a 100644 --- a/app/views/fixed_expenses/update.turbo_stream.erb +++ b/app/views/fixed_expenses/update.turbo_stream.erb @@ -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 %> diff --git a/app/views/incomes/update.turbo_stream.erb b/app/views/incomes/update.turbo_stream.erb index d10fb4c..435496e 100644 --- a/app/views/incomes/update.turbo_stream.erb +++ b/app/views/incomes/update.turbo_stream.erb @@ -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 %> \ No newline at end of file