summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/cust_main/Billing_Batch.pm2
-rw-r--r--FS/FS/cust_pay_batch.pm3
-rw-r--r--FS/FS/pay_batch.pm24
-rwxr-xr-xFS/bin/freeside-paymentech-upload13
-rwxr-xr-xFS/bin/freeside-rbc-upload15
5 files changed, 48 insertions, 9 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";
}
}
diff --git a/FS/bin/freeside-paymentech-upload b/FS/bin/freeside-paymentech-upload
index 9903dd4aa..283781dbf 100755
--- a/FS/bin/freeside-paymentech-upload
+++ b/FS/bin/freeside-paymentech-upload
@@ -41,8 +41,17 @@ my @batches;
if($opt_a) {
my %criteria = (status => 'O');
$criteria{'payby'} = uc($opt_p) if $opt_p;
- $criteria{'type'} = 'DEBIT' unless FS::pay_batch->can_handle_electronic_refunds('paymentech');
- @batches = qsearch('pay_batch', \%criteria);
+
+ my $extra_sql;
+ $extra_sql = " AND ((payby = 'CHEK' AND type != 'CREDIT') OR (payby != 'CHEK'))" unless FS::pay_batch->can_handle_electronic_refunds('paymentech');
+
+ my %hash = (
+ table => 'pay_batch',
+ hashref => \%criteria,
+ extra_sql => $extra_sql,
+ );
+
+ @batches = qsearch(\%hash);
log_and_die("No open batches found".($opt_p ? " of type '$opt_p'" : '').".\n")
if !@batches;
}
diff --git a/FS/bin/freeside-rbc-upload b/FS/bin/freeside-rbc-upload
index 5c0ebdd2e..1d3d0ed4a 100755
--- a/FS/bin/freeside-rbc-upload
+++ b/FS/bin/freeside-rbc-upload
@@ -33,8 +33,17 @@ my @batches;
if($opt_a) {
my %criteria = (status => 'O');
$criteria{'payby'} = uc($opt_p) if $opt_p;
- $criteria{'type'} = 'DEBIT' unless FS::pay_batch->can_handle_electronic_refunds('RBC');
- @batches = qsearch('pay_batch', \%criteria);
+
+ my $extra_sql;
+ $extra_sql = " AND ((payby = 'CHEK' AND type != 'CREDIT') OR (payby != 'CHEK'))" unless FS::pay_batch->can_handle_electronic_refunds('RBC');
+
+ my %hash = (
+ table => 'pay_batch',
+ hashref => \%criteria,
+ extra_sql => $extra_sql,
+ );
+
+ @batches = qsearch(\%hash);
die "No open batches found".($opt_p ? " of type '$opt_p'" : '').".\n"
if !@batches;
}
@@ -45,7 +54,7 @@ else {
die "Can't find payment batch '$batchnum'\n" if !@batches;
if ($batches[0]->type eq "CREDIT") {
warn "running credit\n";
- log_and_die( "Batch number $batchnum is a credit (batch refund) batch, and this format can not handle batch refunds.\n" )
+ die( "Batch number $batchnum is a credit (batch refund) batch, and this format can not handle batch refunds.\n" )
unless FS::pay_batch->can_handle_electronic_refunds('RBC');
}
}