Define an endpoint to expose the list of expenses
All checks were successful
Check usage of free licenses / build-static-assets (pull_request) Successful in 44s
Add copyright notice / copyright_notice (pull_request) Successful in 2m30s
Run unit tests / unit_tests (pull_request) Successful in 6m1s

This commit is contained in:
Manuel Bustillo 2024-11-10 20:40:37 +01:00
parent 8d74d25574
commit 810d0740f3
2 changed files with 5 additions and 1 deletions

View File

@ -4,4 +4,8 @@ class ExpensesController < ApplicationController
def summary def summary
render json: Expenses::TotalQuery.new.call render json: Expenses::TotalQuery.new.call
end end
def index
render json: Expense.all.order(pricing_type: :asc, amount: :desc).as_json(only: %i[id name amount pricing_type])
end
end end

View File

@ -6,7 +6,7 @@ Rails.application.routes.draw do
post :import, on: :collection post :import, on: :collection
post :bulk_update, on: :collection post :bulk_update, on: :collection
end end
resources :expenses do resources :expenses, only: :index do
get :summary, on: :collection get :summary, on: :collection
end end
resources :tables_arrangements, only: [:index, :show] resources :tables_arrangements, only: [:index, :show]