2025-01-13 20:38:47 +00:00
|
|
|
# Copyright (C) 2024 Manuel Bustillo
|
|
|
|
|
2025-01-13 21:37:02 +01:00
|
|
|
# Copyright (C) 2024-2025 LibreWeddingPlanner contributors
|
2024-12-11 08:03:02 +00:00
|
|
|
|
2024-12-28 18:37:47 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-12-11 09:00:45 +01:00
|
|
|
class SummaryController < ApplicationController
|
|
|
|
def index
|
|
|
|
render json: {
|
2024-12-28 18:28:28 +01:00
|
|
|
expenses:,
|
|
|
|
guests:
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def guests
|
|
|
|
guest_summary = Guest.group(:status).count
|
|
|
|
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
|
def expenses
|
|
|
|
expense_summary = Expenses::TotalQuery.new(wedding: ActsAsTenant.current_tenant).call
|
|
|
|
|
|
|
|
{
|
|
|
|
projected: {
|
|
|
|
total: expense_summary['total_projected'],
|
|
|
|
guests: expense_summary['projected_guests']
|
|
|
|
},
|
|
|
|
confirmed: {
|
|
|
|
total: expense_summary['total_confirmed'],
|
|
|
|
guests: expense_summary['confirmed_guests']
|
2024-12-11 09:00:45 +01:00
|
|
|
},
|
2024-12-28 18:28:28 +01:00
|
|
|
status: {
|
|
|
|
paid: 0
|
2024-12-11 09:00:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|