Skip to content

Commit

Permalink
cleanup in SaleableTicketCategory: remove description field #657
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer committed Jun 14, 2019
1 parent 1b6ac5b commit e31f09d
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private Map<String, Boolean> loadStatus(Event event) {
List<SaleableTicketCategory> stcList = eventManager.loadTicketCategories(event)
.stream()
.filter(tc -> !tc.isAccessRestricted())
.map(tc -> new SaleableTicketCategory(tc, "", now, event, ticketReservationManager.countAvailableTickets(event, tc), tc.getMaxTickets(), null))
.map(tc -> new SaleableTicketCategory(tc, now, event, ticketReservationManager.countAvailableTickets(event, tc), tc.getMaxTickets(), null))
.collect(Collectors.toList());
boolean active = EventUtil.checkWaitingQueuePreconditions(event, stcList, configurationManager, eventStatisticsManager.noSeatsAvailable());
boolean paused = active && configurationManager.getBooleanConfigValue(Configuration.from(event, STOP_WAITING_QUEUE_SUBSCRIPTIONS), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public ResponseEntity<ItemsByCategory> getTicketCategories(@PathVariable("eventN
} else if (filteredPromoCode != null && filteredPromoCode.getMaxUsage() != null) {
maxTickets = filteredPromoCode.getMaxUsage() - promoCodeRepository.countConfirmedPromoCode(filteredPromoCode.getId(), categoriesOrNull(filteredPromoCode), null, categoriesOrNull(filteredPromoCode) != null ? "X" : null);
}
return new SaleableTicketCategory(m, "",
return new SaleableTicketCategory(m,
now, event, ticketReservationManager.countAvailableTickets(event, m), maxTickets,
filteredPromoCode);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class SaleableTicketCategory implements PriceContainer {

@Delegate
private final TicketCategory ticketCategory;
private final String description;
private final ZonedDateTime now;
private final ZoneId zoneId;
private final Event event;
Expand All @@ -42,14 +41,12 @@ public class SaleableTicketCategory implements PriceContainer {
private final PromoCodeDiscount promoCodeDiscount;

public SaleableTicketCategory(TicketCategory ticketCategory,
String description,
ZonedDateTime now,
Event event,
int availableTickets,
int maxTickets,
PromoCodeDiscount promoCodeDiscount) {
this.ticketCategory = ticketCategory;
this.description = description;
this.now = now;
this.zoneId = event.getZoneId();
this.event = event;
Expand Down Expand Up @@ -117,10 +114,6 @@ public VatStatus getVatStatus() {
return event.getVatStatus();
}

public String getDescription() {
return description;
}

public String getFormattedFinalPrice() {
return getFinalPriceToDisplay(getFinalPrice().add(getAppliedDiscount()), getVAT(), getVatStatus()).toString();
}
Expand Down
8 changes: 1 addition & 7 deletions src/main/java/alfio/controller/form/ReservationForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ private int ticketSelectionCount() {
return selected().stream().mapToInt(TicketReservationModification::getAmount).sum();
}

private int additionalServicesSelectionCount(AdditionalServiceRepository additionalServiceRepository, int eventId) {
return (int) selectedAdditionalServices().stream()
.filter(as -> as.getAdditionalServiceId() != null && (additionalServiceRepository.getById(as.getAdditionalServiceId(), eventId).isFixPrice() || Optional.ofNullable(as.getAmount()).filter(a -> a.compareTo(BigDecimal.ZERO) > 0).isPresent()))
.count();
}

public Optional<Pair<List<TicketReservationWithOptionalCodeModification>, List<ASReservationWithOptionalCodeModification>>> validate(Errors bindingResult,
TicketReservationManager tickReservationManager,
AdditionalServiceRepository additionalServiceRepository,
Expand Down Expand Up @@ -143,7 +137,7 @@ private static void validateCategory(Errors bindingResult, TicketReservationMana
Event event, int maxAmountOfTicket, List<TicketReservationWithOptionalCodeModification> res,
Optional<SpecialPrice> specialCode, ZonedDateTime now, TicketReservationModification r) {
TicketCategory tc = eventManager.getTicketCategoryById(r.getTicketCategoryId(), event.getId());
SaleableTicketCategory ticketCategory = new SaleableTicketCategory(tc, "", now, event, tickReservationManager.countAvailableTickets(event, tc), maxAmountOfTicket, null);
SaleableTicketCategory ticketCategory = new SaleableTicketCategory(tc, now, event, tickReservationManager.countAvailableTickets(event, tc), maxAmountOfTicket, null);

if (!ticketCategory.getSaleable()) {
bindingResult.reject(ErrorsCode.STEP_1_TICKET_CATEGORY_MUST_BE_SALEABLE);
Expand Down

0 comments on commit e31f09d

Please sign in to comment.