1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-01 21:52:19 +01:00

(feat) pre-register event for family compte and nominatif

This commit is contained in:
Du Peng 2023-06-27 19:04:18 +02:00
parent 9672ab2968
commit 0cdc8a2228
8 changed files with 39 additions and 3 deletions

View File

@ -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)),

View File

@ -58,6 +58,7 @@
<td style="vertical-align:middle">
<span class="ng-binding" ng-if="event.nb_total_places > 0">{{ event.nb_total_places - event.nb_free_places }} / {{ event.nb_total_places }}</span>
<div class="ng-binding" ng-if="event.pre_registration">{{'app.admin.events.NUMBER_pre_registered' | translate:{NUMBER:event.nb_places_for_pre_registration} }}</div>
<span class="badge font-sbold cancelled" ng-if="event.nb_total_places == -1" translate>{{ 'app.admin.events.cancelled' }}</span>
<span class="badge font-sbold" ng-if="!event.nb_total_places" translate>{{ 'app.admin.events.without_reservation' }}</span>
</td>

View File

@ -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

View File

@ -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|

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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"