31 lines
908 B
Ruby
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
|