X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_bill.pm;h=db909309fa041c29f76a2d72673a18e45fcc8500;hb=9db30264ee0ce0f05632c1ed0b3e8dbdd03f7bc2;hp=6e40ef506bdc7a84d7b713f67d4b4207074526f6;hpb=1b84c08aa4c0d92120150dc27b5af6deca484c38;p=freeside.git diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 6e40ef506..db909309f 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -143,6 +143,16 @@ Invoices are normally created by calling the bill method of a customer object =cut sub table { 'cust_bill'; } +sub template_conf { 'invoice_'; } + +sub has_sections { + my $self = shift; + my $agentnum = $self->cust_main->agentnum; + my $tc = $self->template_conf; + + $self->conf->exists($tc.'sections', $agentnum) || + $self->conf->exists($tc.'sections_by_location', $agentnum); +} # should be the ONLY occurrence of "Invoice" in invoice rendering code. # (except email_subject and invnum_date_pretty) @@ -2812,44 +2822,55 @@ sub _items_total { my @items; my ($pr_total) = $self->previous; + my ($previous_charges_desc, $new_charges_desc, $new_charges_amount); + if ( $conf->exists('previous_balance-exclude_from_total') ) { + # can we do some caching on this stuff? it's going to change infrequently + # in production + $previous_charges_desc = $self->mt( + $conf->config('previous_balance-text') || 'Previous Balance' + ); + # then return separate lines for previous balance and total new charges if ( $pr_total ) { push @items, - { total_item => $self->mt('Previous Balance'), + { total_item => $previous_charges_desc, total_amount => sprintf('%.2f',$pr_total) }; } - my $new_charges_desc = $self->mt( - $conf->config('previous_balance-exclude_from_total') + $new_charges_desc = $self->mt( + $conf->config('previous_balance-text-total_new_charges') || 'Total New Charges' - ); # localize 'Total New Charges' or whatever's in the config - - if ( $conf->exists('invoice_show_prior_due_date') ) { - # then the due date should be shown with Total New Charges, - # and should NOT be shown with the Balance Due message. - if ( $self->due_date ) { - # localize the "Please pay by" message and the date itself - # (grammar issues with this, yeah) - $new_charges_desc .= ' - ' . $self->mt('Please pay by') . ' ' . - $self->due_date2str('short'); - } elsif ( $self->terms ) { - # phrases like "due on receipt" should be localized - $new_charges_desc .= ' - ' . $self->mt($self->terms); - } - } + ); - push @items, - { total_item => $self->mt($new_charges_desc), - total_amount => $self->charged - }; + $new_charges_amount = $self->charged; } else { - push @items, - { total_item => $self->mt('Total Charges'), - total_amount => sprintf('%.2f',$self->charged + $pr_total) - }; + + $new_charges_desc = $self->mt('Total Charges'); + $new_charges_amount = sprintf('%.2f',$self->charged + $pr_total); + + } + + if ( $conf->exists('invoice_show_prior_due_date') ) { + # then the due date should be shown with Total New Charges, + # and should NOT be shown with the Balance Due message. + if ( $self->due_date ) { + # localize the "Please pay by" message and the date itself + # (grammar issues with this, yeah) + $new_charges_desc .= ' - ' . $self->mt('Please pay by') . ' ' . + $self->due_date2str('short'); + } elsif ( $self->terms ) { + # phrases like "due on receipt" should be localized + $new_charges_desc .= ' - ' . $self->mt($self->terms); + } } + + push @items, + { total_item => $new_charges_desc, + total_amount => $new_charges_amount, + }; + @items; }