diff --git a/app/controllers/concerns/dashboard_builder.rb b/app/controllers/concerns/dashboard_builder.rb index 6b7358a..61c6a4d 100644 --- a/app/controllers/concerns/dashboard_builder.rb +++ b/app/controllers/concerns/dashboard_builder.rb @@ -19,13 +19,12 @@ def build_dashboard_variables! end def build_locals(taxed_income) - income = taxed_income.income { - income: taxed_income, + total_cost: @total_cost, - investing_amount: income.is_hourly? ? @hourly_invest : @salary_invest, - savings_amount: income.is_hourly? ? @hourly_saving : @salary_saving, - guilt_free: income.is_hourly? ? @guilt_free_hourly : @guilt_free_salary + investing_amount: taxed_income.is_hourly? ? @hourly_invest : @salary_invest, + savings_amount: taxed_income.is_hourly? ? @hourly_saving : @salary_saving, + guilt_free: taxed_income.is_hourly? ? @guilt_free_hourly : @guilt_free_salary } end end diff --git a/app/controllers/concerns/stream.rb b/app/controllers/concerns/stream.rb index 8ecb8d0..40de2e8 100644 --- a/app/controllers/concerns/stream.rb +++ b/app/controllers/concerns/stream.rb @@ -16,7 +16,7 @@ def switch_to_hourly [ turbo_stream.replace("salary_budget", partial: "budget/hourly_budget", - locals: build_locals(tax_on_hourly)) + locals: build_locals(hourly_income)) ] end @@ -24,7 +24,7 @@ def switch_to_salary [ turbo_stream.replace("hourly_budget", partial: "budget/salary_budget", - locals: build_locals(tax_on_salary)) + locals: build_locals(salary_income)) ] end diff --git a/app/controllers/concerns/taxed_income.rb b/app/controllers/concerns/taxed_income.rb index d577c7b..191aaa8 100644 --- a/app/controllers/concerns/taxed_income.rb +++ b/app/controllers/concerns/taxed_income.rb @@ -9,11 +9,11 @@ def build_income_tax_variables! end def salary_income - @salary_income = Income.find_by(income_type: "Salary").weekly_income * 52 + @salary_income = Income.find_by(income_type: "Salary") end def hourly_income - @hourly_income = Income.find_by(income_type: "Hourly").weekly_income * 52 + @hourly_income = Income.find_by(income_type: "Hourly") end def federal_tax_table_type_id @@ -22,10 +22,11 @@ def federal_tax_table_type_id end def build_income_tax_object(income:) - federal_tax = FederalTaxCalculator.call(income: income, federal_tax_table_type_id: federal_tax_table_type_id) - fica_tax = FicaTaxCalculator.call(income: income) - state_tax = StateTaxCalculator.call(income: income) - net_income = income - (fica_tax + federal_tax + state_tax) + annual_income = income.weekly_income * 52 + federal_tax = FederalTaxCalculator.call(income: annual_income, federal_tax_table_type_id: federal_tax_table_type_id) + fica_tax = FicaTaxCalculator.call(income: annual_income) + state_tax = StateTaxCalculator.call(income: annual_income) + net_income = annual_income - (fica_tax + federal_tax + state_tax) OpenStruct.new(federal_tax: federal_tax, fica_tax: fica_tax, state_tax: state_tax, net_income: net_income) end end diff --git a/app/views/budget/_hourly_budget.html.erb b/app/views/budget/_hourly_budget.html.erb index 1f0e91f..50bd99e 100644 --- a/app/views/budget/_hourly_budget.html.erb +++ b/app/views/budget/_hourly_budget.html.erb @@ -5,7 +5,6 @@ <%= render partial: "budget/budget_headings" %> <%= render partial: "shared/budget", locals: { - income: income, total_cost: total_cost, investing_amount: investing_amount, savings_amount: savings_amount, diff --git a/app/views/budget/_salary_budget.html.erb b/app/views/budget/_salary_budget.html.erb index 8ace22f..5bb6eb6 100644 --- a/app/views/budget/_salary_budget.html.erb +++ b/app/views/budget/_salary_budget.html.erb @@ -4,7 +4,6 @@ <%= render partial: "budget/budget_headings" %> <%= render partial: "shared/budget", locals: { - income: income, total_cost: total_cost, investing_amount: investing_amount, savings_amount: savings_amount,