diff --git a/src/main/java/alfio/controller/ReservationController.java b/src/main/java/alfio/controller/ReservationController.java index 4091f6b239..757957a539 100644 --- a/src/main/java/alfio/controller/ReservationController.java +++ b/src/main/java/alfio/controller/ReservationController.java @@ -270,8 +270,6 @@ public String validateToOverview(@PathVariable("eventName") String eventName, @P Configuration.ConfigurationPathKey invoiceOnlyKey = Configuration.from(event.getOrganizationId(), event.getId(), ConfigurationKeys.GENERATE_ONLY_INVOICE); boolean invoiceOnly = configurationManager.getBooleanConfigValue(invoiceOnlyKey, false); - final boolean companyVatChecked = invoiceOnly ? contactAndTicketsForm.isAddCompanyBillingDetails() : contactAndTicketsForm.isInvoiceRequested(); - if(invoiceOnly && reservationCost.getPriceWithVAT() > 0) { //override, that's why we save it contactAndTicketsForm.setInvoiceRequested(true); @@ -284,7 +282,7 @@ public String validateToOverview(@PathVariable("eventName") String eventName, @P contactAndTicketsForm.getBillingAddressCompany(), contactAndTicketsForm.getBillingAddressLine1(), contactAndTicketsForm.getBillingAddressLine2(), contactAndTicketsForm.getBillingAddressZip(), contactAndTicketsForm.getBillingAddressCity(), contactAndTicketsForm.getVatCountryCode(), contactAndTicketsForm.getCustomerReference(), contactAndTicketsForm.getVatNr(), contactAndTicketsForm.isInvoiceRequested(), - contactAndTicketsForm.isAddCompanyBillingDetails(), false); + contactAndTicketsForm.canSkipVatNrCheck(), false); assignTickets(event.getShortName(), reservationId, contactAndTicketsForm, bindingResult, request, true, true); // diff --git a/src/main/java/alfio/controller/form/ContactAndTicketsForm.java b/src/main/java/alfio/controller/form/ContactAndTicketsForm.java index 1f83602fea..361ebbf49f 100644 --- a/src/main/java/alfio/controller/form/ContactAndTicketsForm.java +++ b/src/main/java/alfio/controller/form/ContactAndTicketsForm.java @@ -59,7 +59,7 @@ public class ContactAndTicketsForm implements Serializable { private String billingAddressZip; private String billingAddressCity; - private boolean addCompanyBillingDetails = false; + private Boolean skipVatNr; private Boolean backFromOverview; private static void rejectIfOverLength(BindingResult bindingResult, String field, String errorCode, @@ -114,6 +114,15 @@ public void validate(BindingResult bindingResult, Event event, List. +-- + +alter table tickets_reservation add column skip_vat_nr boolean; +alter table tickets_reservation drop column add_company_billing_details; + + +drop view if exists reservation_and_ticket_and_tx; +drop view if exists ticket_and_reservation_and_tx; diff --git a/src/main/resources/alfio/i18n/public.properties b/src/main/resources/alfio/i18n/public.properties index b6f4ef9e9a..b9f611b394 100644 --- a/src/main/resources/alfio/i18n/public.properties +++ b/src/main/resources/alfio/i18n/public.properties @@ -375,4 +375,5 @@ reservation-page.city=City reservation-page.invoice-details=Invoice details reservation-page.if-applicable=if applicable error.emptyField=This field is required -error.tooLong=The value is too long \ No newline at end of file +error.tooLong=The value is too long +reservation-page.skipVatNr=I don''t have a {0} number \ 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 4f3a21eda9..8dcd1ca2c1 100644 --- a/src/main/resources/alfio/i18n/public_de.properties +++ b/src/main/resources/alfio/i18n/public_de.properties @@ -364,4 +364,5 @@ reservation-page.city=[DE]-City reservation-page.invoice-details=[DE]-Invoice details reservation-page.if-applicable=[DE]-if applicable error.emptyField=[DE]-This field is required -error.tooLong=[DE]-The value is too long \ No newline at end of file +error.tooLong=[DE]-The value is too long +reservation-page.skipVatNr=[DE]-I don''t have a {0} number \ No newline at end of file diff --git a/src/main/resources/alfio/i18n/public_fr.properties b/src/main/resources/alfio/i18n/public_fr.properties index 87c90b0485..a5c9536f0d 100644 --- a/src/main/resources/alfio/i18n/public_fr.properties +++ b/src/main/resources/alfio/i18n/public_fr.properties @@ -374,4 +374,5 @@ reservation-page.city=[FR]-City reservation-page.invoice-details=[FR]-Invoice details reservation-page.if-applicable=[FR]-if applicable error.emptyField=[FR]-This field is required -error.tooLong=[FR]-The value is too long \ No newline at end of file +error.tooLong=[FR]-The value is too long +reservation-page.skipVatNr=[FR]-I don''t have a {0} number \ 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 c5249cc5fa..065bddb26d 100644 --- a/src/main/resources/alfio/i18n/public_it.properties +++ b/src/main/resources/alfio/i18n/public_it.properties @@ -359,4 +359,5 @@ reservation-page.city=[IT]-City reservation-page.invoice-details=[IT]-Invoice details reservation-page.if-applicable=[IT]-if applicable error.emptyField=[IT]-This field is required -error.tooLong=[IT]-The value is too long \ No newline at end of file +error.tooLong=[IT]-The value is too long +reservation-page.skipVatNr=[IT]-I don''t have a {0} number \ No newline at end of file diff --git a/src/main/resources/alfio/i18n/public_nl.properties b/src/main/resources/alfio/i18n/public_nl.properties index b9c65125a4..a2f9b347e4 100644 --- a/src/main/resources/alfio/i18n/public_nl.properties +++ b/src/main/resources/alfio/i18n/public_nl.properties @@ -368,4 +368,5 @@ reservation-page.city=[NL]-City reservation-page.invoice-details=[NL]-Invoice details reservation-page.if-applicable=[NL]-if applicable error.emptyField=[NL]-This field is required -error.tooLong=[NL]-The value is too long \ No newline at end of file +error.tooLong=[NL]-The value is too long +reservation-page.skipVatNr=[NL]-I don''t have a {0} number \ No newline at end of file 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 e58daa1644..5073f9b8c3 100644 --- a/src/main/webapp/WEB-INF/templates/event/reservation-page.ms +++ b/src/main/webapp/WEB-INF/templates/event/reservation-page.ms @@ -172,9 +172,8 @@
-
+
- + {{#field-has-error}}[vatCountryCode]{{#i18n}}{{#field-error}}vatCountryCode{{/field-error}}{{/i18n}}{{/field-has-error}}
{{#customerReferenceEnabled}} @@ -198,20 +198,10 @@
{{/customerReferenceEnabled}}
-
-
- -
- -
-
-
+
-
+
@@ -221,6 +211,16 @@ {{#field-has-error}}[vatNr]{{#i18n}}{{#field-error}}vatNr{{/field-error}}{{/i18n}}{{/field-has-error}}
+
+
+
+ +
+
+
{{/onlyInvoice}} @@ -282,9 +282,8 @@
-
+
- + {{#field-has-error}}[vatCountryCode]{{#i18n}}{{#field-error}}vatCountryCode{{/field-error}}{{/i18n}}{{/field-has-error}}
{{#customerReferenceEnabled}} @@ -310,7 +310,7 @@
-
+
@@ -320,6 +320,16 @@ {{#field-has-error}}[vatNr]{{#i18n}}{{#field-error}}vatNr{{/field-error}}{{/i18n}}{{/field-has-error}}
+
+
+
+ +
+
+
diff --git a/src/main/webapp/resources/css/application.css b/src/main/webapp/resources/css/application.css index 9b814068f2..fbed516b12 100644 --- a/src/main/webapp/resources/css/application.css +++ b/src/main/webapp/resources/css/application.css @@ -208,4 +208,13 @@ html[lang=it] .alfio-lang a[lang=it] { .form-horizontal .control-label.category-name { text-align:left; +} + +.checkbox-in-form-group { + margin-top:30px; +} + +.checkbox-in-form-group label { + padding-left:20px; + font-weight:normal; } \ No newline at end of file diff --git a/src/main/webapp/resources/js/event/reservation-page.js b/src/main/webapp/resources/js/event/reservation-page.js index 48a7598374..954f742ced 100644 --- a/src/main/webapp/resources/js/event/reservation-page.js +++ b/src/main/webapp/resources/js/event/reservation-page.js @@ -115,22 +115,6 @@ } }); }; - - $("form").each(createAllErrors); - $("input,select,textarea").change(function() { - if( !this.validity.valid) { - $(this).parent().addClass('has-error'); - if($(this).parent().parent().parent().hasClass('form-group')) { - $(this).parent().parent().parent().addClass('has-error'); - } - } else { - $(this).parent().removeClass('has-error'); - if($(this).parent().parent().parent().hasClass('form-group')) { - $(this).parent().parent().parent().removeClass('has-error'); - } - } - }); - $('#first-name.autocomplete-src, #last-name.autocomplete-src').change(function() { @@ -189,151 +173,7 @@ } - /*function disableBillingFields() { - $('#vatNr,#vatCountryCode').attr('required', false).attr('disabled', ''); - } - - disableBillingFields(); - - $('#invoice-requested').change(function() { - var element = $('#invoice'); - if($(this).is(':checked')) { - element.find('.field-required').attr('required', true); - element.removeClass('hidden'); - euBillingCountry.change(); - if(euBillingCountry.length === 0) { - //$('#billing-address-container').removeClass(hiddenClasses); - $('#billing-address').attr('required', true).removeAttr('disabled'); - } else { - $('#continue-button').attr('disabled', true); - } - } else { - element.find('.field-required').attr('required', false); - $('#billing-address').attr('required', false).attr('disabled'); - element.addClass('hidden'); - disableBillingFields(); - $('#continue-button').removeAttr('disabled'); - } - }); - - var euBillingCountry = $('#vatCountry'); - euBillingCountry.change(function() { - if($(this).val() === '') { - //$('#billing-address-container').removeClass(hiddenClasses); - $('#billing-address').attr('required', true).removeAttr('disabled'); - $('#validation-result-container, #vat-number-container, #validateVAT').addClass(hiddenClasses); - $('#vatNr').attr('required', false).attr('disabled', ''); - $("#vatCountryCode").attr('required', false).attr('disabled', ''); - } else { - $('#billing-address-container').addClass(hiddenClasses); - $('#validation-result-container, #vat-number-container, #validateVAT').removeClass(hiddenClasses); - $('#billing-address').attr('required', false).attr('disabled'); - $('#vatNr').attr('required', true).removeAttr('disabled'); - $("#vatCountryCode").attr('required', true).removeAttr('disabled', ''); - var countryCode = $(this).val(); - var validateVATButton = $("#validateVAT"); - if($("#optgroup-eu-countries-list option[value="+countryCode+"]").length === 1) { - validateVATButton.text(validateVATButton.attr('data-text')); - } else { - validateVATButton.text(validateVATButton.attr('data-text-non-eu')); - } - } - }); - - var invoiceOnlyMode = $('#invoice-requested[type=hidden]') && $('#invoice-requested[type=hidden]').val() == 'true'; - - var euVATCheckingEnabled = $("#invoice[data-eu-vat-checking-enabled=true]").length === 1; - - if(!invoiceOnlyMode && euVATCheckingEnabled && $("input[type=hidden][name=vatNr]").length === 0) { - $("#billing-address-container").addClass(hiddenClasses); - } - - // invoice only mode - if(invoiceOnlyMode) { - $('#billing-address').attr('required', true).removeAttr('disabled'); - $('#billing-address-container').removeClass(hiddenClasses); - $('#invoice').removeClass('hidden'); - $("#eu-vat-check-countries").addClass(hiddenClasses); - } - - $("#add-company-billing-details").change(function() { - if($(this).is(':checked')) { - $('#billing-address').attr('required', false).attr('disabled'); - $('#billing-address-container').addClass(hiddenClasses); - $("#eu-vat-check-countries").removeClass(hiddenClasses); - $('#continue-button').attr('disabled', true); - if(euVATCheckingEnabled) { - $("#vatCountry").attr('required', true).removeAttr('disabled', ''); - } - } else { - $('#continue-button').attr('disabled', false); - $('#billing-address').attr('required', true).removeAttr('disabled'); - $('#billing-address-container').removeClass(hiddenClasses); - $("#eu-vat-check-countries").addClass(hiddenClasses); - $("#vatCountry").removeAttr('required').removeAttr('disabled', ''); - } - }); - // - - $('#validateVAT').click(function() { - var frm = $(this.form); - var action = $(this).attr('data-validation-url'); - var vatInput = $('#vatNr'); - vatInput.removeClass('has-error'); - vatInput.parent('div').removeClass('has-error'); - var vatNr = vatInput.val(); - var country = euBillingCountry.val(); - var resultContainer = $('#validation-result'); - if(vatNr !== '' && country !== '') { - var btn = $(this); - var previousText = btn.text(); - btn.html(''); - $('#continue-button').attr('disabled', true); - jQuery.ajax({ - url: action, - type: 'POST', - data: frm.serialize(), - success: function() { - window.location.reload(); - }, - error: function(xhr, textStatus, errorThrown) { - vatInput.addClass('has-error'); - vatInput.parent('div').addClass('has-error'); - if(xhr.status === 400) { - resultContainer.html(resultContainer.attr('data-validation-error-msg')); - } else if (xhr.status === 503) { - resultContainer.html(resultContainer.attr('data-vies-down')); - } else { - resultContainer.html(resultContainer.attr('data-generic-error-msg')); - } - }, - complete: function(xhr) { - btn.text(previousText); - var vatInput = $('#vatNr'); - if(vatInput.hasClass('has-error')) { - $('#continue-button').attr('disabled', true); - } else { - $('#continue-button').attr('disabled', false); - } - } - - }); - } - }) - - $('#reset-billing-information').click(function() { - var action = $(this).attr('data-reset-billing-information-url'); - var frm = $(this.form); - jQuery.ajax({ - url: action, - type:'POST', - success: function() { - window.location.reload(); - }, - data:frm.serialize() - }); - });*/ $("select").map(function() { var value = $(this).attr('value'); @@ -362,35 +202,21 @@ $("#vatCountry").change(); $("#invoice-requested").change(); - }); - - /*window.recaptchaLoadCallback = function() { - window.recaptchaReady = true; - var methods = $('input[name=paymentMethod]'); - if(methods.length === 1) { - methodSelected(methods.val()); - } else if(methods.length === 0) { - $('#captcha-FREE').each(function(e) { - methodSelected('FREE'); - }); - } - }; - - var methodSelected = function(method) { - if((method === 'FREE' || method === 'OFFLINE' || method === 'ON_SITE') && window.recaptchaReady) { - $('.g-recaptcha').each(function(i, e) { - try { - grecaptcha.reset(e.id); - } catch(x) {} - }); - try { - grecaptcha.render('captcha-'+method, { - 'sitekey': $('#captcha-'+method).attr('data-sitekey'), - 'hl': $('html').attr('lang') - }); - } catch(x) {} - } - };*/ + $("form").each(createAllErrors); + $("input,select,textarea").change(function() { + if( !this.validity.valid) { + $(this).parent().addClass('has-error'); + if($(this).parent().parent().parent().hasClass('form-group')) { + $(this).parent().parent().parent().addClass('has-error'); + } + } else { + $(this).parent().removeClass('has-error'); + if($(this).parent().parent().parent().hasClass('form-group')) { + $(this).parent().parent().parent().removeClass('has-error'); + } + } + }); + }); })(); \ No newline at end of file