diff options
Diffstat (limited to 'FS/FS/Template_Mixin.pm')
| -rw-r--r-- | FS/FS/Template_Mixin.pm | 54 | 
1 files changed, 35 insertions, 19 deletions
| diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm index 757701aa8..1a3217c44 100644 --- a/FS/FS/Template_Mixin.pm +++ b/FS/FS/Template_Mixin.pm @@ -684,7 +684,12 @@ sub print_generic {    my( $pr_total, @pr_cust_bill ) = $self->previous; #previous balance  #  my( $cr_total, @cr_cust_credit ) = $self->cust_credit; #credits    #my $balance_due = $self->owed + $pr_total - $cr_total; -  my $balance_due = $self->owed + $pr_total; +  my $balance_due = $self->owed; +  if ( $self->enable_previous ) { +    $balance_due += $pr_total; +  } +  # otherwise the previous balance is not shown, so including it in the +  # balance due is just confusing    # the sum of amount owed on all invoices    # (this is used in the summary & on the payment coupon) @@ -1519,7 +1524,7 @@ sub print_generic {    # usage subtotals    if ( $conf->exists('usage_class_summary')         and $self->can('_items_usage_class_summary') ) { -    my @usage_subtotals = $self->_items_usage_class_summary(escape => $escape_function); +    my @usage_subtotals = $self->_items_usage_class_summary(escape => $escape_function, 'money_char' => $other_money_char);      if ( @usage_subtotals ) {        unshift @sections, $usage_subtotals[0]->{section}; # do not summarize        unshift @detail_items, @usage_subtotals; @@ -3010,7 +3015,9 @@ sub _items_cust_bill_pkg {    }    my $summary_page = $opt{summary_page} || ''; #unused    my $multisection = defined($category) || defined($locationnum); -  my $discount_show_always = 0; +  # this variable is the value of the config setting, not whether it applies +  # to this particular line item. +  my $discount_show_always = $conf->exists('discount-show-always');    my $maxlength = $conf->config('cust_bill-latex_lineitem_maxlength') || 40; @@ -3050,11 +3057,13 @@ sub _items_cust_bill_pkg {          if (exists($_->{unit_amount})) {            $_->{unit_amount} = sprintf( "%.2f", $_->{unit_amount} );          } -        push @b, { %$_ } -          if $_->{amount} != 0 -          || $discount_show_always -          || ( ! $_->{_is_setup} && $_->{recur_show_zero} ) -          || (   $_->{_is_setup} && $_->{setup_show_zero} ) +        push @b, { %$_ }; +        # we already decided to create this display line; don't reconsider it +        # now. +        #  if $_->{amount} != 0 +        #  || $discount_show_always +        #  || ( ! $_->{_is_setup} && $_->{recur_show_zero} ) +        #  || (   $_->{_is_setup} && $_->{setup_show_zero} )          ;          $_ = undef;        } @@ -3181,6 +3190,7 @@ sub _items_cust_bill_pkg {          if (    (!$type || $type eq 'S')               && (    $cust_bill_pkg->setup != 0                    || $cust_bill_pkg->setup_show_zero +                  || ($discount_show_always and $cust_bill_pkg->unitsetup > 0)                  )             )           { @@ -3188,10 +3198,12 @@ sub _items_cust_bill_pkg {            warn "$me _items_cust_bill_pkg adding setup\n"              if $DEBUG > 1; +          # append the word 'Setup' to the setup line if there's going to be +          # a recur line for the same package (i.e. not a one-time charge)             my $description = $desc;            $description .= ' Setup'              if $cust_bill_pkg->recur != 0 -            || $discount_show_always +            || ($discount_show_always and $cust_bill_pkg->unitrecur > 0)              || $cust_bill_pkg->recur_show_zero;            $description .= $cust_bill_pkg->time_period_pretty( $part_pkg, @@ -3255,11 +3267,18 @@ sub _items_cust_bill_pkg {          } +        # should we show a recur line? +        # if type eq 'S', then NO, because we've been told not to. +        # otherwise, show the recur line if: +        # - there's a recurring charge +        # - or recur_show_zero is on +        # - or there's a positive unitrecur (so it's been discounted to zero) +        #   and discount-show-always is on          if (    ( !$type || $type eq 'R' || $type eq 'U' )               && (                       $cust_bill_pkg->recur != 0 -                  || $cust_bill_pkg->setup == 0 -                  || $discount_show_always +                  || !defined($s) +                  || ($discount_show_always and $cust_bill_pkg->unitrecur > 0)                    || $cust_bill_pkg->recur_show_zero                  )             ) @@ -3501,9 +3520,6 @@ sub _items_cust_bill_pkg {      } # foreach $display -    $discount_show_always = ($cust_bill_pkg->cust_bill_pkg_discount -                                && $conf->exists('discount-show-always')); -    }    foreach ( $s, $r, ($opt{skip_usage} ? () : $u ), $d ) { @@ -3515,11 +3531,11 @@ sub _items_cust_bill_pkg {          $_->{unit_amount} = sprintf( "%.2f", $_->{unit_amount} );        } -      push @b, { %$_ } -        if $_->{amount} != 0 -        || $discount_show_always -        || ( ! $_->{_is_setup} && $_->{recur_show_zero} ) -        || (   $_->{_is_setup} && $_->{setup_show_zero} ) +      push @b, { %$_ }; +      #if $_->{amount} != 0 +      #  || $discount_show_always +      #  || ( ! $_->{_is_setup} && $_->{recur_show_zero} ) +      #  || (   $_->{_is_setup} && $_->{setup_show_zero} )      }    } | 
