X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_bill.pm;h=9d250eba375aa0419958c850dc3c033fa5c6a269;hp=3f94796c6e73b5e16e54ac08aba8d42b1d379d4b;hb=c15077a092c6b194923b72d9baaa50573c1ececb;hpb=2705b64bb669ba94492a185410e8d67f6ea82edd diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 3f94796c6..9d250eba3 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -245,6 +245,7 @@ sub delete { cust_pay_batch cust_bill_pay_batch cust_bill_pkg + cust_bill_batch )) { foreach my $linked ( $self->$table() ) { @@ -733,6 +734,17 @@ sub cust_credit_bill_pkg { } +=item cust_bill_batch + +Returns all invoice batch records (L) for this invoice. + +=cut + +sub cust_bill_batch { + my $self = shift; + qsearch('cust_bill_batch', { 'invnum' => $self->invnum }); +} + =item tax Returns the tax amount (see L) for this invoice. @@ -2832,8 +2844,10 @@ sub print_generic { if ($conf->exists('voip-cust_accountcode_cdr') && $cust_main->accountcode_cdr) { my ($accountcode_section, $accountcode_lines) = $self->_items_accountcode_cdr($escape_function_nonbsp,$format); - push @{$late_sections}, $accountcode_section; - push @detail_items, @$accountcode_lines; + if ( scalar(@$accountcode_lines) ) { + push @{$late_sections}, $accountcode_section; + push @detail_items, @$accountcode_lines; + } } }else{ push @sections, { 'description' => '', 'subtotal' => '' }; @@ -2889,8 +2903,7 @@ sub print_generic { push @detail_items, { 'description' => $didsummary_desc, 'ext_description' => [ $didsummary, $minutes ], - } - if !$multisection; + }; } foreach my $section (@sections, @$late_sections) { @@ -4149,7 +4162,6 @@ sub _items_accountcode_cdr { 'description' => 'Usage by Account Code', 'post_total' => '', 'summarized' => '', - 'total_generator' => sub { '' }, 'header' => '', }; my @lines; @@ -4186,6 +4198,7 @@ sub _items_accountcode_cdr { ext_description => [], }; + $section->{'amount'} += $amount; $accountcodes{$accountcode}{'amount'} += $amount; $accountcodes{$accountcode}{calls}++; $accountcodes{$accountcode}{duration} += $detail->duration; @@ -4200,7 +4213,9 @@ sub _items_accountcode_cdr { push @lines, $l; } - return ($section,\@lines); + my @sorted_lines = sort { $a->{'description'} <=> $b->{'description'} } @lines; + + return ($section,\@sorted_lines); } sub _items_svc_phone_sections { @@ -4559,23 +4574,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 @@ -4654,9 +4656,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 + ) ) { @@ -4801,21 +4807,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; }