Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / FS / FS / cust_main / Billing_Discount.pm
index d437740..ec2bf07 100644 (file)
@@ -47,7 +47,7 @@ sub _discount_pkgs_and_bill {
   push @where,
     "NOT EXISTS (
        SELECT 1 FROM cust_bill_pkg_discount
-         WHERE cust_bill_pkg.billpkgnum = cust_bill_pkg_discount.billpkgnu:
+         WHERE cust_bill_pkg.billpkgnum = cust_bill_pkg_discount.billpkgnum
     )";
 
   my $extra_sql = 'WHERE '. join(' AND ', @where);
@@ -92,8 +92,11 @@ sub discount_terms {
 
   my @discount_pkgs = $self->_discount_pkgs_and_bill;
   shift @discount_pkgs; #discard bill;
-  
-  map { $terms{$_->months} = 1 }
+
+  # convert @discount_pkgs (the list of packages that have available discounts)
+  # to a list of distinct term lengths in months, and strip any decimal places
+  # from the number of months, not that it should have any 
+  map { $terms{sprintf('%.0f', $_->months)} = 1 }
     grep { $_->months && $_->months > 1 }
     map { $_->discount }
     map { $_->part_pkg->part_pkg_discount }
@@ -110,6 +113,9 @@ by prepaying the most recent invoice for MONTHS.
 
 =cut
 
+# XXX this should work by creating a quotation; then we can finally retire
+# the "no_commit" option, which doesn't work with modern tax calculation
+
 sub discount_term_values {
   my $self = shift;
   my $term = shift;