Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor budget view into partial #21

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/views/budget/_budget_headings.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
</div>

<div class="py-4 col-1">
Investing
Savings
</div>

<div class="py-4 col-1">
Savings
Investing
</div>

<div class="py-4 col-1">
Expand Down
10 changes: 10 additions & 0 deletions app/views/budget/_display_budget.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<%= render partial: "shared/total", locals: { total: total_cost } %>
<div>
<%= humanized_money_with_symbol(savings_amount) %>
</div>
<div>
<%= humanized_money_with_symbol(investing_amount) %>
</div>
<div>
<%= humanized_money_with_symbol(guilt_free) %>
</div>
1 change: 0 additions & 1 deletion app/views/budget/_salary_budget.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<div id="salary_budget" class="py-4">
<strong>Salary</strong>
<%= render partial: "budget/budget_headings" %>
<% Rails.logger.debug "*** Salary_budget #{savings_amount.daily_saving}" %>
<%= render partial: "shared/budget",
locals: {
total_annual_cost: total_annual_cost,
Expand Down
108 changes: 62 additions & 46 deletions app/views/shared/_budget.html.erb
Original file line number Diff line number Diff line change
@@ -1,75 +1,91 @@
<div class="grid grid-cols-5">
<div>Daily</div>

<%= render partial: "shared/total", locals: { total: total_annual_cost / 365 } %>
<div>
<%= humanized_money_with_symbol(investing_amount.daily_saving) %>
</div>
<div>
<%= humanized_money_with_symbol(savings_amount.daily_saving) %>
</div>
<div>
<%= humanized_money_with_symbol((guilt_free.daily_guilt_free) - total_annual_cost / 365) %>
</div>
<%= render partial: "budget/display_budget",
locals: {
total_cost: total_annual_cost/365,
savings_amount: savings_amount.daily_saving,
investing_amount: investing_amount.daily_saving,
guilt_free: guilt_free.daily_guilt_free - total_annual_cost/365
}
%>
</div>

<div class="grid grid-cols-5">
<div>Weekly</div>
<%= render partial: "shared/total", locals: { total: total_annual_cost / 52 } %>
<div><%= humanized_money_with_symbol(investing_amount.weekly_saving) %></div>
<div><%= humanized_money_with_symbol(savings_amount.weekly_saving) %></div>
<div>
<%= humanized_money_with_symbol((guilt_free.weekly_guilt_free) - total_annual_cost / 52) %>
</div>

<%= render partial: "budget/display_budget",
locals: {
total_cost: total_annual_cost/52,
savings_amount: savings_amount.weekly_saving,
investing_amount: investing_amount.weekly_saving,
guilt_free: guilt_free.weekly_guilt_free - total_annual_cost/52
}
%>
</div>

<div class="grid grid-cols-5">
<div>Bi-Weekly</div>
<%= render partial: "shared/total", locals: { total: total_bi_weekly_cost } %>
<div><%= humanized_money_with_symbol(investing_amount.bi_weekly_saving) %></div>
<div><%= humanized_money_with_symbol(savings_amount.bi_weekly_saving) %></div>
<div>
<%= humanized_money_with_symbol((guilt_free.bi_weekly_guilt_free) - total_bi_weekly_cost) %>
</div>

<%= render partial: "budget/display_budget",
locals: {
total_cost: total_bi_weekly_cost,
savings_amount: savings_amount.bi_weekly_saving,
investing_amount: investing_amount.bi_weekly_saving,
guilt_free: guilt_free.bi_weekly_guilt_free - total_bi_weekly_cost
}
%>

</div>

<div class="grid grid-cols-5">
<div>Monthly</div>
<%= render partial: "shared/total", locals: { total: total_monthly_cost } %>
<div><%= humanized_money_with_symbol(investing_amount.monthly_saving) %></div>
<div><%= humanized_money_with_symbol(savings_amount.monthly_saving) %></div>
<div>
<%= humanized_money_with_symbol((guilt_free.monthly_guilt_free) - total_monthly_cost) %>
</div>

<%= render partial: "budget/display_budget",
locals: {
total_cost: total_monthly_cost,
savings_amount: savings_amount.monthly_saving,
investing_amount: investing_amount.monthly_saving,
guilt_free: guilt_free.monthly_guilt_free - total_monthly_cost
}
%>
</div>

<div class="grid grid-cols-5">
<div>Quarterly</div>
<%= render partial: "shared/total", locals: { total: total_annual_cost / 4 } %>
<div><%= humanized_money_with_symbol(investing_amount.quarterly_saving) %></div>
<div><%= humanized_money_with_symbol(savings_amount.quarterly_saving) %></div>
<div>
<%= humanized_money_with_symbol((guilt_free.quarterly_guilt_free) - total_annual_cost / 4) %>
</div>

<%= render partial: "budget/display_budget",
locals: {
total_cost: total_annual_cost/4,
savings_amount: savings_amount.quarterly_saving,
investing_amount: investing_amount.quarterly_saving,
guilt_free: guilt_free.quarterly_guilt_free - total_annual_cost / 4
}
%>
</div>

<div class="grid grid-cols-5">
<div>Biannual</div>
<%= render partial: "shared/total", locals: { total: total_annual_cost / 2 } %>
<div><%= humanized_money_with_symbol(investing_amount.biannual_saving) %></div>
<div><%= humanized_money_with_symbol(savings_amount.biannual_saving) %></div>
<div>
<%= humanized_money_with_symbol((guilt_free.biannual_guilt_free) - total_annual_cost / 2) %>
</div>

<%= render partial: "budget/display_budget",
locals: {
total_cost: total_annual_cost/2,
savings_amount: savings_amount.biannual_saving,
investing_amount: investing_amount.biannual_saving,
guilt_free: guilt_free.biannual_guilt_free - total_annual_cost / 2
}
%>
</div>

<div class="grid grid-cols-5">
<div>Annually</div>
<%= render partial: "shared/total", locals: { total: total_annual_cost } %>

<div><%= humanized_money_with_symbol(investing_amount.annual_saving) %></div>
<div><%= humanized_money_with_symbol(savings_amount.annual_saving) %></div>
<div>
<%= humanized_money_with_symbol(guilt_free.annual_guilt_free - total_annual_cost ) %>
</div>
<%= render partial: "budget/display_budget",
locals: {
total_cost: total_annual_cost,
savings_amount: savings_amount.annual_saving,
investing_amount: investing_amount.annual_saving,
guilt_free: guilt_free.annual_guilt_free - total_annual_cost
}
%>
</div>