[freeside-commits] branch master updated. 5c4da92af240d4a5d7f39e2478e344693817d5b7

Ivan ivan at 420.am
Sat Mar 24 11:31:54 PDT 2012


The branch, master has been updated
       via  5c4da92af240d4a5d7f39e2478e344693817d5b7 (commit)
      from  385939571ba38786e33337504844553c1a250e66 (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 5c4da92af240d4a5d7f39e2478e344693817d5b7
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sat Mar 24 11:31:53 2012 -0700

    fix final month application of percentage discounts to bundled packages, RT#17045

diff --git a/FS/FS/part_pkg/discount_Mixin.pm b/FS/FS/part_pkg/discount_Mixin.pm
index 1305942..335ff6d 100644
--- a/FS/FS/part_pkg/discount_Mixin.pm
+++ b/FS/FS/part_pkg/discount_Mixin.pm
@@ -82,7 +82,7 @@ sub calc_discount {
     #UI enforces one or the other (for now?  probably for good)
     my $amount = 0;
     $amount += $discount->amount
-        if defined $param->{'real_pkgpart'} && $cust_pkg->pkgpart == $param->{'real_pkgpart'};
+        if $cust_pkg->pkgpart == $param->{'real_pkgpart'};
     $amount += sprintf('%.2f', $discount->percent * $br / 100 );
     my $chg_months = $param->{'months'} || $cust_pkg->part_pkg->freq;
 
@@ -124,10 +124,12 @@ sub calc_discount {
     }
 
     if ( ! defined $param->{'setup_charge'} ) {
-      my $error = $cust_pkg_discount->increment_months_used($months)
-        if defined $param->{'real_pkgpart'} 
-        && $cust_pkg->pkgpart == $param->{'real_pkgpart'};
-      die "error discounting: $error" if $error;
+      if ( $cust_pkg->pkgpart == $param->{'real_pkgpart'} ) {
+        push @{ $param->{precommit_hooks} }, sub {
+          my $error = $cust_pkg_discount->increment_months_used($months);
+          die "error discounting: $error" if $error;
+        };
+      }
 
       $amount = min($amount, $br);
       $amount *= $months;

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

Summary of changes:
 FS/FS/part_pkg/discount_Mixin.pm |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)




More information about the freeside-commits mailing list