Skip to content
Open
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
5 changes: 4 additions & 1 deletion app/models/budget.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ def actual_spending
end

def budget_category_actual_spending(budget_category)
expense_totals.category_totals.find { |ct| ct.category.id == budget_category.category.id }&.total || 0
total_expenses = expense_totals.category_totals.find { |ct| ct.category.id == budget_category.category.id }&.total || 0
total_incomes = income_totals.category_totals.find { |ct| ct.category.id == budget_category.category.id }&.total || 0
total = total_incomes - total_expenses
total.negative? ? total.abs : 0
end

def category_median_monthly_expense(category)
Expand Down