X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FClientAPI%2FMyAccount.pm;h=a3198611d4d7c1b8dd82953ccca1d978ae1546bf;hb=889c731e26608ffca1582fe57657e35711fd18b8;hp=5c850301ba3a0982ca7f9f540307af9b15fc7783;hpb=fbe36a956f6e39078c926b8dbbf5d1afca5ea2ea;p=freeside.git diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index 5c850301b..a3198611d 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -1735,9 +1735,6 @@ sub update_payby { $p->{paydate} = $p->{year} . '-' . $p->{month} . '-01' unless $p->{paydate}; } - # Perform update within a transaction - local $FS::UID::AutoCommit = 0; - my $cust_payby = qsearchs('cust_payby', { 'custnum' => $custnum, 'custpaybynum' => $p->{'custpaybynum'}, @@ -1754,26 +1751,23 @@ sub update_payby { $cust_payby->set($field,$p->{$field}); } - my $error = $cust_payby->replace; + # Update column if given a value, and the given value wasn't + # the value generated by $cust_main->masked($column); + $cust_main->set( $_, $p->{$_} ) + for grep{ $p->{$_} !~ /^x/i; } + grep{ exists $p->{$_} } + qw/ss stateid/; - if (!$error) { - my $is_changed = 0; - for my $field ( qw/ss stateid/ ) { - next if !exists $p->{$field} || $p->{$field} =~ /^x/i; - $cust_main->set( $field, $p->{$field} ); - $is_changed = 1; - } - $error = $cust_main->replace if $is_changed; - } + # Perform updates within a transaction + local $FS::UID::AutoCommit = 0; - if ( $error ) { + if ( my $error = $cust_payby->replace || $cust_main->replace ) { dbh->rollback; - return { 'error' => $error }; - } else { - dbh->commit; - return { 'custpaybynum' => $cust_payby->custpaybynum }; + return { error => $error }; } - + + dbh->commit; + return { custpaybynum => $cust_payby->custpaybynum }; } sub verify_payby {