]> wagnertech.de Git - mfinanz.git/blobdiff - SL/IS.pm
Preisfaktoren: Bei neu anlegen auch das Inputfeld anzeigen
[mfinanz.git] / SL / IS.pm
index 6c5aa9ffe70e6826c07a58dd426faaca4167266f..e3ed35ff0d67fa56ca6877f64e8abb94a7b9afe8 100644 (file)
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -492,7 +492,22 @@ 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 #10
+  if (!$ref) {
+    my $customer = SL::DB::Manager::Customer->find_by(id => $::form->{customer_id});
+    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});
+    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)};