From: Moritz Bunkus Date: Mon, 21 Feb 2022 09:09:08 +0000 (+0100) Subject: Kundenstammdaten: keine leeren »zusätzliche Rechnungsadressen« erzeugen X-Git-Tag: kivitendo-mebil_0.1-0~10^2~2^2~179 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=373673499958d1b5c5f6551ea2f30539e0ad6382;p=kivitendo-erp.git Kundenstammdaten: keine leeren »zusätzliche Rechnungsadressen« erzeugen --- 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, '') = '');