use of alfio.model.TicketCategory in project alf.io by alfio-event.
the class TicketController method preparePdfTicket.
private PartialTicketPDFGenerator preparePdfTicket(HttpServletRequest request, Event event, TicketReservation ticketReservation, Ticket ticket) throws WriterException, IOException {
TicketCategory ticketCategory = ticketCategoryRepository.getByIdAndActive(ticket.getCategoryId(), event.getId());
Organization organization = organizationRepository.getById(event.getOrganizationId());
String reservationID = ticketReservationManager.getShortReservationID(event, ticketReservation.getId());
return TemplateProcessor.buildPartialPDFTicket(LocaleUtil.getTicketLanguage(ticket, request), event, ticketReservation, ticketCategory, organization, templateManager, fileUploadManager, reservationID);
}
use of alfio.model.TicketCategory in project alf.io by alfio-event.
the class TicketController method internalSendTicketByEmail.
private Ticket internalSendTicketByEmail(HttpServletRequest request, Triple<Event, TicketReservation, Ticket> data) throws IOException {
Ticket ticket = data.getRight();
Event event = data.getLeft();
Locale locale = LocaleUtil.getTicketLanguage(ticket, request);
TicketReservation reservation = data.getMiddle();
Organization organization = organizationRepository.getById(event.getOrganizationId());
TicketCategory category = ticketCategoryRepository.getById(ticket.getCategoryId());
notificationManager.sendTicketByEmail(ticket, event, locale, TemplateProcessor.buildPartialEmail(event, organization, reservation, category, templateManager, ticketReservationManager.ticketUpdateUrl(event, ticket.getUuid()), request), reservation, ticketCategoryRepository.getByIdAndActive(ticket.getCategoryId(), event.getId()));
return ticket;
}
use of alfio.model.TicketCategory in project alf.io by alfio-event.
the class ConfigurationManagerIntegrationTest method testOverrideMechanism.
@Test
public void testOverrideMechanism() {
Organization organization = organizationRepository.findByName("org").get();
Event event = eventManager.getSingleEvent("eventShortName", "test");
TicketCategory tc = eventManager.loadTicketCategories(event).get(0);
//
// check override level up to event level
assertEquals(5, configurationManager.getIntConfigValue(Configuration.from(event.getOrganizationId(), event.getId(), MAX_AMOUNT_OF_TICKETS_BY_RESERVATION), -1));
configurationRepository.insertOrganizationLevel(organization.getId(), MAX_AMOUNT_OF_TICKETS_BY_RESERVATION.getValue(), "6", "desc");
assertEquals(6, configurationManager.getIntConfigValue(Configuration.from(event.getOrganizationId(), event.getId(), MAX_AMOUNT_OF_TICKETS_BY_RESERVATION), -1));
configurationRepository.insertEventLevel(organization.getId(), event.getId(), MAX_AMOUNT_OF_TICKETS_BY_RESERVATION.getValue(), "7", "desc");
assertEquals(7, configurationManager.getIntConfigValue(Configuration.from(event.getOrganizationId(), event.getId(), MAX_AMOUNT_OF_TICKETS_BY_RESERVATION), -1));
configurationRepository.insertTicketCategoryLevel(organization.getId(), event.getId(), tc.getId(), MAX_AMOUNT_OF_TICKETS_BY_RESERVATION.getValue(), "8", "desc");
assertEquals(7, configurationManager.getIntConfigValue(Configuration.from(event.getOrganizationId(), event.getId(), MAX_AMOUNT_OF_TICKETS_BY_RESERVATION), -1));
}
use of alfio.model.TicketCategory in project alf.io by alfio-event.
the class EventManagerIntegrationTest method testDecreaseRestrictedCategoryWithAlreadySentToken.
// https://github.com/exteso/alf.io/issues/335
@Test
public void testDecreaseRestrictedCategoryWithAlreadySentToken() {
ensureMinimalConfiguration(configurationRepository);
List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 4, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, true, "", true, null, null, null, null, null));
Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);
Event event = pair.getLeft();
String username = pair.getRight();
TicketCategory category = ticketCategoryRepository.findByEventId(event.getId()).get(0);
Map<String, String> categoryDescription = ticketCategoryDescriptionRepository.descriptionForTicketCategory(category.getId());
specialPriceTokenGenerator.generatePendingCodesForCategory(category.getId());
List<SendCodeModification> linked = specialPriceManager.linkAssigneeToCode(Arrays.asList(new SendCodeModification(null, "test1", "test@test.com", "it"), new SendCodeModification(null, "test2", "test@test.com", "it")), event.getShortName(), category.getId(), username);
specialPriceManager.sendCodeToAssignee(linked, event.getShortName(), category.getId(), username);
TicketCategoryModification tcmOk = new TicketCategoryModification(category.getId(), category.getName(), 2, DateTimeModification.fromZonedDateTime(category.getUtcInception()), DateTimeModification.fromZonedDateTime(category.getUtcExpiration()), categoryDescription, category.getPrice(), true, "", true, null, null, null, null, null);
Result<TicketCategory> resOk = eventManager.updateCategory(category.getId(), event, tcmOk, username);
Assert.assertTrue(resOk.isSuccess());
TicketCategoryModification tcm = new TicketCategoryModification(category.getId(), category.getName(), 1, DateTimeModification.fromZonedDateTime(category.getUtcInception()), DateTimeModification.fromZonedDateTime(category.getUtcExpiration()), categoryDescription, category.getPrice(), true, "", true, null, null, null, null, null);
Result<TicketCategory> res = eventManager.updateCategory(category.getId(), event, tcm, username);
Assert.assertFalse(res.isSuccess());
Assert.assertTrue(res.getErrors().contains(ErrorCode.CategoryError.NOT_ENOUGH_FREE_TOKEN_FOR_SHRINK));
}
use of alfio.model.TicketCategory in project alf.io by alfio-event.
the class EventManagerIntegrationTest method testValidationBoundedFailedPendingTickets.
@Test
public void testValidationBoundedFailedPendingTickets() {
List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null));
Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);
Event event = pair.getLeft();
String username = pair.getRight();
TicketCategory category = ticketCategoryRepository.findByEventId(event.getId()).get(0);
Map<String, String> categoryDescription = ticketCategoryDescriptionRepository.descriptionForTicketCategory(category.getId());
List<Integer> tickets = ticketRepository.selectTicketInCategoryForUpdate(event.getId(), category.getId(), 1, Collections.singletonList(Ticket.TicketStatus.FREE.name()));
String reservationId = "12345678";
ticketReservationRepository.createNewReservation(reservationId, DateUtils.addDays(new Date(), 1), null, "en", event.getId(), event.getVat(), event.isVatIncluded());
ticketRepository.reserveTickets(reservationId, tickets, category.getId(), "en", 100);
TicketCategoryModification tcm = new TicketCategoryModification(category.getId(), category.getName(), 10, DateTimeModification.fromZonedDateTime(category.getUtcInception()), DateTimeModification.fromZonedDateTime(category.getUtcExpiration()), categoryDescription, category.getPrice(), false, "", false, null, null, null, null, null);
Result<TicketCategory> result = eventManager.updateCategory(category.getId(), event, tcm, username);
assertFalse(result.isSuccess());
}
Aggregations