X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_pay.pm;h=ab8113381a4ce94326b5967901f56b89d3e9d639;hb=c2e0c1d06e2a9b9146f9b538ce07f57664e16966;hp=acb2844290b39934a652f8ee14df5423f2b3b404;hpb=41ed76e0e3625c9f175743d253ad06fc67302d0f;p=freeside.git diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index acb284429..ab8113381 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -673,7 +673,9 @@ sub _upgrade_data { #class method #not the most efficient, but hey, it only has to run once - my $where = "WHERE otaker IS NULL OR otaker = '' OR otaker = 'ivan' "; + my $where = "WHERE ( otaker IS NULL OR otaker = '' OR otaker = 'ivan' ) ". + " AND 0 < ( SELECT COUNT(*) FROM cust_main ". + " WHERE cust_main.custnum = cust_pay.custnum ) "; my $count_sql = "SELECT COUNT(*) FROM cust_pay $where"; @@ -685,19 +687,19 @@ sub _upgrade_data { #class method my $count = 0; my $lastprog = 0; - while (1) { - my $cust_pay = qsearchs( { + my @cust_pay = qsearch( { 'table' => 'cust_pay', 'hashref' => {}, 'extra_sql' => $where, - 'order_by' => 'ORDER BY paynum LIMIT 1', - } ); + 'order_by' => 'ORDER BY paynum', + } ); - return unless $cust_pay; + foreach my $cust_pay (@cust_pay) { my $h_cust_pay = $cust_pay->h_search('insert'); if ( $h_cust_pay ) { + next if $cust_pay->otaker eq $h_cust_pay->history_user; $cust_pay->otaker($h_cust_pay->history_user); } else { $cust_pay->otaker('legacy'); @@ -705,7 +707,13 @@ sub _upgrade_data { #class method delete $FS::payby::hash{'COMP'}->{cust_pay}; #quelle kludge my $error = $cust_pay->replace; - die $error if $error; + + if ( $error ) { + warn " *** WARNING: Error updaating order taker for payment paynum". + $cust_pay->paynun. ": $error\n"; + next; + } + $FS::payby::hash{'COMP'}->{cust_pay} = ''; #restore it $count++;