From c348008de567bbede345c2fa861c4d3694f8b1d3 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Mon, 29 Aug 2016 19:05:42 -0700 Subject: [PATCH] stop making spurious extra contacts --- FS/FS/cust_main.pm | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) 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; + } + } } -- 2.11.0