1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-29 18:52:22 +01:00

update nb of free places after moving an event reservation with custom prices

This commit is contained in:
Sylvain 2016-08-30 12:34:36 +02:00
parent 7de896feb9
commit b9411366c2
3 changed files with 7 additions and 6 deletions

View File

@ -358,11 +358,14 @@ Application.Controllers.controller "ShowEventController", ["$scope", "$state", "
$uibModalInstance.dismiss('cancel')
]
.result['finally'](null).then (reservation)->
# remove the reservation from the user's reservations list for this event (occurrence)
$scope.reservations.splice(index, 1)
$scope.event.nb_free_places = $scope.event.nb_free_places + reservation.nb_reserve_places + reservation.nb_reserve_reduced_places
# add the number of places transfered (to the new date) to the total of free places for this event
$scope.event.nb_free_places = $scope.event.nb_free_places + reservation.total_booked_seats
# remove the number of places transfered from the total of free places of the receiving occurrance
angular.forEach $scope.event.recurrence_events, (e)->
if e.id is parseInt(reservation.reservable_id, 10)
e.nb_free_places = e.nb_free_places - reservation.nb_reserve_places - reservation.nb_reserve_reduced_places
if e.id is parseInt(reservation.reservable.id, 10)
e.nb_free_places = e.nb_free_places - reservation.total_booked_seats

View File

@ -512,9 +512,6 @@ angular.module('application.router', ['ui.router']).
eventPromise: ['Event', '$stateParams', (Event, $stateParams)->
Event.get(id: $stateParams.id).$promise
]
reducedAmountAlert: ['Setting', (Setting)->
Setting.get(name: 'event_reduced_amount_alert').$promise
]
priceCategoriesPromise: ['PriceCategory', (PriceCategory) ->
PriceCategory.query().$promise
]

View File

@ -34,4 +34,5 @@ json.tickets @reservation.tickets do |t|
end
end
end
json.total_booked_seats @reservation.total_booked_seats
json.created_at @reservation.created_at.iso8601