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