From: Jan Büren Date: Thu, 4 Sep 2014 14:54:12 +0000 (+0200) Subject: undefs für find_by berücksichtigen X-Git-Tag: release-3.2.0beta~317 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=a4e4f1a7ca65293cc7f3c45e29fc31571b4e91dd;p=kivitendo-erp.git undefs für find_by berücksichtigen --- diff --git a/SL/IS.pm b/SL/IS.pm index f6115a81d..e3ed35ff0 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -492,17 +492,21 @@ sub customer_details { ORDER BY cp.cp_id LIMIT 1|; my $ref = selectfirst_hashref_query($form, $dbh, $query, @values); - # we have no values, probably a invalid contact person. hotfix and first idea for issue #9 + # we have no values, probably a invalid contact person. hotfix and first idea for issue #10 if (!$ref) { my $customer = SL::DB::Manager::Customer->find_by(id => $::form->{customer_id}); - $ref->{name} = $customer->name; - $ref->{street} = $customer->street; - $ref->{zipcode} = $customer->zipcode; - $ref->{country} = $customer->country; + if ($customer) { + $ref->{name} = $customer->name; + $ref->{street} = $customer->street; + $ref->{zipcode} = $customer->zipcode; + $ref->{country} = $customer->country; + } my $contact = SL::DB::Manager::Contact->find_by(cp_id => $::form->{cp_id}); - $ref->{cp_name} = $contact->cp_name; - $ref->{cp_givenname} = $contact->cp_givenname; - $ref->{cp_gender} = $contact->cp_gender; + if ($contact) { + $ref->{cp_name} = $contact->cp_name; + $ref->{cp_givenname} = $contact->cp_givenname; + $ref->{cp_gender} = $contact->cp_gender; + } } # remove id and taxincluded before copy back delete @$ref{qw(id taxincluded)};