[freeside-commits] branch FREESIDE_2_3_BRANCH updated. 69a47bd38e71ae6486b14d24d60dc60077cf09e9

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


The branch, FREESIDE_2_3_BRANCH has been updated
       via  69a47bd38e71ae6486b14d24d60dc60077cf09e9 (commit)
      from  9fa7ba37e237f576c84955c92226e41c2313e02b (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 69a47bd38e71ae6486b14d24d60dc60077cf09e9
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sat Mar 24 11:31:54 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 63909b3..7de3bfe 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