wedding-planner/app/controllers/expenses_controller.rb
Manuel Bustillo 88a7785b46
All checks were successful
Run unit tests / unit_tests (pull_request) Successful in 4m56s
Check usage of free licenses / build-static-assets (pull_request) Successful in 38s
Add copyright notice / copyright_notice (pull_request) Successful in 1m28s
Define endpoint to update expenses
2024-11-11 08:08:49 +01:00

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