summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2013-11-19 22:30:12 -0800
committerIvan Kohler <ivan@freeside.biz>2013-11-19 22:30:12 -0800
commit3cd4fcd5ba52826336c727b855ac12a6407a4b35 (patch)
treee2ace03a7a2ae595941c7b77765d157682f3678c
parent7d259262bb97c5a911754e485a61a6ff7bed0104 (diff)
fix self-service error on change package with BILL customers and selfservice-realtime, RT#26140
-rw-r--r--FS/FS/ClientAPI/MyAccount.pm33
1 files changed, 20 insertions, 13 deletions
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index 241963f90..a58099184 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -2318,7 +2318,7 @@ sub change_pkg {
my $conf = new FS::Conf;
if ( $conf->exists('signup_server-realtime') ) {
- my $bill_error = _do_bop_realtime( $cust_main, $status );
+ my $bill_error = _do_bop_realtime( $cust_main, $status, 'no_credit'=>1 );
if ($bill_error) {
$newpkg[0]->suspend;
@@ -2390,25 +2390,32 @@ sub order_recharge {
}
sub _do_bop_realtime {
- my ($cust_main, $status) = (shift, shift);
+ my ($cust_main, $status, %opt) = @_;
my $old_balance = $cust_main->balance;
my $bill_error = $cust_main->bill
- || $cust_main->apply_payments_and_credits
- || $cust_main->realtime_collect('selfservice' => 1);
+ || $cust_main->apply_payments_and_credits;
+
+ $bill_error ||= $cust_main->realtime_collect('selfservice' => 1)
+ if $cust_main->payby =~ /^(CARD|CHEK)$/;
if ( $cust_main->balance > $old_balance
&& $cust_main->balance > 0
- && ( $cust_main->payby !~ /^(BILL|DCRD|DCHK)$/ ?
- 1 : $status eq 'suspended' ) ) {
- #this makes sense. credit is "un-doing" the invoice
- my $conf = new FS::Conf;
- $cust_main->credit( sprintf("%.2f", $cust_main->balance - $old_balance ),
- 'self-service decline',
- 'reason_type' => $conf->config('signup_credit_type'),
- );
- $cust_main->apply_credits( 'order' => 'newest' );
+ && ( $cust_main->payby !~ /^(BILL|DCRD|DCHK)$/
+ || $status eq 'suspended'
+ )
+ )
+ {
+ unless ( $opt{'no_credit'} ) {
+ #this makes sense. credit is "un-doing" the invoice
+ my $conf = new FS::Conf;
+ $cust_main->credit( sprintf("%.2f", $cust_main->balance-$old_balance ),
+ 'self-service decline',
+ reason_type=>$conf->config('signup_credit_type'),
+ );
+ $cust_main->apply_credits( 'order' => 'newest' );
+ }
return { 'error' => '_decline', 'bill_error' => $bill_error };
}