+
+ open my $fh, "<$tmpdir/$filename";
+ # Some duplication with FS::pay_batch::import_results, but we're really
+ # doing something different here.
+ my $csv = new Text::CSV_XS ( { quote_char => undef, sep_char => '|' } );
+ my %hash;
+ while (my $line = <$fh>) {
+ next if $line =~ /^\s*$/;
+ $csv->parse($line) or do {
+ log_info( "can't parse $filename: ".$csv->error_input."\n" );
+ next FILE; #parsing errors = reading the wrong kind of file
+ };
+ @hash{@fields} = $csv->fields();
+ log_info( "voiding paybatchnum#$hash{paybatchnum}\n" );
+ my $cpb = qsearchs('cust_pay_batch',
+ { paybatchnum => $hash{'paybatchnum'} });
+ if ( !$cpb ) {
+ log_info(
+ "can't find paybatchnum #$hash{paybatchnum} ".
+ "($hash{first} $hash{last}, $hash{paid})\n"
+ );
+ next;
+ }
+ my $error = $cpb->decline("Returned payment ($hash{returncode})");
+ if ( $error ) {
+ log_info( "can't void paybatchnum #$hash{paybatchnum}: $error\n" );
+ }
+ }
+ close $fh;