[freeside-commits] branch FREESIDE_3_BRANCH updated. e2d16c850d8857567023f10b8c57daf0570c6a8e

Mark Wells mark at 420.am
Fri Nov 6 14:20:56 PST 2015


The branch, FREESIDE_3_BRANCH has been updated
       via  e2d16c850d8857567023f10b8c57daf0570c6a8e (commit)
      from  f8c4741390077c1448d627949d19c9220cc8e610 (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 e2d16c850d8857567023f10b8c57daf0570c6a8e
Author: Mark Wells <mark at freeside.biz>
Date:   Thu Nov 5 19:55:26 2015 -0800

    ignore discount duration when applying to setup fee, #38489

diff --git a/FS/FS/part_pkg/discount_Mixin.pm b/FS/FS/part_pkg/discount_Mixin.pm
index 194479e..e411c84 100644
--- a/FS/FS/part_pkg/discount_Mixin.pm
+++ b/FS/FS/part_pkg/discount_Mixin.pm
@@ -123,17 +123,13 @@ sub calc_discount {
 
         if ( $discount->percent > 0 ) {
             $amount = $discount->percent * $param->{'setup_charge'} / 100;
-        } elsif ( $discount->amount > 0 && ($discount->months || 0) == 1) {
+        } elsif ( $discount->amount > 0 ) {
             # apply the discount amount, up to a maximum of the setup charge
             $amount = min($discount->amount, $param->{'setup_charge'});
             $discount_left = sprintf('%.2f', $discount->amount - $amount);
             # transfer remainder of discount, if any, to recur
             $param->{'discount_left_recur'}{$discount->discountnum} = $discount_left;
-        } else {
-          # I guess we don't allow multiple-month flat amount discounts to
-          # apply to setup?
-            next; 
-        }
+        } 
 
     } else {
       
diff --git a/httemplate/edit/cust_pkg_discount.html b/httemplate/edit/cust_pkg_discount.html
index 0bb84b8..e814c96 100755
--- a/httemplate/edit/cust_pkg_discount.html
+++ b/httemplate/edit/cust_pkg_discount.html
@@ -30,6 +30,7 @@
              'empty_label' => ( $pkgdiscountnum ? '' : 'Select discount' ),
              'onchange'    => 'enable_discount_pkg()',
              'cgi'         => $cgi,
+             'setup_only'  => $setup_only,
           )
 %>
 
@@ -72,5 +73,6 @@ my $cust_pkg =
 #         " ( pkgnum ". cust_pkg->pkgnum. ")";
 
 my $part_pkg = $cust_pkg->part_pkg;
+my $setup_only = ($part_pkg->freq eq '0') ? 1 : 0;
 
 </%init>
diff --git a/httemplate/elements/tr-select-discount.html b/httemplate/elements/tr-select-discount.html
index ee86251..faa65e1 100644
--- a/httemplate/elements/tr-select-discount.html
+++ b/httemplate/elements/tr-select-discount.html
@@ -53,6 +53,13 @@
             )
   %>
 
+% if ( $opt{'setup_only'} ) {
+  <& /elements/hidden.html,
+    'field' => $name.'_setup',
+    'id'    => $name.'_setup',
+    'value' => 'Y'
+  &>
+% } else { # normal case, allow the user to choose
   <% include( '/elements/tr-input-text.html',
                 'label'   => '<B>Discount duration (months)</B>',
                 'field'   => $name. '_months',
@@ -73,6 +80,7 @@
                 'colspan'    => $opt{'colspan'},
             )
   %>
+% }
 
 %#  <% include( '/elements/tr-checkbox.html',
 %#                'label'     => '<B>Apply discount to add-on packages</B>',

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

Summary of changes:
 FS/FS/part_pkg/discount_Mixin.pm            |    8 ++------
 httemplate/edit/cust_pkg_discount.html      |    2 ++
 httemplate/elements/tr-select-discount.html |    8 ++++++++
 3 files changed, 12 insertions(+), 6 deletions(-)




More information about the freeside-commits mailing list