Skip to content

Commit

Permalink
#111 donations/additional services: user facing changes
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer committed May 20, 2017
1 parent 0da5422 commit 68dc62e
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 11 deletions.
13 changes: 10 additions & 3 deletions src/main/java/alfio/controller/EventController.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ public String showEvent(@PathVariable("eventName") String eventName,
List<SaleableAdditionalService> additionalServices = additionalServiceRepository.loadAllForEvent(event.getId()).stream().map((as) -> getSaleableAdditionalService(event, locale, as, promoCodeDiscount.orElse(null))).collect(Collectors.toList());
Predicate<SaleableTicketCategory> waitingQueueTargetCategory = tc -> !tc.getExpired() && !tc.isBounded();
boolean validPaymentConfigured = isEventHasValidPaymentConfigurations(event, configurationManager);

List<SaleableAdditionalService> notExpiredServices = additionalServices.stream().filter(SaleableAdditionalService::isNotExpired).collect(Collectors.toList());
List<SaleableAdditionalService> donations = notExpiredServices.stream().filter(a -> a.getType() == AdditionalService.AdditionalServiceType.DONATION).collect(Collectors.toList());
List<SaleableAdditionalService> supplements = notExpiredServices.stream().filter(a -> a.getType() == AdditionalService.AdditionalServiceType.SUPPLEMENT).collect(Collectors.toList());

model.addAttribute("event", eventDescriptor)//
.addAttribute("organization", organizationRepository.getById(event.getOrganizationId()))
.addAttribute("ticketCategories", validCategories)//
Expand All @@ -239,9 +244,11 @@ public String showEvent(@PathVariable("eventName") String eventName,
.addAttribute("unboundedCategories", ticketCategories.stream().filter(waitingQueueTargetCategory).collect(Collectors.toList()))
.addAttribute("preSales", EventUtil.isPreSales(event, ticketCategories))
.addAttribute("userLanguage", locale.getLanguage())
.addAttribute("showAdditionalServices", !additionalServices.isEmpty())
.addAttribute("enabledAdditionalServices", additionalServices.stream().filter(SaleableAdditionalService::isNotExpired).collect(Collectors.toList()))
.addAttribute("disabledAdditionalServices", additionalServices.stream().filter(SaleableAdditionalService::isExpired).collect(Collectors.toList()))
.addAttribute("showAdditionalServices", !notExpiredServices.isEmpty())
.addAttribute("showAdditionalServicesDonations", !donations.isEmpty())
.addAttribute("showAdditionalServicesSupplements", !supplements.isEmpty())
.addAttribute("enabledAdditionalServicesDonations", donations)
.addAttribute("enabledAdditionalServicesSupplements", supplements)
.addAttribute("forwardButtonDisabled", (ticketCategories.stream().noneMatch(SaleableTicketCategory::getSaleable)) || !validPaymentConfigured)
.addAttribute("useFirstAndLastName", event.mustUseFirstAndLastName())
.addAttribute("validPaymentMethodAvailable", validPaymentConfigured);
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/alfio/controller/form/ReservationForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,16 @@ public Optional<Pair<List<TicketReservationWithOptionalCodeModification>, List<A
return OptionalWrapper.optionally(() -> eventManager.findEventByTicketCategory(tc)).isPresent();
});


//FIXME add here a new error code for handling supplement policy!
//

