diff --git a/app/frontend/src/javascript/controllers/admin/events.js b/app/frontend/src/javascript/controllers/admin/events.js
index e14bc2173..ff1162224 100644
--- a/app/frontend/src/javascript/controllers/admin/events.js
+++ b/app/frontend/src/javascript/controllers/admin/events.js
@@ -494,7 +494,11 @@ Application.Controllers.controller('ShowEventReservationsController', ['$scope',
items: [{
reservation: {
...reservation,
- slots_reservations_attributes: reservation.slots_reservations_attributes.map(sr => ({ slot_id: sr.slot_id }))
+ slots_reservations_attributes: reservation.slots_reservations_attributes.map(sr => ({ slot_id: sr.slot_id })),
+ tickets_attributes: reservation.tickets_attributes.map(t => ({ booked: t.booked, event_price_category_id: t.event_price_category.id })),
+ booking_users_attributes: reservation.booking_users_attributes.map(bu => (
+ { name: bu.name, event_price_category_id: bu.event_price_category_id, booked_id: bu.booked_id, booked_type: bu.booked_type }
+ ))
}
}],
coupon_code: ((coupon ? coupon.code : undefined)),
diff --git a/app/frontend/templates/admin/events/monitoring.html b/app/frontend/templates/admin/events/monitoring.html
index 76c658ed9..01d8e9285 100644
--- a/app/frontend/templates/admin/events/monitoring.html
+++ b/app/frontend/templates/admin/events/monitoring.html
@@ -58,6 +58,7 @@
{{ event.nb_total_places - event.nb_free_places }} / {{ event.nb_total_places }}
+ {{'app.admin.events.NUMBER_pre_registered' | translate:{NUMBER:event.nb_places_for_pre_registration} }}
{{ 'app.admin.events.cancelled' }}
{{ 'app.admin.events.without_reservation' }}
|
diff --git a/app/models/event.rb b/app/models/event.rb
index 96ab48199..c91011998 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -89,12 +89,21 @@ class Event < ApplicationRecord
else
reserved_places = reservations.joins(:slots_reservations)
.where('slots_reservations.canceled_at': nil)
+ .where.not('slots_reservations.validated_at': nil)
.map(&:total_booked_seats)
.inject(0) { |sum, t| sum + t }
self.nb_free_places = (nb_total_places - reserved_places)
end
end
+ def nb_places_for_pre_registration
+ reservations.joins(:slots_reservations)
+ .where('slots_reservations.canceled_at': nil)
+ .where('slots_reservations.validated_at': nil)
+ .map(&:total_booked_seats)
+ .inject(0) { |sum, t| sum + t }
+ end
+
def all_day?
availability.start_at.hour.zero?
end
diff --git a/app/services/reservation_confirm_payment_service.rb b/app/services/reservation_confirm_payment_service.rb
index 553e6b210..c509a172f 100644
--- a/app/services/reservation_confirm_payment_service.rb
+++ b/app/services/reservation_confirm_payment_service.rb
@@ -20,13 +20,27 @@ class ReservationConfirmPaymentService
offered: @offered
}
end
+ tickets = @reservation.tickets.map do |t|
+ {
+ event_price_category_id: t.event_price_category_id,
+ booked: t.booked
+ }
+ end
+ booking_users = @reservation.booking_users.map do |bu|
+ {
+ name: bu.name,
+ event_price_category_id: bu.event_price_category_id,
+ booked_id: bu.booked_id,
+ booked_type: bu.booked_type
+ }
+ end
event_reservation = CartItem::EventReservation.new(customer_profile: @reservation.user.invoicing_profile,
operator_profile: @operator.invoicing_profile,
event: @reservation.reservable,
cart_item_reservation_slots_attributes: slots_reservations,
normal_tickets: @reservation.nb_reserve_places,
- cart_item_event_reservation_tickets_attributes: @reservation.tickets.to_a,
- cart_item_event_reservation_booking_users_attributes: @reservation.booking_users.to_a)
+ cart_item_event_reservation_tickets_attributes: tickets,
+ cart_item_event_reservation_booking_users_attributes: booking_users)
all_elements = {
slots: @reservation.slots_reservations.map do |sr|
diff --git a/app/services/slots_reservations_service.rb b/app/services/slots_reservations_service.rb
index f3f6b8c5b..668868ba1 100644
--- a/app/services/slots_reservations_service.rb
+++ b/app/services/slots_reservations_service.rb
@@ -24,6 +24,11 @@ class SlotsReservationsService
def validate(slot_reservation)
if slot_reservation.update(validated_at: Time.current)
+ reservable = slot_reservation.reservation.reservable
+ if reservable.is_a?(Event)
+ reservable.update_nb_free_places
+ reservable.save
+ end
NotificationCenter.call type: 'notify_member_reservation_validated',
receiver: slot_reservation.reservation.user,
attached_object: slot_reservation.reservation
diff --git a/app/views/api/events/_event.json.jbuilder b/app/views/api/events/_event.json.jbuilder
index 2ab9cab33..49a1488e6 100644
--- a/app/views/api/events/_event.json.jbuilder
+++ b/app/views/api/events/_event.json.jbuilder
@@ -2,6 +2,7 @@
json.extract! event, :id, :title, :description, :event_type, :pre_registration, :pre_registration_end_date
json.pre_registration_end_date event.pre_registration_end_date&.to_date
+json.nb_places_for_pre_registration event.nb_places_for_pre_registration
if event.event_image
json.event_image_attributes do
json.id event.event_image.id
diff --git a/config/locales/app.admin.en.yml b/config/locales/app.admin.en.yml
index afa28cf82..4ccba66e0 100644
--- a/config/locales/app.admin.en.yml
+++ b/config/locales/app.admin.en.yml
@@ -601,6 +601,7 @@ en:
family: "Family"
nominative: "Nominative"
pre_registration: "Pre-registration"
+ NUMBER_pre_registered: " {NUMBER} pre-registered"
#add a new event
events_new:
add_an_event: "Add an event"
diff --git a/config/locales/app.admin.fr.yml b/config/locales/app.admin.fr.yml
index d61925611..481d2f497 100644
--- a/config/locales/app.admin.fr.yml
+++ b/config/locales/app.admin.fr.yml
@@ -601,6 +601,7 @@ fr:
family: "Famille"
nominative: "Nominatif"
pre_registration: "Pré-inscription"
+ NUMBER_pre_registered: " {NUMBER} pré-inscrit"
#add a new event
events_new:
add_an_event: "Ajouter un événement"