23 lines
507 B
Ruby
23 lines
507 B
Ruby
# Copyright (C) 2024 Manuel Bustillo
|
|
|
|
class ExpensesController < ApplicationController
|
|
def summary
|
|
render json: Expenses::TotalQuery.new.call
|
|
end
|
|
|
|
def index
|
|
render json: Expense.all.order(pricing_type: :asc, amount: :desc).as_json(only: %i[id name amount pricing_type])
|
|
end
|
|
|
|
def update
|
|
Expense.find(params[:id]).update!(expense_params)
|
|
render json: {}, status: :ok
|
|
end
|
|
|
|
private
|
|
|
|
def expense_params
|
|
params.require(:expense).permit(:name, :amount, :pricing_type)
|
|
end
|
|
end
|