[freeside-commits] branch FREESIDE_2_3_BRANCH updated. 10b4364dc788df061006dd866fde79cff08645fc

Mark Wells mark at 420.am
Sat Mar 17 16:29:49 PDT 2012


The branch, FREESIDE_2_3_BRANCH has been updated
       via  10b4364dc788df061006dd866fde79cff08645fc (commit)
      from  631e1def5b34f6f5c63403c93c07f7bcb1346265 (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 10b4364dc788df061006dd866fde79cff08645fc
Author: Mark Wells <mark at freeside.biz>
Date:   Sat Mar 17 16:28:58 2012 -0700

    fix term discount display, #16965

diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index bb44c05..3aa75ec 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -5261,6 +5261,9 @@ sub _items_discounts_avail {
                  join(', ', map { "#$_" } $plan->pkgnums)
       if $list_pkgnums;
 
+    # discounts for non-integer months don't work anyway
+    $months = sprintf("%d", $months);
+
     +{
       description => $self->mt('Save [_1]% by paying for [_2] months',
                                 $percent, $months),
diff --git a/FS/FS/discount_plan.pm b/FS/FS/discount_plan.pm
index 3ae44c8..6a45676 100644
--- a/FS/FS/discount_plan.pm
+++ b/FS/FS/discount_plan.pm
@@ -80,19 +80,24 @@ sub new {
           $self->{discounted} += $setup;
         }
 
-        if ( $discount->percent ) {
+        if ( $discount->percent > 0 ) {
           $discountable += $months * $permonth;
           $discountable -= ($discountable * $discount->percent / 100);
           $discountable -= ($permonth - $recur); # correct for prorate
           $self->{discounted} += $discountable;
         }
-        else {
+        elsif ( $discount->amount > 0 ) {
           $discountable += $recur;
           $discountable -= $discount->amount * $recur/$permonth;
           $discountable += ($months - 1) * max($permonth - $discount->amount,0);
+          $self->{discounted} += $discountable;
+        }
+        else {
+          warn "discountnum ".$discount->discountnum.
+            " has no amount or percentage, ignored\n";
+          $self->{discounted} = $self->{base};
         }
 
-        $self->{discounted} += $discountable;
         push @{ $self->{pkgnums} }, $cust_pkg->pkgnum;
       }
       else { #no discount

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

Summary of changes:
 FS/FS/cust_bill.pm     |    3 +++
 FS/FS/discount_plan.pm |   11 ++++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)




More information about the freeside-commits mailing list