mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-23 07:09:39 +02:00
* Budgeting V1 * Basic UI template * Fully scaffolded budgeting v1 * Basic working budget * Finalize donut chart for budgets * Allow categorization of loan payments for budget * Include loan payments in incomes_and_expenses scope * Add budget allocations progress * Empty states * Clean up budget methods * Category aggregation queries * Handle overage scenarios in form * Finalize budget donut chart controller * Passing tests * Fix allocation naming * Add income category migration * Native support for uncategorized budget category * Formatting * Fix subcategory sort order, padding * Fix calculation for category rollups in budget
35 lines
1.3 KiB
Ruby
35 lines
1.3 KiB
Ruby
class BudgetCategoriesController < ApplicationController
|
|
def index
|
|
@budget = Current.family.budgets.find(params[:budget_id])
|
|
render layout: "wizard"
|
|
end
|
|
|
|
def show
|
|
@budget = Current.family.budgets.find(params[:budget_id])
|
|
|
|
@recent_transactions = @budget.entries
|
|
|
|
if params[:id] == BudgetCategory.uncategorized.id
|
|
@budget_category = @budget.uncategorized_budget_category
|
|
@recent_transactions = @recent_transactions.where(account_transactions: { category_id: nil })
|
|
else
|
|
@budget_category = Current.family.budget_categories.find(params[:id])
|
|
@recent_transactions = @recent_transactions.joins("LEFT JOIN categories ON categories.id = account_transactions.category_id")
|
|
.where("categories.id = ? OR categories.parent_id = ?", @budget_category.category.id, @budget_category.category.id)
|
|
end
|
|
|
|
@recent_transactions = @recent_transactions.order("account_entries.date DESC, ABS(account_entries.amount) DESC").take(3)
|
|
end
|
|
|
|
def update
|
|
@budget_category = Current.family.budget_categories.find(params[:id])
|
|
@budget_category.update!(budget_category_params)
|
|
|
|
redirect_to budget_budget_categories_path(@budget_category.budget)
|
|
end
|
|
|
|
private
|
|
def budget_category_params
|
|
params.require(:budget_category).permit(:budgeted_spending)
|
|
end
|
|
end
|