From 3d44994029eca9d82030740d7feed1506c52b0b4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Tue, 10 Oct 2017 11:11:15 +0200 Subject: [PATCH] SL::DB::ShopOrder: Warnings --- SL/DB/ShopOrder.pm | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/SL/DB/ShopOrder.pm b/SL/DB/ShopOrder.pm index e02969486..ee02f3e93 100644 --- a/SL/DB/ShopOrder.pm +++ b/SL/DB/ShopOrder.pm @@ -59,8 +59,8 @@ sub convert_to_sales_order { if(!scalar(@error_report)){ my $shipto_id; - if ($self->billing_firstname ne $self->delivery_firstname || $self->billing_lastname ne $self->delivery_lastname || $self->billing_city ne $self->delivery_city || $self->billing_street ne $self->delivery_street) { - if(my $address = SL::DB::Manager::Shipto->find_by( shiptoname => $self->delivery_firstname . " " . $self->delivery_lastname, + if ($self->has_differing_delivery_address) { + if(my $address = SL::DB::Manager::Shipto->find_by( shiptoname => $self->delivery_fullname, shiptostreet => $self->delivery_street, shiptocity => $self->delivery_city, )) { @@ -68,7 +68,7 @@ sub convert_to_sales_order { } else { my $deliveryaddress = SL::DB::Shipto->new; $deliveryaddress->assign_attributes( - shiptoname => $self->delivery_firstname . " " . $self->delivery_lastname, + shiptoname => $self->delivery_fullname, shiptodepartment_1 => $self->delivery_company, shiptodepartment_2 => $self->delivery_department, shiptostreet => $self->delivery_street, @@ -245,6 +245,18 @@ sub check_trgm { return 0; } +sub has_differing_delivery_address { + my ($self) = @_; + ($self->billing_firstname // '') ne ($self->delivery_firstname // '') || + ($self->billing_lastname // '') ne ($self->delivery_lastname // '') || + ($self->billing_city // '') ne ($self->delivery_city // '') || + ($self->billing_street // '') ne ($self->delivery_street // '') +} + +sub delivery_fullname { + ($_[0]->delivery_firstname // '') . " " . ($_[0]->delivery_lastname // '') +} + 1; __END__ -- 2.20.1