diff --git a/app/assets/stylesheets/application.tailwind.css b/app/assets/stylesheets/application.tailwind.css
index 2d19c26..3f7b012 100644
--- a/app/assets/stylesheets/application.tailwind.css
+++ b/app/assets/stylesheets/application.tailwind.css
@@ -11,6 +11,10 @@
@apply rounded-lg px-4 bg-red-600 inline-block font-medium text-white;
}
+ .btn-secondary {
+ @apply rounded-lg px-4 bg-blue-600 inline-block font-medium text-white;
+ }
+
h1 {
@apply text-3xl font-bold tracking-tight text-gray-800
}
diff --git a/app/controllers/concerns/dashboard_builder.rb b/app/controllers/concerns/dashboard_builder.rb
new file mode 100644
index 0000000..b387e7f
--- /dev/null
+++ b/app/controllers/concerns/dashboard_builder.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+module DashboardBuilder
+ include TaxedIncome
+ include TotalCost
+
+ def build_dashboard_variables!
+ @incomes = Income.order_by_type
+ @fixed_expenses = FixedExpense.get_ordered
+ build_taxed_income_vars!
+ build_total_cost_vars!
+ end
+end
diff --git a/app/controllers/concerns/taxed_income.rb b/app/controllers/concerns/taxed_income.rb
new file mode 100644
index 0000000..cab2c8a
--- /dev/null
+++ b/app/controllers/concerns/taxed_income.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+module TaxedIncome
+ def tax_on_salary
+ income = Income.find_by(income_type: "Salary")
+ Rails.logger.debug "**** Tax Salary: #{income.inspect}"
+ IncomeTaxCalculatorService.new(income: income)
+ end
+
+ def tax_on_hourly
+ income = Income.find_by(income_type: "Hourly")
+ IncomeTaxCalculatorService.new(income: income)
+ end
+
+ def build_taxed_income_vars!
+ @salary_taxed = tax_on_salary
+ @hourly_taxed = tax_on_hourly
+ end
+end
diff --git a/app/controllers/concerns/total_cost.rb b/app/controllers/concerns/total_cost.rb
new file mode 100644
index 0000000..003e2f9
--- /dev/null
+++ b/app/controllers/concerns/total_cost.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+module TotalCost
+ def total_annual_cost
+ Money.new(get_sum(:annual_cost_cents))
+ end
+
+ def total_monthly_cost
+ Money.new(get_sum(:monthly_cost_cents))
+ end
+
+ def total_bi_weekly_cost
+ Money.new(get_sum(:bi_weekly_cost_cents))
+ end
+
+ def build_total_cost_vars!
+ @total_annual_cost = total_annual_cost
+ @total_monthly_cost = total_monthly_cost
+ @total_bi_weekly_cost = total_bi_weekly_cost
+ end
+
+ private
+
+ def get_sum(time_period)
+ FixedExpense.sum(&time_period)
+ end
+end
diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb
index 5c20825..d069d72 100644
--- a/app/controllers/dashboard_controller.rb
+++ b/app/controllers/dashboard_controller.rb
@@ -1,10 +1,7 @@
class DashboardController < ApplicationController
+ include DashboardBuilder
+
def index
- @incomes = Income.order_by_type
- @fixed_expenses = FixedExpense.get_ordered
- @totals = FixedExpense.total_costs
- @federal_tax_brackets = FederalTaxBracket.order_by_range
- @salary_taxed = Income.tax_on_income(income_type: "Salary")
- @hourly_taxed = Income.tax_on_income(income_type: "Hourly")
+ build_dashboard_variables!
end
end
diff --git a/app/controllers/fixed_expenses_controller.rb b/app/controllers/fixed_expenses_controller.rb
index 08c7ba2..37e7367 100644
--- a/app/controllers/fixed_expenses_controller.rb
+++ b/app/controllers/fixed_expenses_controller.rb
@@ -1,4 +1,6 @@
class FixedExpensesController < ApplicationController
+ include DashboardBuilder
+
before_action :set_fixed_expense, only: %i[show edit update destroy]
# GET /fixed_expenses or /fixed_expenses.json
@@ -25,10 +27,7 @@ def create
respond_to do |format|
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")
+ build_dashboard_variables!
format.html { redirect_to root_path, notice: "Fixed expense was successfully created." }
format.turbo_stream
else
@@ -42,9 +41,7 @@ def create
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")
+ build_dashboard_variables!
format.html { redirect_to root_path, notice: "Fixed expense was successfully updated." }
format.turbo_stream
else
@@ -57,10 +54,8 @@ def update
# DELETE /fixed_expenses/1 or /fixed_expenses/1.json
def destroy
@fixed_expense.destroy
- @totals = FixedExpense.total_costs
+ build_dashboard_variables!
@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
diff --git a/app/controllers/incomes_controller.rb b/app/controllers/incomes_controller.rb
index 28c4486..aab5e66 100644
--- a/app/controllers/incomes_controller.rb
+++ b/app/controllers/incomes_controller.rb
@@ -1,4 +1,7 @@
class IncomesController < ApplicationController
+ include DashboardBuilder
+ include TotalCost
+
before_action :set_income, only: %i[show edit update destroy]
# GET /incomes or /incomes.json
@@ -38,9 +41,7 @@ def create
def update
respond_to do |format|
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
+ build_dashboard_variables!
format.html { redirect_to root_path, notice: "Income was successfully updated." }
format.turbo_stream
else
@@ -61,31 +62,20 @@ def destroy
end
def income_switch
- totals = FixedExpense.total_costs
if params[:enabled] == "0"
- salary = Income.tax_on_income(income_type: "Salary")
-
respond_to do |format|
format.turbo_stream {
render turbo_stream: turbo_stream.replace("hourly_budget",
partial: "budget/salary_budget",
- locals: {
- totals: totals,
- income: salary
- })
+ locals: build_locals(tax_on_salary))
}
end
else
- hourly = Income.tax_on_income(income_type: "Hourly")
-
respond_to do |format|
format.turbo_stream {
render turbo_stream: turbo_stream.replace("salary_budget",
partial: "budget/hourly_budget",
- locals: {
- totals: totals,
- income: hourly
- })
+ locals: build_locals(tax_on_hourly))
}
end
end
@@ -102,4 +92,14 @@ def set_income
def income_params
params.require(:income).permit(:income_type, :rate, :hours, :weekly_income)
end
+
+ def build_locals(income)
+ build_total_cost_vars!
+ {
+ total_annual_cost: @total_annual_cost,
+ total_monthly_cost: @total_monthly_cost,
+ total_bi_weekly_cost: @total_bi_weekly_cost,
+ income: income
+ }
+ end
end
diff --git a/app/models/fixed_expense.rb b/app/models/fixed_expense.rb
index cf1cbfc..4527a37 100644
--- a/app/models/fixed_expense.rb
+++ b/app/models/fixed_expense.rb
@@ -18,6 +18,8 @@ class FixedExpense < ApplicationRecord
monetize :monthly_cost_cents
monetize :bi_weekly_cost_cents
+ scope :get_ordered, -> { order(annual_cost_cents: :desc) }
+
def self.new_from_dashboard(params:)
expense = params[:fixed_expense]
amount = (expense[:amount].to_f * 100).to_i
@@ -63,16 +65,4 @@ def update_from_dashboard(params:)
false
end
end
-
- def self.total_costs
- OpenStruct.new(
- total_annual_cost: sum(&:annual_cost_cents).to_f / 100,
- total_monthly_cost: sum(&:monthly_cost_cents).to_f / 100,
- total_bi_weekly_cost: sum(&:bi_weekly_cost_cents).to_f / 100
- )
- end
-
- def self.get_ordered
- all.order(annual_cost_cents: :desc)
- end
end
diff --git a/app/models/income.rb b/app/models/income.rb
index fa69c73..ecc52dd 100644
--- a/app/models/income.rb
+++ b/app/models/income.rb
@@ -16,6 +16,8 @@ class Income < ApplicationRecord
monetize :rate_cents
monetize :weekly_income_cents
+ scope :order_by_type, -> { order(income_type: :desc) }
+
def update_from_dashboard(params:)
income = params[:income]
income_type_passed = income[:income_type]
@@ -40,10 +42,6 @@ def update_from_dashboard(params:)
end
end
- def self.order_by_type
- Income.all.order(income_type: :desc)
- end
-
def is_hourly?
income_type == "Hourly"
end
@@ -51,11 +49,4 @@ def is_hourly?
def is_salary?
income_type == "Salary"
end
-
- def self.tax_on_income(income_type:)
- income = Income.find_by(income_type: income_type)
- taxable_income = IncomeTaxCalculator.new(income: income)
- taxable_income.calculate_taxes
- taxable_income
- end
end
diff --git a/app/poros/income_tax_calculator.rb b/app/services/income_tax_calculator_service.rb
similarity index 55%
rename from app/poros/income_tax_calculator.rb
rename to app/services/income_tax_calculator_service.rb
index 0a1f112..e98be81 100644
--- a/app/poros/income_tax_calculator.rb
+++ b/app/services/income_tax_calculator_service.rb
@@ -1,4 +1,4 @@
-class IncomeTaxCalculator
+class IncomeTaxCalculatorService
attr_reader :income,
:annual_income,
:federal_tax,
@@ -14,20 +14,7 @@ class IncomeTaxCalculator
def initialize(income:)
@income = income
- @annual_income = income.weekly_income_cents * 52
- @federal_tax = nil
- @net_after_fed_tax = nil
- @state_tax = nil
- @total_net_income = nil
- @bi_weekly_net_income = nil
- @daily_income = nil
- @weekly_income = nil
- @monthly_income = nil
- @quarterly_income = nil
- @biannual_income = nil
- end
-
- def calculate_taxes
+ @annual_income = income.weekly_income * 52
@federal_tax = calculate_fed_tax
@net_after_fed_tax = calculate_net_after_fed_tax
@state_tax = calculate_state_tax
@@ -43,45 +30,44 @@ def calculate_taxes
private
def calculate_fed_tax
- bracket = FederalTaxBracket.where("bottom_range_cents <= ?", @annual_income).order(:bottom_range_cents).last
+ bracket = FederalTaxBracket.where("bottom_range_cents <= ?", @annual_income.cents).order(:bottom_range_cents).last
rated = bracket.rate * @annual_income
- Money.new(rated + bracket.cumulative_cents, "USD")
+ rated + bracket.cumulative
end
def calculate_state_tax
- state_tax = (@net_after_fed_tax.fractional * 0.0463).to_i
- Money.new(state_tax, "USD")
+ @net_after_fed_tax * 0.0463
end
def calculate_net_after_fed_tax
- Money.new(@annual_income - @federal_tax.fractional, "USD")
+ @annual_income - @federal_tax
end
def calculate_total_net_income
- Money.new(@net_after_fed_tax.fractional - @state_tax.fractional, "USD")
+ @net_after_fed_tax - @state_tax
end
def calculate_bi_weekly_income
- Money.new(@total_net_income.fractional / 26)
+ @total_net_income / 26
end
def calculate_daily_income
- Money.new(@total_net_income.fractional / 365)
+ @total_net_income / 365
end
def calculate_weekly_income
- Money.new(@total_net_income.fractional / 52)
+ @total_net_income / 52
end
def calculate_monthly_income
- Money.new(@total_net_income.fractional / 12)
+ @total_net_income / 12
end
def calculate_quarterly_income
- Money.new(@total_net_income.fractional / 4)
+ @total_net_income / 4
end
def calculate_biannual_income
- Money.new(@total_net_income.fractional / 2)
+ @total_net_income / 2
end
end
diff --git a/app/views/budget/_hourly_budget.html.erb b/app/views/budget/_hourly_budget.html.erb
index f369823..9d9007d 100644
--- a/app/views/budget/_hourly_budget.html.erb
+++ b/app/views/budget/_hourly_budget.html.erb
@@ -2,6 +2,6 @@
Hourly
<%= render partial: "budget/budget_headings" %>
- <%= render partial: "shared/budget", locals: {totals: totals, income: income} %>
+ <%= render partial: "shared/budget", locals: { total_annual_cost: total_annual_cost, total_monthly_cost: total_monthly_cost, total_bi_weekly_cost: total_bi_weekly_cost, income: income } %>
<% end %>
\ No newline at end of file
diff --git a/app/views/budget/_salary_budget.html.erb b/app/views/budget/_salary_budget.html.erb
index 1f4ee0f..939cc68 100644
--- a/app/views/budget/_salary_budget.html.erb
+++ b/app/views/budget/_salary_budget.html.erb
@@ -2,6 +2,6 @@
Salary
<%= render partial: "budget/budget_headings" %>
- <%= render partial: "shared/budget", locals: {totals: totals, income: income} %>
+ <%= render partial: "shared/budget", locals: { total_annual_cost: total_annual_cost, total_monthly_cost: total_monthly_cost, total_bi_weekly_cost: total_bi_weekly_cost, income: income } %>
<% end %>
diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb
index b5014d5..cf1aac1 100644
--- a/app/views/dashboard/index.html.erb
+++ b/app/views/dashboard/index.html.erb
@@ -12,7 +12,7 @@
<%= render partial: "components/income_switch" %>
- <%= 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 } %>
@@ -50,7 +50,7 @@
<% end %>
<%= turbo_frame_tag "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 %>
diff --git a/app/views/federal_tax_brackets/_form.html.erb b/app/views/federal_tax_brackets/_form.html.erb
index 48ed016..eea5af6 100644
--- a/app/views/federal_tax_brackets/_form.html.erb
+++ b/app/views/federal_tax_brackets/_form.html.erb
@@ -37,10 +37,10 @@
- <%= form.submit class: "rounded-lg py-1 px-4 bg-gray-100 inline-block font-medium" %>
+ <%= form.submit class: "btn btn-primary" %>
- <%= link_to "Cancel", fixed_expenses_path, class: "rounded-lg py-1 px-4 bg-gray-100 inline-block font-medium" %>
+ <%= link_to "Cancel", fixed_expenses_path, class: "btn btn-secondary" %>
<% end %>
diff --git a/app/views/fixed_expenses/_form.html.erb b/app/views/fixed_expenses/_form.html.erb
index 1bbf74f..c9646ef 100644
--- a/app/views/fixed_expenses/_form.html.erb
+++ b/app/views/fixed_expenses/_form.html.erb
@@ -35,10 +35,10 @@
- <%= form.submit class: "rounded-lg py-1 px-4 bg-gray-100 inline-block font-medium" %>
+ <%= form.submit class: "btn btn-primary" %>
- <%= link_to "Cancel", root_path, class: "rounded-lg py-1 px-4 bg-gray-100 inline-block font-medium", data:{ turbo_frame: :fixed_expenses } %>
+ <%= link_to "Cancel", root_path, class: "btn btn-secondary", data:{ turbo_frame: :fixed_expenses } %>
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/_form.html.erb b/app/views/incomes/_form.html.erb
index 9c53ff6..9d0da47 100644
--- a/app/views/incomes/_form.html.erb
+++ b/app/views/incomes/_form.html.erb
@@ -34,10 +34,10 @@
- <%= form.submit class: "rounded-lg px-2 bg-gray-100 inline-block font-medium" %>
+ <%= form.submit class: "btn btn-primary" %>
- <%= link_to "Cancel", root_path, class: "rounded-lg px-2 bg-gray-100 inline-block font-medium" %>
+ <%= link_to "Cancel", root_path, class: "btn btn-secondary" %>
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
diff --git a/app/views/shared/_budget.html.erb b/app/views/shared/_budget.html.erb
index 96fb5b9..7a1eb2a 100644
--- a/app/views/shared/_budget.html.erb
+++ b/app/views/shared/_budget.html.erb
@@ -1,70 +1,70 @@
Daily
- <%= render partial: "shared/total", locals: { total: totals.total_annual_cost / 365 } %>
+ <%= render partial: "shared/total", locals: { total: total_annual_cost / 365 } %>
0
0
- <%= humanized_money_with_symbol((income.daily_income.fractional / 100) - totals.total_annual_cost / 365) %>
+ <%= humanized_money_with_symbol((income.daily_income) - total_annual_cost / 365) %>
Weekly
- <%= render partial: "shared/total", locals: { total: totals.total_bi_weekly_cost / 2 } %>
+ <%= render partial: "shared/total", locals: { total: total_annual_cost / 52 } %>
0
0
- <%= humanized_money_with_symbol((income.weekly_income.fractional / 100) - totals.total_bi_weekly_cost / 2) %>
+ <%= humanized_money_with_symbol((income.weekly_income) - total_annual_cost / 52) %>
Bi-Weekly
- <%= render partial: "shared/total", locals: { total: totals.total_bi_weekly_cost } %>
+ <%= render partial: "shared/total", locals: { total: total_bi_weekly_cost } %>
0
0
- <%= humanized_money_with_symbol((income.bi_weekly_net_income.fractional / 100) - totals.total_bi_weekly_cost) %>
+ <%= humanized_money_with_symbol((income.bi_weekly_net_income) - total_bi_weekly_cost) %>
Monthly
- <%= render partial: "shared/total", locals: { total: totals.total_monthly_cost } %>
+ <%= render partial: "shared/total", locals: { total: total_monthly_cost } %>
0
0
- <%= humanized_money_with_symbol((income.monthly_income.fractional / 100) - totals.total_monthly_cost) %>
+ <%= humanized_money_with_symbol((income.monthly_income) - total_monthly_cost) %>
Quarterly
- <%= render partial: "shared/total", locals: { total: totals.total_annual_cost / 4 } %>
+ <%= render partial: "shared/total", locals: { total: total_annual_cost / 4 } %>
0
0
- <%= humanized_money_with_symbol((income.quarterly_income.fractional / 100.0) - totals.total_annual_cost / 4) %>
+ <%= humanized_money_with_symbol((income.quarterly_income) - total_annual_cost / 4) %>
Biannual
- <%= render partial: "shared/total", locals: { total: totals.total_annual_cost / 4 } %>
+ <%= render partial: "shared/total", locals: { total: total_annual_cost / 2 } %>
0
0
- <%= humanized_money_with_symbol((income.biannual_income.fractional / 100.0) - totals.total_annual_cost / 4) %>
+ <%= humanized_money_with_symbol((income.biannual_income) - total_annual_cost / 2) %>
Annually
- <%= render partial: "shared/total", locals: { total: totals.total_annual_cost } %>
+ <%= render partial: "shared/total", locals: { total: total_annual_cost } %>
0
0
- <%= humanized_money_with_symbol(income.total_net_income.fractional.to_f / 100 - totals.total_annual_cost) %>
+ <%= humanized_money_with_symbol(income.total_net_income - total_annual_cost ) %>
diff --git a/app/views/shared/_total_costs.html.erb b/app/views/shared/_total_costs.html.erb
index 95b24aa..7ba865a 100644
--- a/app/views/shared/_total_costs.html.erb
+++ b/app/views/shared/_total_costs.html.erb
@@ -5,19 +5,19 @@
- <%= render partial: "shared/total", locals: { total: @totals.total_annual_cost } %>
+ <%= render partial: "shared/total", locals: { total: total_annual_cost } %>
- <%= render partial: "shared/total", locals: { total: @totals.total_monthly_cost } %>
+ <%= render partial: "shared/total", locals: { total: total_monthly_cost } %>
- <%= render partial: "shared/total", locals: { total: @totals.total_bi_weekly_cost } %>
+ <%= render partial: "shared/total", locals: { total: total_bi_weekly_cost } %>