final boolean validAdditionalServiceSelected = additionalServices.stream().allMatch(asm -> {
AdditionalService as = eventManager.getAdditionalServiceById(asm.getAdditionalServiceId(), event.getId());
ZonedDateTime now = ZonedDateTime.now(event.getZoneId());
return as.getInception(event.getZoneId()).isBefore(now) && as.getExpiration(event.getZoneId()).isAfter(now) &&
return as.getInception(event.getZoneId()).isBefore(now) &&
as.getExpiration(event.getZoneId()).isAfter(now) &&
(as.isFixPrice() || (!as.isFixPrice() && asm.getAmount() != null && asm.getAmount().compareTo(BigDecimal.ZERO) >= 0)) &&
OptionalWrapper.optionally(() -> eventManager.findEventByAdditionalService(as)).isPresent();
});

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/alfio/i18n/public.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ show-event.header.title=Reserve a Ticket for {0}\!
show-event.by=By
show-event.tickets=Tickets
show-event.additional-services=Additional options
show-event.donations=Donations
show-event.continue=Continue
show-event.incVat=All prices are VAT inclusive at {0}%
show-event.excVat=All prices are VAT exclusive at {0}%
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/alfio/i18n/public_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,4 @@ invoice.payment-to=Zahlung an:
invoice.payment-reason=Bitte <strong>{0}</strong> als Zahlungsgrund/Verwendungszweck anzugeben.
reservation-page-waiting.required-steps.1.with-bank-account-owner=\u00DCberweise den Betrag von <strong> {0} </strong> an folgende Bankverbindung: <strong> {1} </strong>.
reservation-page-waiting.required-steps.1.with-bank-account-owner.2=Du bist verpflichtet, <strong> {0} </strong> als Zahlungsgrund/Verwendungszweck anzugeben
show-event.donations=Spenden
3 changes: 2 additions & 1 deletion src/main/resources/alfio/i18n/public_it.properties
Original file line number Diff line number Diff line change
Expand Up @@ -313,4 +313,5 @@ invoice.account-number=Numero del conto: <strong>{0}</strong>
invoice.payment-to=Pagamento a:
invoice.payment-reason=Specificando <strong>{0}</strong> quale causale del pagamento.
reservation-page-waiting.required-steps.1.with-bank-account-owner=Invia l''importo di <strong>{0}</strong> al conto corrente: <strong>{1}</strong>
reservation-page-waiting.required-steps.1.with-bank-account-owner.2=specificando <strong>{0}</strong> quale causale del pagamento
reservation-page-waiting.required-steps.1.with-bank-account-owner.2=specificando <strong>{0}</strong> quale causale del pagamento
show-event.donations=Donazioni
1 change: 1 addition & 0 deletions src/main/resources/alfio/i18n/public_nl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,4 @@ invoice.payment-to=Betaling aan:
invoice.payment-reason=Met <strong>{0}</strong> als betalingsomschrijving.
reservation-page-waiting.required-steps.1.with-bank-account-owner=Maak een bedrag van <strong>{0}</strong> over naar het volgende Bank Account: <strong>{1}</strong>.
reservation-page-waiting.required-steps.1.with-bank-account-owner.2=U bent verplicht <strong>{0}</strong> als betalingsreden in te voeren.
show-event.donations=Donaties
22 changes: 16 additions & 6 deletions src/main/webapp/WEB-INF/templates/event/show-event.ms
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,22 @@
{{/ticketCategories}}
</ul>
{{#showAdditionalServices}}
<h2>{{#i18n}}show-event.additional-services{{/i18n}}</h2>
<ul class="list-group">
{{#enabledAdditionalServices}}
{{> /event/additional-service.ms }}
{{/enabledAdditionalServices}}
</ul>
{{#showAdditionalServicesSupplements}}
<h2>{{#i18n}}show-event.additional-services{{/i18n}}</h2>
<ul class="list-group">
{{#enabledAdditionalServicesDonations}}
{{> /event/additional-service.ms }}
{{/enabledAdditionalServicesDonations}}
</ul>
{{/showAdditionalServicesSupplements}}
{{#showAdditionalServicesDonations}}
<h2>{{#i18n}}show-event.donations{{/i18n}}</h2>
<ul class="list-group">
{{#enabledAdditionalServicesDonations}}
{{> /event/additional-service.ms }}
{{/enabledAdditionalServicesDonations}}
</ul>
{{/showAdditionalServicesDonations}}
{{/showAdditionalServices}}
{{#showNoCategoriesWarning}}
<div class="alert alert-warning">
Expand Down

0 comments on commit 68dc62e

Please sign in to comment.