Search in sources :

Example 1 with TicketCategory

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);
}
Also used : Organization(alfio.model.user.Organization) TicketCategory(alfio.model.TicketCategory)

Example 2 with TicketCategory

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;
}
Also used : Locale(java.util.Locale) Ticket(alfio.model.Ticket) Organization(alfio.model.user.Organization) Event(alfio.model.Event) TicketCategory(alfio.model.TicketCategory) TicketReservation(alfio.model.TicketReservation)

Example 3 with TicketCategory

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));
}
Also used : Organization(alfio.model.user.Organization) Event(alfio.model.Event) TicketCategory(alfio.model.TicketCategory) Test(org.junit.Test)

Example 4 with TicketCategory

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));
}
Also used : Event(alfio.model.Event) TicketCategory(alfio.model.TicketCategory) Test(org.junit.Test)

Example 5 with TicketCategory

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());
}
Also used : Event(alfio.model.Event) TicketCategory(alfio.model.TicketCategory) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Aggregations

TicketCategory (alfio.model.TicketCategory)22 Event (alfio.model.Event)17 Test (org.junit.Test)11 Ticket (alfio.model.Ticket)6 Organization (alfio.model.user.Organization)6 TicketReservation (alfio.model.TicketReservation)4 Triple (org.apache.commons.lang3.tuple.Triple)3 SaleableTicketCategory (alfio.controller.decorator.SaleableTicketCategory)2 EventManager (alfio.manager.EventManager)2 TicketReservationManager (alfio.manager.TicketReservationManager)2 SpecialPrice (alfio.model.SpecialPrice)2 TicketReservationWithOptionalCodeModification (alfio.model.modification.TicketReservationWithOptionalCodeModification)2 LocalDate (java.time.LocalDate)2 Collectors (java.util.stream.Collectors)2 TicketDecorator (alfio.controller.support.TicketDecorator)1 NotificationManager (alfio.manager.NotificationManager)1 Mailer (alfio.manager.system.Mailer)1 AdditionalService (alfio.model.AdditionalService)1 ASReservationWithOptionalCodeModification (alfio.model.modification.ASReservationWithOptionalCodeModification)1 AdditionalServiceReservationModification (alfio.model.modification.AdditionalServiceReservationModification)1