=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)
=item apply_payments_and_credits [ OPTION => VALUE ... ]
Applies unapplied payments and credits to this invoice.
+Payments with the no_auto_apply flag set will not be applied.
A hash of optional arguments may be passed. Currently "manual" is supported.
If true, a payment receipt is sent instead of a statement when
$self->select_for_update; #mutex
- my @payments = grep { $_->unapplied > 0 } $self->cust_main->cust_pay;
+ my @payments = grep { $_->unapplied > 0 }
+ grep { !$_->no_auto_apply }
+ $self->cust_main->cust_pay;
my @credits = grep { $_->credited > 0 } $self->cust_main->cust_credit;
if ( $conf->exists('pkg-balances') ) {
my @items;
my ($pr_total) = $self->previous;
- my ($new_charges_desc, $new_charges_amount);
+ 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)
};
}
$new_charges_desc = $self->mt(
- $conf->config('previous_balance-exclude_from_total')
+ $conf->config('previous_balance-text-total_new_charges')
|| 'Total New Charges'
- ); # localize 'Total New Charges' or whatever's in the config
+ );
$new_charges_amount = $self->charged;
}
+# this is called from search/cust_bill.html and given all its search
+# parameters, so it needs to perform the same search.
+
sub re_X {
# spool_invoice ftp_invoice fax_invoice print_invoice
my($method, $job, %param ) = @_;
}
#some false laziness w/search/cust_bill.html
- my $distinct = '';
- my $orderby = 'ORDER BY cust_bill._date';
-
- my $extra_sql = ' WHERE '. FS::cust_bill->search_sql_where(\%param);
-
- my $addl_from = 'LEFT JOIN cust_main USING ( custnum )';
-
- my @cust_bill = qsearch( {
- #'select' => "cust_bill.*",
- 'table' => 'cust_bill',
- 'addl_from' => $addl_from,
- 'hashref' => {},
- 'extra_sql' => $extra_sql,
- 'order_by' => $orderby,
- 'debug' => 1,
- } );
+ $param{'order_by'} = 'cust_bill._date';
+
+ my $query = FS::cust_bill->search(\%param);
+ delete $query->{'count_query'};
+ delete $query->{'count_addl'};
+
+ $query->{debug} = 1; # was in here before, is obviously useful
+
+ my @cust_bill = qsearch( $query );
$method .= '_invoice' unless $method eq 'email' || $method eq 'print';