Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / FS / FS / cust_main.pm
index 23d54b6..925eb4e 100644 (file)
@@ -1523,8 +1523,10 @@ sub replace {
                                  custnum     => $self->custnum,
                                }
       );
-    $implicit_contact->set($_, $i_cust_contact->$_)
-      foreach qw( classnum selfservice_access comment );
+    if ( $i_cust_contact ) {
+      $implicit_contact->set($_, $i_cust_contact->$_)
+        foreach qw( classnum selfservice_access comment );
+    }
 
     my $error;
     if ( $implicit_contact->contactnum ) {
@@ -4615,6 +4617,8 @@ PAYBYLOOP:
         next if grep(/^$field$/, qw( custpaybynum payby weight ) );
         next if grep(/^$field$/, @preserve );
         next PAYBYLOOP unless $new->get($field) eq $cust_payby->get($field);
+        # check if paymask exists,  if so stop and don't save, no need for a duplicate.
+        return '' if $new->get('paymask') eq $cust_payby->get('paymask');
       }
       # now check fields that can replace if one value is blank
       my $replace = 0;