diff options
author | ivan <ivan> | 2011-06-10 03:33:44 +0000 |
---|---|---|
committer | ivan <ivan> | 2011-06-10 03:33:44 +0000 |
commit | c7bf005860b761a55ca075df987fb3b5ade8c242 (patch) | |
tree | 59fdf9039e264c654380528ffdf511b9b69d30a2 /FS | |
parent | 6b4fe3354a905755f9e6f1810cf94bbc269ce81d (diff) |
add package def option to show $0 recurring on invoices, RT#9777
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Schema.pm | 3 | ||||
-rw-r--r-- | FS/FS/cust_bill.pm | 64 | ||||
-rw-r--r-- | FS/FS/cust_bill_pkg.pm | 28 | ||||
-rw-r--r-- | FS/FS/cust_main/Billing.pm | 36 | ||||
-rw-r--r-- | FS/FS/part_pkg.pm | 1 |
5 files changed, 92 insertions, 40 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index ab4752f4b..25912a22f 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -1626,7 +1626,8 @@ sub tables_hashref { 'credit_weight', 'real', 'NULL', '', '', '', 'agentnum', 'int', 'NULL', '', '', '', 'fcc_ds0s', 'int', 'NULL', '', '', '', - 'no_auto', 'char', 'NULL', 1, '', '', + 'no_auto', 'char', 'NULL', 1, '', '', + 'recur_show_zero', 'char', 'NULL', 1, '', '', ], 'primary_key' => 'pkgpart', 'unique' => [], diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index fd3b63820..7106d1fa8 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -4575,23 +4575,10 @@ sub _items_cust_bill_pkg { foreach my $cust_bill_pkg ( @$cust_bill_pkgs ) { - warn "$me _items_cust_bill_pkg considering cust_bill_pkg $cust_bill_pkg\n" + warn "$me _items_cust_bill_pkg considering cust_bill_pkg ". + $cust_bill_pkg->billpkgnum. ", pkgnum ". $cust_bill_pkg->pkgnum. "\n" if $DEBUG > 1; - $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 && !$discount_show_always ); - $_ = undef; - } - } - foreach my $display ( grep { defined($section) ? $_->section eq $section : 1 @@ -4670,9 +4657,13 @@ sub _items_cust_bill_pkg { } - 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' ) + if ( ( !$type || $type eq 'R' || $type eq 'U' ) + && ( + $cust_bill_pkg->recur != 0 + || $cust_bill_pkg->setup == 0 + || $discount_show_always + || $cust_bill_pkg->recur_show_zero + ) ) { @@ -4817,21 +4808,38 @@ sub _items_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, { %$_ } + if $_->{amount} != 0 + || $discount_show_always + || $cust_bill_pkg->recur_show_zero; + $_ = undef; + } + } + } + #foreach ( $s, $r, ($opt{skip_usage} ? () : $u ) ) { + # if ( $_ ) { + # $_->{amount} = sprintf( "%.2f", $_->{amount} ), + # $_->{amount} =~ s/^\-0\.00$/0.00/; + # $_->{unit_amount} = sprintf( "%.2f", $_->{unit_amount} ), + # push @b, { %$_ } + # if $_->{amount} != 0 + # || $discount_show_always + # } + #} + warn "$me _items_cust_bill_pkg done considering cust_bill_pkgs\n" if $DEBUG > 1; - foreach ( $s, $r, ($opt{skip_usage} ? () : $u ) ) { - if ( $_ ) { - $_->{amount} = sprintf( "%.2f", $_->{amount} ), - $_->{amount} =~ s/^\-0\.00$/0.00/; - $_->{unit_amount} = sprintf( "%.2f", $_->{unit_amount} ), - push @b, { %$_ } - unless ( $_->{amount} == 0 && !$discount_show_always ); - } - } - @b; } diff --git a/FS/FS/cust_bill_pkg.pm b/FS/FS/cust_bill_pkg.pm index 37c4a2735..2c79209c5 100644 --- a/FS/FS/cust_bill_pkg.pm +++ b/FS/FS/cust_bill_pkg.pm @@ -413,7 +413,8 @@ sub previous_cust_bill_pkg { Returns an array of detail information for the invoice line item. -Currently available options are: I<format> I<escape_function> +Currently available options are: I<format>, I<escape_function> and +I<format_function>. If I<format> is set to html or latex then the array members are improved for tabular appearance in those environments if possible. @@ -421,6 +422,12 @@ for tabular appearance in those environments if possible. If I<escape_function> is set then the array members are processed by this function before being returned. +I<format_function> overrides the normal HTML or LaTeX function for returning +formatted CDRs. It can be set to a subroutine which returns an empty list +to skip usage detail: + + 'format_function' => sub { () }, + =cut sub details { @@ -872,7 +879,7 @@ sub cust_bill_pkg_detail { my %hash = ( 'billpkgnum' => $self->billpkgnum ); $hash{classnum} = $classnum if $classnum; - qsearch ( 'cust_bill_pkg_detail', { %hash } ), + qsearch( 'cust_bill_pkg_detail', \%hash ), } @@ -883,8 +890,21 @@ Returns the list of associated cust_bill_pkg_discount objects. =cut sub cust_bill_pkg_discount { - my $self = shift; - qsearch ( 'cust_bill_pkg_discount', { 'billpkgnum' => $self->billpkgnum } ); + my $self = shift; + qsearch( 'cust_bill_pkg_discount', { 'billpkgnum' => $self->billpkgnum } ); +} + +=item recur_show_zero + +=cut + +sub recur_show_zero { + my $self = shift; + + $self->recur == 0 + && $self->pkgnum + && $self->cust_pkg->part_pkg->recur_show_zero; + } =back diff --git a/FS/FS/cust_main/Billing.pm b/FS/FS/cust_main/Billing.pm index f6a608053..d565a327c 100644 --- a/FS/FS/cust_main/Billing.pm +++ b/FS/FS/cust_main/Billing.pm @@ -603,27 +603,47 @@ sub bill { #discard bundled packages of 0 value sub _omit_zero_value_bundles { + my @in = @_; my @cust_bill_pkg = (); my @cust_bill_pkg_bundle = (); my $sum = 0; my $discount_show_always = 0; - foreach my $cust_bill_pkg ( @_ ) { + foreach my $cust_bill_pkg ( @in ) { + $discount_show_always = ($cust_bill_pkg->get('discounts') && scalar(@{$cust_bill_pkg->get('discounts')}) && $conf->exists('discount-show-always')); + + warn " pkgnum ". $cust_bill_pkg->pkgnum. + " sum $sum, recur_show_zero ". $cust_bill_pkg->recur_show_zero. "\n" + if $DEBUG > 0; + if (scalar(@cust_bill_pkg_bundle) && !$cust_bill_pkg->pkgpart_override) { push @cust_bill_pkg, @cust_bill_pkg_bundle - if ($sum > 0 || ($sum == 0 && $discount_show_always)); + if $sum > 0 + || ($sum == 0 && ( $discount_show_always + || grep $_->recur_show_zero, @cust_bill_pkg_bundle ) + ); @cust_bill_pkg_bundle = (); $sum = 0; } + $sum += $cust_bill_pkg->setup + $cust_bill_pkg->recur; push @cust_bill_pkg_bundle, $cust_bill_pkg; + } + push @cust_bill_pkg, @cust_bill_pkg_bundle - if ($sum > 0 || ($sum == 0 && $discount_show_always)); + if $sum > 0 + || ($sum == 0 && ( $discount_show_always + || grep $_->recur_show_zero, @cust_bill_pkg_bundle ) + ); + + warn " _omit_zero_value_bundles: ". scalar(@in). + '->'. scalar(@cust_bill_pkg). "\n" #. Dumper(@cust_bill_pkg). "\n" + if $DEBUG > 2; (@cust_bill_pkg); @@ -1024,10 +1044,12 @@ sub _make_lines { my $discount_show_always = ($recur == 0 && scalar(@discounts) && $conf->exists('discount-show-always')); - if ( $setup != 0 || - $recur != 0 || - (!$part_pkg->hidden && $options{has_hidden}) || #include some $0 lines - $discount_show_always ) + if ( $setup != 0 + || $recur != 0 + || (!$part_pkg->hidden && $options{has_hidden}) #include some $0 lines + || $discount_show_always + || ($recur == 0 && $part_pkg->recur_show_zero) + ) { warn " charges (setup=$setup, recur=$recur); adding line items\n" diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm index 17af4d73f..285970009 100644 --- a/FS/FS/part_pkg.pm +++ b/FS/FS/part_pkg.pm @@ -553,6 +553,7 @@ sub check { || $self->ut_enum('disabled', [ '', 'Y' ] ) || $self->ut_enum('custom', [ '', 'Y' ] ) || $self->ut_enum('no_auto', [ '', 'Y' ]) + || $self->ut_enum('recur_show_zero', [ '', 'Y' ]) #|| $self->ut_moneyn('setup_cost') #|| $self->ut_moneyn('recur_cost') || $self->ut_floatn('setup_cost') |