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 ) {
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;
# at the time we do this, also migrate paytype into cust_pay_batch
# so that batches that are open before the migration can still be
# processed
- my @cust_pay_batch = qsearch('cust_pay_batch', {
- 'custnum' => $cust_main->custnum,
- 'payby' => 'CHEK',
- 'paytype' => '',
- });
- foreach my $cust_pay_batch (@cust_pay_batch) {
- $cust_pay_batch->set('paytype', $cust_main->get('paytype'));
- my $error = $cust_pay_batch->replace;
- die "$error (setting cust_pay_batch.paytype)" if $error;
+ if ( $cust_main->get('paytype') ) {
+ my @cust_pay_batch = qsearch('cust_pay_batch', {
+ 'custnum' => $cust_main->custnum,
+ 'payby' => 'CHEK',
+ 'paytype' => '',
+ });
+ foreach my $cust_pay_batch (@cust_pay_batch) {
+ $cust_pay_batch->set('paytype', $cust_main->get('paytype'));
+ my $error = $cust_pay_batch->replace;
+ die "$error (setting cust_pay_batch.paytype)" if $error;
+ }
}
$cust_main->complimentary('Y') if $cust_main->payby eq 'COMP';