From e4f75250ed4828000922cf4d7fecef62a83b60dd Mon Sep 17 00:00:00 2001 From: levinse Date: Mon, 31 Jan 2011 06:23:33 +0000 Subject: [PATCH] add missing commits as part of backporting of RT10481 to 2.1 branch --- FS/FS/Conf.pm | 7 +++++++ FS/FS/cust_bill.pm | 11 ++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 5ed3b6bec..991906563 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -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.', diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index aef0b91df..1924bbf85 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -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 ); } } -- 2.11.0