diff --git a/src/main/java/alfio/controller/ReservationController.java b/src/main/java/alfio/controller/ReservationController.java index 69b6808a1e..f6e46a72e2 100644 --- a/src/main/java/alfio/controller/ReservationController.java +++ b/src/main/java/alfio/controller/ReservationController.java @@ -28,6 +28,7 @@ import alfio.model.TicketReservation.TicketReservationStatus; import alfio.model.result.ValidationResult; import alfio.model.system.Configuration; +import alfio.model.system.ConfigurationKeys; import alfio.model.transaction.PaymentProxy; import alfio.model.user.Organization; import alfio.repository.EventRepository; @@ -59,6 +60,7 @@ import java.util.*; import java.util.stream.Collectors; +import static alfio.model.system.Configuration.getSystemConfiguration; import static alfio.model.system.ConfigurationKeys.*; import static java.util.stream.Collectors.toList; @@ -150,7 +152,7 @@ public String showPaymentPage(@PathVariable("eventName") String eventName, if(orderSummary.getFree() || activePaymentMethods.stream().anyMatch(p -> p == PaymentProxy.OFFLINE || p == PaymentProxy.ON_SITE)) { boolean captchaForOfflinePaymentEnabled = configurationManager.isRecaptchaForOfflinePaymentEnabled(event); model.addAttribute("captchaRequestedForOffline", captchaForOfflinePaymentEnabled) - .addAttribute("recaptchaApiKey", configurationManager.getStringConfigValue(Configuration.getSystemConfiguration(RECAPTCHA_API_KEY), null)) + .addAttribute("recaptchaApiKey", configurationManager.getStringConfigValue(getSystemConfiguration(RECAPTCHA_API_KEY), null)) .addAttribute("captchaRequestedFreeOfCharge", orderSummary.getFree() && captchaForOfflinePaymentEnabled); } @@ -166,6 +168,8 @@ public String showPaymentPage(@PathVariable("eventName") String eventName, .addAttribute("expressCheckoutEnabled", isExpressCheckoutEnabled(event, orderSummary)) .addAttribute("useFirstAndLastName", event.mustUseFirstAndLastName()) .addAttribute("countries", TicketHelper.getLocalizedCountries(locale)) + .addAttribute("countriesForVat", TicketHelper.getLocalizedCountriesForVat(locale)) + .addAttribute("euCountriesForVat", TicketHelper.getLocalizedEUCountriesForVat(locale, configurationManager.getRequiredValue(getSystemConfiguration(ConfigurationKeys.EU_COUNTRIES_LIST)))) .addAttribute("euVatCheckingEnabled", vatChecker.isVatCheckingEnabledFor(event.getOrganizationId())) .addAttribute("invoiceIsAllowed", invoiceAllowed) .addAttribute("vatNrIsLinked", orderSummary.isVatExempt() || paymentForm.getHasVatCountryCode()) diff --git a/src/main/java/alfio/controller/api/admin/ConfigurationApiController.java b/src/main/java/alfio/controller/api/admin/ConfigurationApiController.java index 3207ae3667..3afe795ee7 100644 --- a/src/main/java/alfio/controller/api/admin/ConfigurationApiController.java +++ b/src/main/java/alfio/controller/api/admin/ConfigurationApiController.java @@ -131,8 +131,8 @@ public boolean deleteKey(@PathVariable("key") String key) { } @RequestMapping(value = "/configuration/eu-countries", method = GET) - public List> loadEUCountries(Locale locale) { - return TicketHelper.getLocalizedEUCountries(locale, configurationManager.getRequiredValue(getSystemConfiguration(ConfigurationKeys.EU_COUNTRIES_LIST))); + public List> loadEUCountries() { + return TicketHelper.getLocalizedEUCountriesForVat(Locale.ENGLISH, configurationManager.getRequiredValue(getSystemConfiguration(ConfigurationKeys.EU_COUNTRIES_LIST))); } @RequestMapping(value = "/configuration/platform-mode/status/{organizationId}", method = GET) diff --git a/src/main/java/alfio/controller/api/support/TicketHelper.java b/src/main/java/alfio/controller/api/support/TicketHelper.java index 6230196ee9..85b9495fb3 100644 --- a/src/main/java/alfio/controller/api/support/TicketHelper.java +++ b/src/main/java/alfio/controller/api/support/TicketHelper.java @@ -206,10 +206,25 @@ public static List> getLocalizedCountries(Locale locale) { return mapISOCountries(Stream.of(Locale.getISOCountries()), locale); } - public static List> getLocalizedEUCountries(Locale locale, String euCountries) { - return mapISOCountries(Stream.of(Locale.getISOCountries()).filter(isoCode -> StringUtils.contains(euCountries, isoCode)), locale); + public static List> getLocalizedEUCountriesForVat(Locale locale, String euCountries) { + return fixVAT(mapISOCountries(Stream.of(Locale.getISOCountries()) + .filter(isoCode -> StringUtils.contains(euCountries, isoCode) || "GR".equals(isoCode)), locale)); } + public static List> getLocalizedCountriesForVat(Locale locale) { + return fixVAT(mapISOCountries(Stream.of(Locale.getISOCountries()), locale)); + } + + private static List> fixVAT(List> countries) { + return countries.stream() + .map(kv -> Pair.of(FIX_ISO_CODE_FOR_VAT.getOrDefault(kv.getKey(), kv.getKey()), kv.getValue())) + .collect(Collectors.toList()); + } + + + // + public static final Map FIX_ISO_CODE_FOR_VAT = Collections.singletonMap("GR", "EL"); + private static List> mapISOCountries(Stream isoCountries, Locale locale) { return isoCountries .map(isoCode -> Pair.of(isoCode, new Locale("", isoCode).getDisplayCountry(locale))) diff --git a/src/main/resources/alfio/db/HSQLDB/V22_1.15.1__FIX_EU_COUNTRIES_LIST.sql b/src/main/resources/alfio/db/HSQLDB/V22_1.15.1__FIX_EU_COUNTRIES_LIST.sql new file mode 100644 index 0000000000..77dec3f42c --- /dev/null +++ b/src/main/resources/alfio/db/HSQLDB/V22_1.15.1__FIX_EU_COUNTRIES_LIST.sql @@ -0,0 +1,19 @@ +-- +-- This file is part of alf.io. +-- +-- alf.io is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- alf.io is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with alf.io. If not, see . +-- + +delete from configuration where c_key = 'EU_COUNTRIES_LIST'; +insert into configuration(c_key, c_value, description) values('EU_COUNTRIES_LIST', 'BE,EL,LT,PT,BG,ES,LU,RO,CZ,FR,HU,SI,DK,HR,MT,SK,DE,IT,NL,FI,EE,CY,AT,SE,IE,LV,PL,GB', ''); \ No newline at end of file diff --git a/src/main/resources/alfio/db/MYSQL/V22_1.15.1__FIX_EU_COUNTRIES_LIST.sql b/src/main/resources/alfio/db/MYSQL/V22_1.15.1__FIX_EU_COUNTRIES_LIST.sql new file mode 100644 index 0000000000..77dec3f42c --- /dev/null +++ b/src/main/resources/alfio/db/MYSQL/V22_1.15.1__FIX_EU_COUNTRIES_LIST.sql @@ -0,0 +1,19 @@ +-- +-- This file is part of alf.io. +-- +-- alf.io is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- alf.io is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with alf.io. If not, see . +-- + +delete from configuration where c_key = 'EU_COUNTRIES_LIST'; +insert into configuration(c_key, c_value, description) values('EU_COUNTRIES_LIST', 'BE,EL,LT,PT,BG,ES,LU,RO,CZ,FR,HU,SI,DK,HR,MT,SK,DE,IT,NL,FI,EE,CY,AT,SE,IE,LV,PL,GB', ''); \ No newline at end of file diff --git a/src/main/resources/alfio/db/PGSQL/V22_1.15.1__FIX_EU_COUNTRIES_LIST.sql b/src/main/resources/alfio/db/PGSQL/V22_1.15.1__FIX_EU_COUNTRIES_LIST.sql new file mode 100644 index 0000000000..77dec3f42c --- /dev/null +++ b/src/main/resources/alfio/db/PGSQL/V22_1.15.1__FIX_EU_COUNTRIES_LIST.sql @@ -0,0 +1,19 @@ +-- +-- This file is part of alf.io. +-- +-- alf.io is free software: you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation, either version 3 of the License, or +-- (at your option) any later version. +-- +-- alf.io is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with alf.io. If not, see . +-- + +delete from configuration where c_key = 'EU_COUNTRIES_LIST'; +insert into configuration(c_key, c_value, description) values('EU_COUNTRIES_LIST', 'BE,EL,LT,PT,BG,ES,LU,RO,CZ,FR,HU,SI,DK,HR,MT,SK,DE,IT,NL,FI,EE,CY,AT,SE,IE,LV,PL,GB', ''); \ No newline at end of file diff --git a/src/main/resources/alfio/i18n/public.properties b/src/main/resources/alfio/i18n/public.properties index a8f100adf9..7eae608cc1 100644 --- a/src/main/resources/alfio/i18n/public.properties +++ b/src/main/resources/alfio/i18n/public.properties @@ -355,4 +355,6 @@ invoice.refund=This invoice has been updated after the cancellation of one or mo reservation-page.privacy.prefix=I have read and agree to the reservation-page.privacy.link.text=privacy policy reservation-page.privacy.suffix=. -reservation-page.country.select=Please select the Country \ No newline at end of file +reservation-page.country.select=Please select the Country +reservation-page.eu-countries=EU countries +reservation-page.all-countries=All the countries \ No newline at end of file diff --git a/src/main/resources/alfio/i18n/public_de.properties b/src/main/resources/alfio/i18n/public_de.properties index 1213cf77cc..9141464cca 100644 --- a/src/main/resources/alfio/i18n/public_de.properties +++ b/src/main/resources/alfio/i18n/public_de.properties @@ -346,3 +346,5 @@ invoice.refund=Diese Rechnung wurde aktualisiert nach eine Storno/R\u00FCckzalun reservation-page.privacy.prefix=Ich habe gelesen und stimme zur reservation-page.privacy.link.text=Datenschutzerkl\u00E4rung reservation-page.privacy.suffix=. +reservation-page.eu-countries=EU Staaten +reservation-page.all-countries=alle Länder diff --git a/src/main/resources/alfio/i18n/public_fr.properties b/src/main/resources/alfio/i18n/public_fr.properties index bb8057b1bf..0b8d2b3816 100644 --- a/src/main/resources/alfio/i18n/public_fr.properties +++ b/src/main/resources/alfio/i18n/public_fr.properties @@ -355,4 +355,6 @@ invoice.refund=Cette facture a \u00E9t\u00E9 modifi\u00E9e suite \u00E0 l'annula reservation-page.privacy.prefix=Vous avez lu et acc\u00E9ptez les reservation-page.privacy.link.text=r\u00E8gles de confidentialit\u00E9 reservation-page.privacy.suffix=. -reservation-page.country.select=veuillez s\u00E9lectionner le pays \ No newline at end of file +reservation-page.country.select=veuillez s\u00E9lectionner le pays +reservation-page.eu-countries=Pays UE +reservation-page.all-countries=Tout les pays \ No newline at end of file diff --git a/src/main/resources/alfio/i18n/public_it.properties b/src/main/resources/alfio/i18n/public_it.properties index d4c84f726a..e020cbdead 100644 --- a/src/main/resources/alfio/i18n/public_it.properties +++ b/src/main/resources/alfio/i18n/public_it.properties @@ -340,3 +340,5 @@ reservation-page.privacy.prefix=Ho letto ed accetto reservation-page.privacy.link.text=l''informativa sulla privacy reservation-page.privacy.suffix=. reservation-page.country.select=Seleziona una nazione +reservation-page.eu-countries=Paesi UE +reservation-page.all-countries=Tutti i paesi diff --git a/src/main/resources/alfio/i18n/public_nl.properties b/src/main/resources/alfio/i18n/public_nl.properties index e74dc355fc..18fcec1501 100644 --- a/src/main/resources/alfio/i18n/public_nl.properties +++ b/src/main/resources/alfio/i18n/public_nl.properties @@ -350,3 +350,6 @@ reservation-page.privacy.prefix=Ik ga akkoord met de reservation-page.privacy.link.text=Privacybeleid reservation-page.privacy.suffix=. reservation-page.country.select=Selecteer alstublieft een land +reservation-page.eu-countries=EU landen +reservation-page.all-countries=alle landen + diff --git a/src/main/webapp/WEB-INF/templates/event/reservation-page.ms b/src/main/webapp/WEB-INF/templates/event/reservation-page.ms index 724e6be24a..f8afb380ca 100644 --- a/src/main/webapp/WEB-INF/templates/event/reservation-page.ms +++ b/src/main/webapp/WEB-INF/templates/event/reservation-page.ms @@ -272,9 +272,16 @@