X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FTemplate_Mixin.pm;h=426386b861abba676c9b80db8777bbbcf9d287f4;hb=282d98b8ebad35123455dd8ccb414805a1624c6c;hp=00151ae2643b438be39f734fcf960c7a49faff70;hpb=9aaccf56a9cb4367a72450911f26cd9b324c3717;p=freeside.git diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm index 00151ae26..426386b86 100644 --- a/FS/FS/Template_Mixin.pm +++ b/FS/FS/Template_Mixin.pm @@ -485,9 +485,14 @@ sub print_generic { 'quotationnum' => $self->quotationnum, 'no_date' => $params{'no_date'}, '_date' => ( $params{'no_date'} ? '' : $self->_date ), + # workaround for inconsistent behavior in the early plain text + # templates; see RT#28271 'date' => ( $params{'no_date'} ? '' - : $self->time2str_local('long', $self->_date, $format) + : ($format eq 'template' + ? $self->_date + : $self->time2str_local('long', $self->_date, $format) + ) ), 'today' => $self->time2str_local('long', $today, $format), 'terms' => $self->terms, @@ -936,7 +941,7 @@ sub print_generic { my $detail = { ref => $line_item->{'pkgnum'}, pkgpart => $line_item->{'pkgpart'}, - quantity => 1, + #quantity => 1, # not really correct section => $previous_section, # which might be $default_section description => &$escape_function($line_item->{'description'}), ext_description => [ map { &$escape_function($_) } @@ -2452,6 +2457,8 @@ sub _items_cust_bill_pkg { warn "$me _items_cust_bill_pkg cust_bill_pkg is quotation_pkg\n" if $DEBUG > 1; + # quotation_pkgs are never fees, so don't worry about the case where + # part_pkg is undefined if ( $cust_bill_pkg->setup != 0 ) { my $description = $desc; @@ -2471,7 +2478,7 @@ sub _items_cust_bill_pkg { }; } - } elsif ( $cust_bill_pkg->pkgnum > 0 ) { + } elsif ( $cust_bill_pkg->pkgnum > 0 ) { # and it's not a quotation_pkg warn "$me _items_cust_bill_pkg cust_bill_pkg is non-tax\n" if $DEBUG > 1; @@ -2576,7 +2583,8 @@ sub _items_cust_bill_pkg { my $is_summary = $display->summary; my $description = $desc; - if ( $type eq 'U' and ($is_summary or $cust_bill_pkg->hidden) ) { + if ( $type eq 'U' and defined($r) ) { + # don't just show the same description as the recur line $description = $self->mt('Usage charges'); } @@ -2596,10 +2604,19 @@ sub _items_cust_bill_pkg { push @dates, $prev->sdate if $prev; push @dates, undef if !$prev; + # show service labels, unless... + # the package is set not to display them unless ( $part_pkg->hide_svc_detail + # or this is a tax-like line item || $cust_bill_pkg->itemdesc + # or this is a hidden (bundled) line item || $cust_bill_pkg->hidden + # or this is a usage summary line || $is_summary && $type && $type eq 'U' + # or this is a usage line and there's a recurring line + # for the package in the same section (which will + # have service labels already) + || ($type eq 'U' and defined($r)) ) { @@ -2647,7 +2664,7 @@ sub _items_cust_bill_pkg { } } #if svc_acct-usage_seconds - } + } # if we are showing service labels unless ( $is_summary ) { warn "$me _items_cust_bill_pkg adding details\n" @@ -2673,15 +2690,15 @@ sub _items_cust_bill_pkg { $amount = $cust_bill_pkg->usage; } - my $unit_amount = - ( $cust_bill_pkg->unitrecur > 0 ) ? $cust_bill_pkg->unitrecur - : $amount; - if ( !$type || $type eq 'R' ) { warn "$me _items_cust_bill_pkg adding recur\n" if $DEBUG > 1; + my $unit_amount = + ( $cust_bill_pkg->unitrecur > 0 ) ? $cust_bill_pkg->unitrecur + : $amount; + if ( $cust_bill_pkg->hidden ) { $r->{amount} += $amount; $r->{unit_amount} += $unit_amount; @@ -2712,7 +2729,6 @@ sub _items_cust_bill_pkg { # line for the bundle, add this package's total amount and # usage details to it $u->{amount} += $amount; - $u->{unit_amount} += $unit_amount, push @{ $u->{ext_description} }, @d; } elsif ( $amount ) { # create a new usage line @@ -2722,8 +2738,6 @@ sub _items_cust_bill_pkg { pkgnum => $cust_bill_pkg->pkgnum, amount => $amount, recur_show_zero => $cust_bill_pkg->recur_show_zero, - unit_amount => $unit_amount, - quantity => $cust_bill_pkg->quantity, %item_dates, ext_description => \@d, }; @@ -2732,29 +2746,21 @@ sub _items_cust_bill_pkg { } # recurring or usage with recurring charge - } else { #pkgnum tax or one-shot line item (??) + } else { # taxes and fees warn "$me _items_cust_bill_pkg cust_bill_pkg is tax\n" if $DEBUG > 1; - if ( $cust_bill_pkg->setup != 0 ) { - push @b, { - 'description' => $desc, - 'amount' => sprintf("%.2f", $cust_bill_pkg->setup), - }; - } - if ( $cust_bill_pkg->recur != 0 ) { - push @b, { - 'description' => "$desc (". - $self->time2str_local('short', $cust_bill_pkg->sdate). ' - '. - $self->time2str_local('short', $cust_bill_pkg->edate). ')', - 'amount' => sprintf("%.2f", $cust_bill_pkg->recur), - }; - } + # items of this kind should normally not have sdate/edate. + push @b, { + 'description' => $desc, + 'amount' => sprintf('%.2f', $cust_bill_pkg->setup + + $cust_bill_pkg->recur) + }; - } + } # if quotation / package line item / other line item - } + } # foreach $display $discount_show_always = ($cust_bill_pkg->cust_bill_pkg_discount && $conf->exists('discount-show-always')); @@ -2764,8 +2770,11 @@ sub _items_cust_bill_pkg { foreach ( $s, $r, ($opt{skip_usage} ? () : $u ) ) { if ( $_ ) { $_->{amount} = sprintf( "%.2f", $_->{amount} ), + if exists($_->{amount}); $_->{amount} =~ s/^\-0\.00$/0.00/; - $_->{unit_amount} = sprintf( "%.2f", $_->{unit_amount} ), + $_->{unit_amount} = sprintf('%.2f', $_->{unit_amount}) + if exists($_->{unit_amount}); + push @b, { %$_ } if $_->{amount} != 0 || $discount_show_always