[freeside-commits] branch FREESIDE_4_BRANCH updated. 4ad2efca4dd06a0d3cab96dd4e5a22b9aad2421d

Ivan Kohler ivan at freeside.biz
Tue Sep 29 14:27:45 PDT 2020


The branch, FREESIDE_4_BRANCH has been updated
       via  4ad2efca4dd06a0d3cab96dd4e5a22b9aad2421d (commit)
      from  7be809e90534e82380f6bab190514c7e10a87972 (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 4ad2efca4dd06a0d3cab96dd4e5a22b9aad2421d
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Sep 29 14:27:44 2020 -0700

    fix rare FP rounding errors on void, RT#84904

diff --git a/FS/FS/cust_bill_pkg.pm b/FS/FS/cust_bill_pkg.pm
index 6f9c74a64..f0d710534 100644
--- a/FS/FS/cust_bill_pkg.pm
+++ b/FS/FS/cust_bill_pkg.pm
@@ -392,7 +392,7 @@ sub void {
 
   }
 
-  $error = $self->delete;
+  $error = $self->delete( skip_update_cust_bill_charged=>1 );
   if ( $error ) {
     $dbh->rollback if $oldAutoCommit;
     return $error;
@@ -448,6 +448,7 @@ Not recommended.
 
 sub delete {
   my $self = shift;
+  my %opt = @_;
 
   local $SIG{HUP} = 'IGNORE';
   local $SIG{INT} = 'IGNORE';
@@ -493,16 +494,27 @@ sub delete {
     }
   }
 
-  #fix the invoice amount
+  unless ( $opt{skip_update_cust_bill_charged} ) {
+
+    #fix the invoice amount
+
+    my $cust_bill = $self->cust_bill;
+    my $charged = $cust_bill->charged - $self->setup - $self->recur;
+    $charged = sprintf('%.2f', $charged + 0.00000001 );
+    $cust_bill->charged( $charged );
 
-  my $cust_bill = $self->cust_bill;
-  $cust_bill->charged( $cust_bill->charged - $self->setup - $self->recur );
+    #not adding a cc surcharge, but this override lets us modify charged
+    $cust_bill->{'Hash'}{'cc_surcharge_replace_hack'} = 1;
 
-  #not adding a cc surcharge, but this override lets us modify charged
-  $cust_bill->{'Hash'}{'cc_surcharge_replace_hack'} = 1;
+    my $error = $cust_bill->replace;
+    if ( $error ) {
+      $dbh->rollback if $oldAutoCommit;
+      return $error;
+    }
+
+  }
 
-  my $error =  $cust_bill->replace
-            || $self->SUPER::delete(@_);
+  my $error = $self->SUPER::delete(@_);
   if ( $error ) {
     $dbh->rollback if $oldAutoCommit;
     return $error;

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

Summary of changes:
 FS/FS/cust_bill_pkg.pm | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)




More information about the freeside-commits mailing list