+
+ my %r_obj = (
+ _date => $cust_pay->_date,
+ amount => sprintf("%.2f", $obj->amount),
+ paynum => $cust_pay->paynum,
+ payinfo => $cust_pay->payby_payinfo_pretty(),
+ description => join(' ',
+ $self->mt('Payment received'),
+ $self->time2str_local('short', $cust_pay->_date),
+ ),
+ );
+
+ if ($c_invoice_payment_details) {
+ $r_obj{description} = join(' ',
+ $r_obj{description},
+ $self->mt('via'),
+ $cust_pay->payby_payinfo_pretty($self->cust_main->locale),
+ );
+ }
+
+ push @return, \%r_obj;
+ }
+ return @return;
+}
+
+=item _items_total()
+
+ Generate the line-items to be shown on the bill in the "Totals" section
+
+ Returns a list of hashrefs, each with the keys:
+ - total_item: description field
+ - total_amount: dollar-formatted number amount
+
+ Information presented by this method varies based on Conf
+
+ Conf previous_balance-payments_due
+ - default, flag not set
+ Only transactions that were applied to this bill bill be
+ displayed and calculated intothe total. If items exist in
+ the past-due section, those items will disappear from this
+ invoice if they have been paid off.
+
+ - previous_balance-payments_due flag is set
+ Transactions occuring after the timestsamp of this
+ invoice are not reflected on invoice line items
+
+ Only payments/credits applied between the previous invoice
+ and this one are displayed and calculated into the total
+
+ - previous_balance-payments_due && $opt{template} eq 'statement'
+ Same as above, except payments/credits occuring before the date
+ of the following invoice are also displayed and calculated into
+ the total
+
+ Conf previous_balance-exclude_from_total
+ - default, flag not set
+ The "Totals" section contains a single line item.
+ The dollar amount of this line items is a sum of old and new charges
+ - previous_balance-exclude_from_total flag is set
+ The "Totals" section contains two line items.
+ One for previous balance, one for new charges
+ !NOTE: Avent virtualization flag 'disable_previous_balance' can
+ override the global conf flag previous_balance-exclude_from_total
+
+ Conf invoice_show_prior_due_date
+ - default, flag not set
+ Total line item in the "Totals" section does not mention due date
+ - invoice_show_prior_due_date flag is set
+ Total line item in the "Totals" section includes either the due
+ date of the invoice, or the specified invoice terms
+ ? Not sure why this is called "Prior" due date, since we seem to be
+ displaying THIS due date...
+=cut
+
+sub _items_total {
+ my $self = shift;
+ my $conf = $self->conf;
+
+ my $c_multi_line_total = 0;
+ $c_multi_line_total = 1
+ if $conf->exists('previous_balance-exclude_from_total')
+ && $self->enable_previous();
+
+ my @line_items;
+ my $invoice_charges = $self->charged();
+
+ # _items_previous() is aware of conf flags
+ my $previous_balance = 0;
+ $previous_balance += $_->{amount} for $self->_items_previous();
+
+ my $total_charges;
+ my $total_descr;
+
+ if ( $previous_balance && $c_multi_line_total ) {
+ # previous balance, new charges on separate lines
+
+ push @line_items, {
+ total_amount => sprintf('%.2f',$previous_balance),
+ total_item => $self->mt(
+ $conf->config('previous_balance-text') || 'Previous Balance'
+ ),