forked from CGM_Public/pretix_original
Invoice address: Add convenient autofill for Pepppol in Belgium (Z#23220397) (#5809)
* Invoice address: Add convenient autofill for Pepppol in Belgium (Z#23220397) * Update src/pretix/static/pretixbase/js/addressform.js Co-authored-by: Richard Schreiber <schreiber@pretix.eu> --------- Co-authored-by: Richard Schreiber <schreiber@pretix.eu>
This commit is contained in:
@@ -166,6 +166,23 @@ $(function () {
|
||||
};
|
||||
update();
|
||||
dependencies.on("change", update);
|
||||
|
||||
if (dependents.vat_id && dependents.transmission_type && dependents.transmission_peppol_participant_id) {
|
||||
// In Belgium, the VAT ID is built from "BE" + the company ID. The Peppol ID also needs to be built
|
||||
// from the company ID with ID scheme 0208. We can save users some knowing and typing by filling this in!
|
||||
if (!dependents.transmission_peppol_participant_id.val()) {
|
||||
const fill_peppol_id = function () {
|
||||
const vatId = dependents.vat_id.val();
|
||||
if (vatId && vatId.startsWith("BE") && dependents.transmission_type.val() === "peppol" && autofill_peppol_id) {
|
||||
dependents.transmission_peppol_participant_id.val("0201:" + vatId.substring(2))
|
||||
}
|
||||
}
|
||||
dependents.vat_id.add(dependents.transmission_type).on("change", fill_peppol_id);
|
||||
dependents.transmission_peppol_participant_id.one("change", () => {
|
||||
dependents.vat_id.add(dependents.transmission_type).unbind("change", fill_peppol_id)
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user