[freeside-commits] branch master updated. bc678cfbd4d28955fbaed101ee647714a8f2c469

Jonathan Prykop jonathan at 420.am
Tue Oct 27 16:55:26 PDT 2015


The branch, master has been updated
       via  bc678cfbd4d28955fbaed101ee647714a8f2c469 (commit)
      from  83800bc3c540ad6a6327af49cf75734d28c82c59 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit bc678cfbd4d28955fbaed101ee647714a8f2c469
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Tue Oct 27 18:55:02 2015 -0500

    RT#38671: Do not include charges and credits from failed signup processing

diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index 98b87ad..89c70f7 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -2424,7 +2424,7 @@ sub change_pkg {
 
   if ( $conf->exists('signup_server-realtime') ) {
 
-    my $bill_error = _do_bop_realtime( $cust_main, $status, 'no_credit'=>1 );
+    my $bill_error = _do_bop_realtime( $cust_main, $status, 'no_invoice_void'=>1 );
 
     if ($bill_error) {
       $err_or_cust_pkg->suspend;
@@ -2500,8 +2500,12 @@ sub _do_bop_realtime {
 
     my $old_balance = $cust_main->balance;
 
-    my $bill_error =    $cust_main->bill
-                     || $cust_main->apply_payments_and_credits;
+    my @cust_bill;
+    my $bill_error = $cust_main->bill(
+      'return_bill'   => \@cust_bill,
+    );
+
+    $bill_error ||= $cust_main->apply_payments_and_credits;
 
     $bill_error ||= $cust_main->realtime_collect('selfservice' => 1)
       if $cust_main->payby =~ /^(CARD|CHEK)$/;
@@ -2513,14 +2517,14 @@ sub _do_bop_realtime {
             )
        )
     {
-      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' );
+      unless ( $opt{'no_invoice_void'} ) {
+
+        #this used to apply a credit, but now we can void invoices...
+        foreach my $cust_bill (@cust_bill) {
+          my $voiderror = $cust_bill->void();
+          warn "Error voiding cust bill after decline: $voiderror";
+        }
+
       }
 
       return { 'error' => '_decline', 'bill_error' => $bill_error };
diff --git a/FS/FS/ClientAPI/Signup.pm b/FS/FS/ClientAPI/Signup.pm
index c0a9d98..a4ea21b 100644
--- a/FS/FS/ClientAPI/Signup.pm
+++ b/FS/FS/ClientAPI/Signup.pm
@@ -783,7 +783,11 @@ sub new_customer {
 
     #warn "$me Billing customer...\n" if $Debug;
 
-    my $bill_error = $cust_main->bill( 'depend_jobnum'=>$placeholder->jobnum );
+    my @cust_bill;
+    my $bill_error = $cust_main->bill(
+      'depend_jobnum' => $placeholder->jobnum,
+      'return_bill'   => \@cust_bill,
+    );
     #warn "$me error billing new customer: $bill_error"
     #  if $bill_error;
 
@@ -818,11 +822,11 @@ sub new_customer {
 
     if ( $cust_main->balance > 0 ) {
 
-      #this makes sense.  credit is "un-doing" the invoice
-      $cust_main->credit( $cust_main->balance, 'signup server decline',
-                          'reason_type' => $conf->config('signup_credit_type'),
-                        );
-      $cust_main->apply_credits;
+      #this used to apply a credit, but now we can void invoices...
+      foreach my $cust_bill (@cust_bill) {
+        my $voiderror = $cust_bill->void();
+        warn "Error voiding cust bill after decline: $voiderror";
+      }
 
       #should check list for errors...
       #$cust_main->suspend;

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/ClientAPI/MyAccount.pm |   26 +++++++++++++++-----------
 FS/FS/ClientAPI/Signup.pm    |   16 ++++++++++------
 2 files changed, 25 insertions(+), 17 deletions(-)




More information about the freeside-commits mailing list