Ask only for VAT ID if company is inside EU (#1709)

Co-authored-by: Andreas Teuber <andreas.teuber@passiv.de>
Co-authored-by: Raphael Michel <mail@raphaelmichel.de>
This commit is contained in:
Andreas Teuber
2020-07-13 18:04:09 +02:00
committed by GitHub
parent b2401f7641
commit 4746b8e456
4 changed files with 46 additions and 5 deletions

View File

@@ -314,6 +314,24 @@ var form_handlers = function (el) {
dependency.closest('.form-group').find('input[name=' + dependency.attr("name") + ']').on("dp.change", update);
});
$("input[name$=vat_id][data-countries-in-eu]").each(function () {
var dependent = $(this),
dependency_country = $(this).closest(".panel-body, form").find('select[name$=country]'),
dependency_id_is_business_1 = $(this).closest(".panel-body, form").find('input[id$=id_is_business_1]'),
update = function (ev) {
if (dependency_id_is_business_1.length && !dependency_id_is_business_1.prop("checked")) {
dependent.closest(".form-group").hide();
} else if (dependent.attr('data-countries-in-eu').split(',').includes(dependency_country.val())) {
dependent.closest(".form-group").show();
} else {
dependent.closest(".form-group").hide();
}
};
update();
dependency_country.on("change", update);
dependency_id_is_business_1.on("change", update);
});
$("select[name$=state]:not([data-static])").each(function () {
var dependent = $(this),
counter = 0,