# Copyright (C) 2024-2025 LibreWeddingPlanner contributors # frozen_string_literal: true class ExpensesController < ApplicationController def summary render json: Expenses::TotalQuery.new.call end def index render json: Expense.order(pricing_type: :asc, amount: :desc).as_json(only: %i[id name amount pricing_type]) end def create Expense.create!(expense_params) render json: {}, status: :created end def update Expense.find(params[:id]).update!(expense_params) render json: {}, status: :ok end def destroy Expense.find(params[:id]).destroy! render json: {}, status: :ok end private def expense_params params.require(:expense).permit(:name, :amount, :pricing_type) end end