stop making spurious extra contacts
authorIvan Kohler <ivan@freeside.biz>
Tue, 30 Aug 2016 02:05:42 +0000 (19:05 -0700)
committerIvan Kohler <ivan@freeside.biz>
Tue, 30 Aug 2016 02:05:42 +0000 (19:05 -0700)
FS/FS/cust_main.pm

index 2af6a1f..7bbed1b 100644 (file)
@@ -598,17 +598,21 @@ sub insert {
       }
     }
 
-    my $contact = FS::contact->new({
-      'custnum'       => $self->get('custnum'),
-      'last'          => $self->get('last'),
-      'first'         => $self->get('first'),
-      'emailaddress'  => $email,
-      'invoice_dest'  => 'Y', # yes, you can set this via the contact
-    });
-    my $error = $contact->insert;
-    if ( $error ) {
-      $dbh->rollback if $oldAutoCommit;
-      return $error;
+    if ( $email ) {
+
+      my $contact = FS::contact->new({
+        'custnum'       => $self->get('custnum'),
+        'last'          => $self->get('last'),
+        'first'         => $self->get('first'),
+        'emailaddress'  => $email,
+        'invoice_dest'  => 'Y', # yes, you can set this via the contact
+      });
+      my $error = $contact->insert;
+      if ( $error ) {
+        $dbh->rollback if $oldAutoCommit;
+        return $error;
+      }
+
     }
 
   }