From cad7560bbd8e95c77e0d86e69637df21b8d83307 Mon Sep 17 00:00:00 2001 From: Sylvain Jermini Date: Mon, 10 Nov 2014 15:06:06 +0100 Subject: [PATCH] display vat nr in email --- .../java/io/bagarino/config/MvcConfiguration.java | 13 ++++++++++--- .../bagarino/controller/ReservationController.java | 5 +++++ .../bagarino/manager/TicketReservationManager.java | 4 ++++ .../io/bagarino/i18n/application.properties | 1 + .../io/bagarino/i18n/application_it.properties | 1 + .../io/bagarino/templates/confirmation-email-txt.ms | 2 ++ 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/bagarino/config/MvcConfiguration.java b/src/main/java/io/bagarino/config/MvcConfiguration.java index e4ae3e2fc3..c8fcd37631 100644 --- a/src/main/java/io/bagarino/config/MvcConfiguration.java +++ b/src/main/java/io/bagarino/config/MvcConfiguration.java @@ -21,8 +21,11 @@ import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.JSR310Module; import com.samskivert.mustache.Mustache; + import io.bagarino.controller.support.TemplateManager; import io.bagarino.util.MustacheCustomTagInterceptor; + +import org.apache.commons.lang3.StringUtils; import org.springframework.context.MessageSource; import org.springframework.context.ResourceLoaderAware; import org.springframework.context.annotation.Bean; @@ -51,8 +54,10 @@ import org.springframework.web.servlet.view.mustache.jmustache.JMustacheTemplateLoader; import org.springframework.web.servlet.view.mustache.jmustache.LocalizationMessageInterceptor; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.Arrays; @@ -92,9 +97,11 @@ public void postHandle(HttpServletRequest request, HttpServletResponse response, ModelAndView modelAndView) throws Exception { Optional.ofNullable(modelAndView).ifPresent(mv -> { mv.addObject("request", request); - final ModelMap modelMap = mv.getModelMap(); - modelMap.putIfAbsent("pageTitle", "empty"); - modelMap.putIfAbsent("event", null); + final ModelMap modelMap = mv.getModelMap(); + modelMap.putIfAbsent("event", null); + if(!StringUtils.startsWith(mv.getViewName(), "redirect:")) { + modelMap.putIfAbsent("pageTitle", "empty"); + } }); } }); diff --git a/src/main/java/io/bagarino/controller/ReservationController.java b/src/main/java/io/bagarino/controller/ReservationController.java index b4544d3789..9a58a68e19 100644 --- a/src/main/java/io/bagarino/controller/ReservationController.java +++ b/src/main/java/io/bagarino/controller/ReservationController.java @@ -290,6 +290,11 @@ private Map prepareModelForReservationEmail(Event event, TicketR model.put("organization", organizationRepository.getById(event.getOrganizationId())); model.put("event", event); model.put("ticketReservation", reservation); + + Optional vat = ticketReservationManager.getVAT(); + + model.put("hasVat", vat.isPresent()); + model.put("vatNr", vat.orElse("")); OrderSummary orderSummary = ticketReservationManager.orderSummaryForReservationId(reservation.getId(), event); model.put("tickets", ticketReservationManager.findTicketsInReservation(reservation.getId())); diff --git a/src/main/java/io/bagarino/manager/TicketReservationManager.java b/src/main/java/io/bagarino/manager/TicketReservationManager.java index d6f8b7fbd0..d36d82cd78 100644 --- a/src/main/java/io/bagarino/manager/TicketReservationManager.java +++ b/src/main/java/io/bagarino/manager/TicketReservationManager.java @@ -344,4 +344,8 @@ public List findTicketsInReservation(String reservationId) { public int countUnsoldTicket(int eventId, int categoryId) { return ticketRepository.countUnsoldTicket(eventId, categoryId); } + + public Optional getVAT() { + return configurationManager.getStringConfigValue(ConfigurationKeys.VAT_NR); + } } diff --git a/src/main/resources/io/bagarino/i18n/application.properties b/src/main/resources/io/bagarino/i18n/application.properties index eb4b25d92a..206c4842d6 100644 --- a/src/main/resources/io/bagarino/i18n/application.properties +++ b/src/main/resources/io/bagarino/i18n/application.properties @@ -172,6 +172,7 @@ email-confirmation.completed=Your reservation for the event {0} has been complet email-confirmation.reservation-summary=Reservation summary email-confirmation.summary=Category: {0}, Amount: {1}, Subtotal: {2} {3} email-confirmation.order-information=Order information : {0} +email-confirmation.vatNr=VAT number: {0} #ticket-has-changed-owner-txt.ms diff --git a/src/main/resources/io/bagarino/i18n/application_it.properties b/src/main/resources/io/bagarino/i18n/application_it.properties index 27cbcedde4..43f6e973e1 100644 --- a/src/main/resources/io/bagarino/i18n/application_it.properties +++ b/src/main/resources/io/bagarino/i18n/application_it.properties @@ -159,6 +159,7 @@ email-confirmation.completed=La tua prenotazione per l''evento {0} \u00E8 stata email-confirmation.reservation-summary=Riepilogo della prenotazione email-confirmation.summary=Categoria\: {0}, Quantit\u00E0\: {1}, Subtotale\: {2} {3} email-confirmation.order-information=Informazioni sull''ordine \: {0} +email-confirmation.vatNr=Numero IVA: {0} #ticket-has-changed-owner-txt.ms ticket-has-changed-owner.notice=Avviso\: l''email associata al tuo biglietto per l''evento {0} \u00E8 stata modificata da {1} a {2}. Per favore controlla che sia tutto OK usando il seguente link\: {3}. diff --git a/src/main/resources/io/bagarino/templates/confirmation-email-txt.ms b/src/main/resources/io/bagarino/templates/confirmation-email-txt.ms index 89b9a3ff13..bb27aa2f46 100644 --- a/src/main/resources/io/bagarino/templates/confirmation-email-txt.ms +++ b/src/main/resources/io/bagarino/templates/confirmation-email-txt.ms @@ -12,6 +12,8 @@ {{^orderSummary.free}}{{#event.vatIncluded}} {{#i18n}}reservation-page.vat-included [{{event.vat}}]{{/i18n}}: {{orderSummary.totalVAT}} {{event.currency}}{{/event.vatIncluded}}{{/orderSummary.free}} +{{#hasVat}}{{#i18n}}email-confirmation.vatNr [{{vatNr}}]{{/i18n}}{{/hasVat}} + {{#i18n}}email-confirmation.order-information [{{ticketReservation.id}}]{{/i18n}} #### {{#i18n}}email.event-info{{/i18n}} ####