wedding-planner/app/controllers/summary_controller.rb
Manuel Bustillo 4e61ee2f22
All checks were successful
Add copyright notice / copyright_notice (pull_request) Successful in 1m19s
Check usage of free licenses / check-licenses (pull_request) Successful in 1m30s
Run unit tests / unit_tests (pull_request) Successful in 2m5s
Include real data in the guests summary of the dashboard
2024-12-11 23:42:25 +01:00

31 lines
908 B
Ruby

# Copyright (C) 2024 Manuel Bustillo
class SummaryController < ApplicationController
def index
expense_summary = Expenses::TotalQuery.new(wedding: ActsAsTenant.current_tenant).call
guest_summary = Guest.group(:status).count
render json: {
expenses: {
projected: {
total: expense_summary['total_projected'],
guests: expense_summary['projected_guests']
},
confirmed: {
total: expense_summary['total_confirmed'],
guests: expense_summary['confirmed_guests']
},
status: {
paid: 0
}
},
guests: {
total: guest_summary.except('considered').values.sum,
confirmed: guest_summary['confirmed'].to_i,
declined: guest_summary['declined'].to_i,
tentative: guest_summary['tentative'].to_i,
invited: guest_summary['invited'].to_i
}
}
end
end