mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 12:04:08 +00:00
fix: subcategories are not properly handled for budget allocations (#1844)
* fix: `allocated_spending` logic * fix: subcategories exceeding parent limit * refactor: budget allocations and max allocation logic * feat: add stream for budget category form validation * feat: update uncategorized value via stream, refactor confirm button with stream * fix: ensure live updates for parent & sibling budgets in Turbo Stream * fix: lint issues
This commit is contained in:
@@ -133,10 +133,10 @@ class Budget < ApplicationRecord
|
||||
end
|
||||
|
||||
# =============================================================================
|
||||
# Budget allocations: How much user has budgeted for all categories combined
|
||||
# Budget allocations: How much user has budgeted for all parent categories combined
|
||||
# =============================================================================
|
||||
def allocated_spending
|
||||
budget_categories.sum(:budgeted_spending)
|
||||
budget_categories.reject { |bc| bc.subcategory? }.sum(&:budgeted_spending)
|
||||
end
|
||||
|
||||
def allocated_percent
|
||||
|
||||
Reference in New Issue
Block a user