add missing commits as part of backporting of RT10481 to 2.1 branch
authorlevinse <levinse>
Mon, 31 Jan 2011 06:23:33 +0000 (06:23 +0000)
committerlevinse <levinse>
Mon, 31 Jan 2011 06:23:33 +0000 (06:23 +0000)
FS/FS/Conf.pm
FS/FS/cust_bill.pm

index 5ed3b6b..9919065 100644 (file)
@@ -655,6 +655,13 @@ my %payment_gateway_options = (
   },
 
   {
+    'key'         => 'discount-show-always',
+    'section'     => 'billing',
+    'description' => 'Generate a line item on an invoice even when a package is discounted 100%',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'encryption',
     'section'     => 'billing',
     'description' => 'Enable encryption of credit cards.',
index aef0b91..1924bbf 100644 (file)
@@ -4133,19 +4133,23 @@ sub _items_cust_bill_pkg {
   my $summary_page = $opt{summary_page} || '';
   my $multilocation = $opt{multilocation} || '';
   my $multisection = $opt{multisection} || '';
+  my $discount_show_always = 0;
 
   my @b = ();
   my ($s, $r, $u) = ( undef, undef, undef );
   foreach my $cust_bill_pkg ( @$cust_bill_pkg )
   {
 
+    $discount_show_always = ($cust_bill_pkg->cust_bill_pkg_discount
+                               && $conf->exists('discount-show-always'));
+
     foreach ( $s, $r, ($opt{skip_usage} ? () : $u ) ) {
       if ( $_ && !$cust_bill_pkg->hidden ) {
         $_->{amount}      = sprintf( "%.2f", $_->{amount} ),
         $_->{amount}      =~ s/^\-0\.00$/0.00/;
         $_->{unit_amount} = sprintf( "%.2f", $_->{unit_amount} ),
         push @b, { %$_ }
-          unless $_->{amount} == 0;
+         unless ( $_->{amount} == 0 && !$discount_show_always );
         $_ = undef;
       }
     }
@@ -4219,7 +4223,8 @@ sub _items_cust_bill_pkg {
 
         }
 
-        if ( ( $cust_bill_pkg->recur != 0  || $cust_bill_pkg->setup == 0 ) &&
+        if ( ( $cust_bill_pkg->recur != 0  || $cust_bill_pkg->setup == 0 || 
+               ($discount_show_always && $cust_bill_pkg->recur == 0) ) &&
              ( !$type || $type eq 'R' || $type eq 'U' )
            )
         {
@@ -4344,7 +4349,7 @@ sub _items_cust_bill_pkg {
       $_->{amount}      =~ s/^\-0\.00$/0.00/;
       $_->{unit_amount} = sprintf( "%.2f", $_->{unit_amount} ),
       push @b, { %$_ }
-        unless $_->{amount} == 0;
+       unless ( $_->{amount} == 0 && !$discount_show_always );
     }
   }