Define an endpoint to expose the list of expenses #116

Merged
bustikiller merged 1 commits from expenses-list-endpoints into main 2024-11-11 06:50:19 +00:00
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]