Skip to content

Commit

Permalink
fix #412 - add TicketReservations (reservations)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbellone committed Apr 24, 2018
1 parent 9898b8d commit 37e4c32
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/alfio/manager/AdminReservationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,8 @@ private void removeTicketsFromReservation(TicketReservation reservation, Event e
.addValue("eventId", event.getId())
.addValue("newUuid", UUID.randomUUID().toString())
).toArray(MapSqlParameterSource[]::new);
List<String> reservationIds = ticketRepository.findReservationIds(ticketIds);
List<String> ticketUUIDs = ticketRepository.findUUIDs(ticketIds);
jdbc.batchUpdate(ticketRepository.batchReleaseTickets(), args);
if(!removeReservation) {
//#407 update invoice/receipt model only if the reservation is still "PENDING", otherwise we could lead to accountancy problems
Expand All @@ -586,9 +588,9 @@ private void removeTicketsFromReservation(TicketReservation reservation, Event e
auditingRepository.insert(reservationId, userId, event.getId(), eventType, date, RESERVATION, reservationId);
updateInvoiceReceiptModel(event, reservation.getUserLanguage(), reservationId);
}
extensionManager.handleTicketCancelledForEvent(event, ticketRepository.findUUIDs(ticketIds));
extensionManager.handleTicketCancelledForEvent(event, ticketUUIDs);
} else {
extensionManager.handleReservationsCancelledForEvent(event, ticketRepository.findReservationIds(ticketIds));
extensionManager.handleReservationsCancelledForEvent(event, reservationIds);
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/alfio/manager/ExtensionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import alfio.model.*;
import alfio.model.extension.InvoiceGeneration;
import alfio.repository.EventRepository;
import alfio.repository.TicketReservationRepository;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

Expand All @@ -32,6 +33,7 @@ public class ExtensionManager {

private final ExtensionService extensionService;
private final EventRepository eventRepository;
private final TicketReservationRepository ticketReservationRepository;

public enum ExtensionEvent {
RESERVATION_CONFIRMED,
Expand Down Expand Up @@ -129,6 +131,7 @@ private void handleReservationRemoval(Event event, Collection<String> reservatio

Map<String, Object> payload = new HashMap<>();
payload.put("reservationIds", reservationIds);
payload.put("reservations", ticketReservationRepository.findByIds(reservationIds));

syncCall(extensionEvent, event, organizationId, payload, Boolean.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,7 @@ int updateBillingData(@Bind("vatStatus") PriceContainer.VatStatus vatStatus,

@Query("select id, event_id_fk from tickets_reservation where id in (:ids)")
List<ReservationIdAndEventId> getReservationIdAndEventId(@Bind("ids") Collection<String> ids);

@Query("select * from tickets_reservation where id in (:ids)")
List<TicketReservation> findByIds(@Bind("ids") Collection<String> ids);
}

0 comments on commit 37e4c32

Please sign in to comment.