diff --git a/app/controllers/fixed_expenses_controller.rb b/app/controllers/fixed_expenses_controller.rb index df5ab48..08c7ba2 100644 --- a/app/controllers/fixed_expenses_controller.rb +++ b/app/controllers/fixed_expenses_controller.rb @@ -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 @@ -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 @@ -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 diff --git a/app/controllers/incomes_controller.rb b/app/controllers/incomes_controller.rb index 3eb0a32..1e34b9d 100644 --- a/app/controllers/incomes_controller.rb +++ b/app/controllers/incomes_controller.rb @@ -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 diff --git a/app/views/budget/_budget_headings.html.erb b/app/views/budget/_budget_headings.html.erb new file mode 100644 index 0000000..37b0b33 --- /dev/null +++ b/app/views/budget/_budget_headings.html.erb @@ -0,0 +1,17 @@ +
+
+ Fixed Expense +
+ +
+ Investing +
+ +
+ Savings +
+ +
+ Guilt Free +
+
\ No newline at end of file diff --git a/app/views/budget/_hourly_budget.html.erb b/app/views/budget/_hourly_budget.html.erb new file mode 100644 index 0000000..0627d23 --- /dev/null +++ b/app/views/budget/_hourly_budget.html.erb @@ -0,0 +1,5 @@ +
+ Hourly + <%= render partial: "budget/budget_headings" %> + <%= render partial: "shared/budget", locals: {totals: totals, income: income} %> +
\ No newline at end of file diff --git a/app/views/budget/_salary_budget.html.erb b/app/views/budget/_salary_budget.html.erb new file mode 100644 index 0000000..3538073 --- /dev/null +++ b/app/views/budget/_salary_budget.html.erb @@ -0,0 +1,5 @@ +
+ Salary + <%= render partial: "budget/budget_headings" %> + <%= render partial: "shared/budget", locals: {totals: totals, income: income} %> +
diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb index ccf403f..be41643 100644 --- a/app/views/dashboard/index.html.erb +++ b/app/views/dashboard/index.html.erb @@ -7,6 +7,22 @@
+
+
+
+

Budget

+
+ + <%= 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 %> +
+
+
<%= turbo_frame_tag "income_header_frame" do %> diff --git a/app/views/fixed_expenses/create.turbo_stream.erb b/app/views/fixed_expenses/create.turbo_stream.erb index be4f9b5..65e874d 100644 --- a/app/views/fixed_expenses/create.turbo_stream.erb +++ b/app/views/fixed_expenses/create.turbo_stream.erb @@ -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 %> diff --git a/app/views/fixed_expenses/destroy.turbo_stream.erb b/app/views/fixed_expenses/destroy.turbo_stream.erb index cb802b7..5562d82 100644 --- a/app/views/fixed_expenses/destroy.turbo_stream.erb +++ b/app/views/fixed_expenses/destroy.turbo_stream.erb @@ -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 %> diff --git a/app/views/fixed_expenses/update.turbo_stream.erb b/app/views/fixed_expenses/update.turbo_stream.erb index be14367..e9db543 100644 --- a/app/views/fixed_expenses/update.turbo_stream.erb +++ b/app/views/fixed_expenses/update.turbo_stream.erb @@ -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 %> diff --git a/app/views/incomes/update.turbo_stream.erb b/app/views/incomes/update.turbo_stream.erb index 267360f..d10fb4c 100644 --- a/app/views/incomes/update.turbo_stream.erb +++ b/app/views/incomes/update.turbo_stream.erb @@ -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 %> \ No newline at end of file diff --git a/app/views/shared/_budget.html.erb b/app/views/shared/_budget.html.erb new file mode 100644 index 0000000..41f6b0b --- /dev/null +++ b/app/views/shared/_budget.html.erb @@ -0,0 +1,60 @@ +
+
Daily
+ <%= render partial: "shared/total", locals: { total: totals.total_annual_cost / 365 } %> +
0
+
0
+
+ <%= humanized_money_with_symbol((income.total_net_income.fractional / 100) / 365 - totals.total_annual_cost / 365) %> +
+
+ +
+
Weekly
+ <%= render partial: "shared/total", locals: { total: totals.total_bi_weekly_cost / 2 } %> +
0
+
0
+
+ <%= humanized_money_with_symbol((income.bi_weekly_net_income.fractional / 100) / 2 - totals.total_bi_weekly_cost / 2) %> +
+
+ +
+
Bi-Weekly
+ <%= render partial: "shared/total", locals: { total: totals.total_bi_weekly_cost } %> +
0
+
0
+
+ <%= humanized_money_with_symbol((income.bi_weekly_net_income.fractional / 100) - totals.total_bi_weekly_cost) %> +
+
+ +
+
Monthly
+ <%= render partial: "shared/total", locals: { total: totals.total_monthly_cost } %> +
0
+
0
+
+ <%= humanized_money_with_symbol((income.total_net_income.fractional / 100) / 12 - totals.total_monthly_cost) %> +
+
+ +
+
Quarterly
+ <%= render partial: "shared/total", locals: { total: totals.total_annual_cost / 4 } %> +
0
+
0
+
+ <%= humanized_money_with_symbol((income.total_net_income.fractional / 100.0) / 4 - totals.total_annual_cost / 4) %> +
+
+ +
+
Annually
+ <%= render partial: "shared/total", locals: { total: totals.total_annual_cost } %> + +
0
+
0
+
+ <%= humanized_money_with_symbol(income.total_net_income.fractional.to_f / 100 - totals.total_annual_cost) %> +
+
diff --git a/app/views/shared/_total.html.erb b/app/views/shared/_total.html.erb index fa5ff61..b7c0e0c 100644 --- a/app/views/shared/_total.html.erb +++ b/app/views/shared/_total.html.erb @@ -1,3 +1,3 @@
- <%= humanized_money_with_symbol(total) %> + <%= humanized_money_with_symbol(total) %>
\ No newline at end of file diff --git a/app/views/shared/_total_costs.html.erb b/app/views/shared/_total_costs.html.erb index fa125f7..1c28898 100644 --- a/app/views/shared/_total_costs.html.erb +++ b/app/views/shared/_total_costs.html.erb @@ -4,14 +4,20 @@
- <%= render partial: "shared/total", locals: { total: @totals.total_annual_cost } %> + + <%= render partial: "shared/total", locals: { total: @totals.total_annual_cost } %> +
- <%= render partial: "shared/total", locals: { total: @totals.total_monthly_cost } %> + + <%= render partial: "shared/total", locals: { total: @totals.total_monthly_cost } %> +
- <%= render partial: "shared/total", locals: { total: @totals.total_bi_weekly_cost } %> + + <%= render partial: "shared/total", locals: { total: @totals.total_bi_weekly_cost } %> +