mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-21 15:54:22 +01:00
compute right nb of free seats for event reservation
also: copy nb_total_places to n+1 instances when creating recurrent availabilities
This commit is contained in:
parent
ce366beaa2
commit
bbd613f2a5
@ -244,8 +244,11 @@ class Reservation < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def total_booked_seats
|
def total_booked_seats
|
||||||
total = 0
|
# cases:
|
||||||
total = nb_reserve_places if slots.first.canceled_at
|
# - machine/training/space reservation => 1 slot = 1 seat (currently not covered by this function)
|
||||||
|
# - event reservation => seats = nb_reserve_place (normal price) + tickets.booked (other prices)
|
||||||
|
total = nb_reserve_places
|
||||||
|
total = 0 if slots.first.canceled_at
|
||||||
total += tickets.map(&:booked).map(&:to_i).reduce(:+) if tickets.count.positive?
|
total += tickets.map(&:booked).map(&:to_i).reduce(:+) if tickets.count.positive?
|
||||||
|
|
||||||
total
|
total
|
||||||
|
@ -20,7 +20,8 @@ class Availabilities::CreateAvailabilitiesService
|
|||||||
machine_ids: availability.machine_ids,
|
machine_ids: availability.machine_ids,
|
||||||
training_ids: availability.training_ids,
|
training_ids: availability.training_ids,
|
||||||
space_ids: availability.space_ids,
|
space_ids: availability.space_ids,
|
||||||
tag_ids: availability.tag_ids
|
tag_ids: availability.tag_ids,
|
||||||
|
nb_total_places: availability.nb_total_places
|
||||||
).save!
|
).save!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user