my @legacy_cust_bill = $cust_main->legacy_cust_bill;
- my @cust_bill = $cust_main->cust_bill;
-
- my $hide_taxclass = $conf->config('selfservice-hide_invoices-taxclass');
- if ( $hide_taxclass ) {
- @cust_bill = grep { my @cust_bill_pkg = $_->cust_bill_pkg;
- my @part_pkg= grep $_, map $_->part_pkg, @cust_bill_pkg;
- grep { $_->taxclass ne $hide_taxclass } @part_pkg;
- }
- @cust_bill;
- }
+ my @cust_bill = grep ! $_->hide, $cust_main->cust_bill;
my $balance = 0;
{
'key' => 'selfservice-hide_invoices-taxclass',
'section' => 'self-service',
- 'description' => 'Hide invoices with only this package tax class from self-service. Typically set to something like "Previous balance" and used when importing legacy invoices into legacy_cust_bill.',
+ 'description' => 'Hide invoices with only this package tax class from self-service and supress sending (emailing, printing, faxing) them. Typically set to something like "Previous balance" and used when importing legacy invoices into legacy_cust_bill.',
'type' => 'text',
},
$balance;
}
+=item hide
+
+Returns true if this invoice should be hidden. See the
+selfservice-hide_invoices-taxclass configuraiton setting.
+
+=cut
+
+sub hide {
+ my $self = shift;
+ my $conf = $self->conf;
+ my $hide_taxclass = $conf->config('selfservice-hide_invoices-taxclass')
+ or return '';
+ my @cust_bill_pkg = $self->cust_bill_pkg;
+ my @part_pkg = grep $_, map $_->part_pkg, @cust_bill_pkg;
+ ! grep { $_->taxclass ne $hide_taxclass } @part_pkg;
+}
+
=item apply_payments_and_credits [ OPTION => VALUE ... ]
Applies unapplied payments and credits to this invoice.
#sub email_invoice {
sub email {
my $self = shift;
+ return if $self->hide;
my $conf = $self->conf;
my( $template, $invoice_from, $notice_name, $no_coupon );
#sub print_invoice {
sub print {
my $self = shift;
+ return if $self->hide;
my $conf = $self->conf;
+
my( $template, $notice_name );
if ( ref($_[0]) ) {
my $opt = shift;
sub fax_invoice {
my $self = shift;
+ return if $self->hide;
my $conf = $self->conf;
+
my( $template, $notice_name );
if ( ref($_[0]) ) {
my $opt = shift;