From 373673499958d1b5c5f6551ea2f30539e0ad6382 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 21 Feb 2022 10:09:08 +0100 Subject: [PATCH] =?utf8?q?Kundenstammdaten:=20keine=20leeren=20=C2=BBzus?= =?utf8?q?=C3=A4tzliche=20Rechnungsadressen=C2=AB=20erzeugen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/CustomerVendor.pm | 2 +- ...remove_empty_additional_billing_addresses.sql | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 sql/Pg-upgrade2/customer_remove_empty_additional_billing_addresses.sql diff --git a/SL/Controller/CustomerVendor.pm b/SL/Controller/CustomerVendor.pm index 608803abb..f9e251578 100644 --- a/SL/Controller/CustomerVendor.pm +++ b/SL/Controller/CustomerVendor.pm @@ -283,7 +283,7 @@ sub _save { $self->{shipto}->save(cascade => 1); } - if ($self->is_customer && any { $self->{additional_billing_address}->$_ ne '' } @ADDITIONAL_BILLING_ADDRESS_COLUMNS) { + if ($self->is_customer && any { $self->{additional_billing_address}->$_ ne '' } grep { $_ ne 'default_address' } @ADDITIONAL_BILLING_ADDRESS_COLUMNS) { $self->{additional_billing_address}->customer_id($self->{cv}->id); $self->{additional_billing_address}->save(cascade => 1); diff --git a/sql/Pg-upgrade2/customer_remove_empty_additional_billing_addresses.sql b/sql/Pg-upgrade2/customer_remove_empty_additional_billing_addresses.sql new file mode 100644 index 000000000..bb603582e --- /dev/null +++ b/sql/Pg-upgrade2/customer_remove_empty_additional_billing_addresses.sql @@ -0,0 +1,16 @@ +-- @tag: customer_remove_empty_additional_billing_addresses +-- @description: Leere »zusätzliche Rechnungsadressen« entfernen +-- @depends: customer_additional_billing_addresses +DELETE +FROM additional_billing_addresses +WHERE (coalesce(name, '') = '') + AND (coalesce(department_1, '') = '') + AND (coalesce(department_2, '') = '') + AND (coalesce(contact, '') = '') + AND (coalesce(street, '') = '') + AND (coalesce(zipcode, '') = '') + AND (coalesce(city, '') = '') + AND (coalesce(country, '') = '') + AND (coalesce(email, '') = '') + AND (coalesce(phone, '') = '') + AND (coalesce(fax, '') = ''); -- 2.20.1