diff options
author | Christopher Burger <burgerc@freeside.biz> | 2019-03-15 11:29:50 -0400 |
---|---|---|
committer | Christopher Burger <burgerc@freeside.biz> | 2019-03-15 11:29:50 -0400 |
commit | 38f5c59a6a3b92881c0f60bc8dccc9acd0feef41 (patch) | |
tree | 42ba5cacaead27b0bf05fadaa0fc5a664c79d9dd /FS/FS | |
parent | bb201b08e3f48784cd77979dd4e31e866aa4f15d (diff) |
RT# 83044 - fixed cc refund issues
Diffstat (limited to 'FS/FS')
-rw-r--r-- | FS/FS/cust_main/Billing_Batch.pm | 2 | ||||
-rw-r--r-- | FS/FS/cust_pay_batch.pm | 3 | ||||
-rw-r--r-- | FS/FS/pay_batch.pm | 24 |
3 files changed, 25 insertions, 4 deletions
diff --git a/FS/FS/cust_main/Billing_Batch.pm b/FS/FS/cust_main/Billing_Batch.pm index c1bb35f04..c8292cd1b 100644 --- a/FS/FS/cust_main/Billing_Batch.pm +++ b/FS/FS/cust_main/Billing_Batch.pm @@ -151,7 +151,7 @@ sub batch_card { ), 'exp' => $options{paydate} || $cust_payby->paydate, 'payname' => $options{payname} || $cust_payby->payname, - 'paytype' => $options{paytype} || $cust_payby->paytype, + 'paytype' => $options{paytype} || $cust_payby->{'Hash'}->{'paytype'}, 'amount' => $amount, # consolidating 'paycode' => $options{paycode} || '', } ); diff --git a/FS/FS/cust_pay_batch.pm b/FS/FS/cust_pay_batch.pm index 6e76b3462..2931fe79d 100644 --- a/FS/FS/cust_pay_batch.pm +++ b/FS/FS/cust_pay_batch.pm @@ -293,6 +293,9 @@ sub approve { if ( $error ) { return "error approving paybatchnum $paybatchnum: $error\n"; } + + return if $new->paycode eq "C"; + my $cust_pay = new FS::cust_pay ( { 'custnum' => $new->custnum, 'payby' => $new->payby, diff --git a/FS/FS/pay_batch.pm b/FS/FS/pay_batch.pm index d0ed7ae2d..0df9c7a23 100644 --- a/FS/FS/pay_batch.pm +++ b/FS/FS/pay_batch.pm @@ -1278,20 +1278,38 @@ sub _upgrade_data { my $error = $pay_batch->insert; if ( $error ) { $dbh->rollback if $oldAutoCommit; - warn "error creating a credit batch: $error\n"; + warn "error creating a check credit batch: $error\n"; + } + } + + my %card_pay_batch = ( + 'status' => 'O', + 'payby' => 'CARD', + 'type' => 'CREDIT', + ); + + my $card_pay_batch = qsearchs( 'pay_batch', \%card_pay_batch ); + + unless ( $card_pay_batch ) { + $card_pay_batch = new FS::pay_batch \%card_pay_batch; + my $error = $card_pay_batch->insert; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + warn "error creating a card credit batch: $error\n"; } } my $replace_error; foreach my $cust_pay_batch (@batch_refunds) { - $cust_pay_batch->batchnum($pay_batch->batchnum); + if ($cust_pay_batch->payby eq "CARD") { $cust_pay_batch->batchnum($card_pay_batch->batchnum); } + else { $cust_pay_batch->batchnum($pay_batch->batchnum); } $replace_error = $cust_pay_batch->replace(); if ( $replace_error ) { $dbh->rollback if $oldAutoCommit; warn "Unable o move credit to a credit batch: $replace_error"; } else { - warn "Moved cust pay credit ".$cust_pay_batch->paybatchnum." to credit batch ".$cust_pay_batch->batchnum."\n"; + warn "Moved cust pay credit ".$cust_pay_batch->paybatchnum." to ".$cust_pay_batch->payby." credit batch ".$cust_pay_batch->batchnum."\n"; } } |