From: Ivan Kohler Date: Tue, 30 Aug 2016 02:05:44 +0000 (-0700) Subject: stop making spurious extra contacts X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=c85feb8ed34e07182695757322dfe132f6485045 stop making spurious extra contacts --- diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 1253ac3b1..25b3d0804 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -597,17 +597,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; + } + } }