RT# 37817 - added a declaration to cust bill event actions that send out invoices
[freeside.git] / FS / FS / part_event / Action / cust_bill_print.pm
1 package FS::part_event::Action::cust_bill_print;
2
3 use strict;
4 use base qw( FS::part_event::Action );
5
6 sub description { 'Send invoice (print only)'; }
7
8 ## declaring that this action will send out an invoice
9 sub will_send_invoice { 1; }
10
11 sub eventtable_hashref {
12   { 'cust_bill' => 1 };
13 }
14
15 sub option_fields {
16   (
17     'modenum' => {  label => 'Invoice mode',
18                     type  => 'select-invoice_mode',
19                  },
20     'skip_nopost' => { label => 'Skip customers without postal billing enabled',
21                        type  => 'checkbox',
22                        value => 'Y',
23                      },
24   );
25 }
26
27 sub default_weight { 51; }
28
29 sub do_action {
30   my( $self, $cust_bill, $cust_event ) = @_;
31
32   #my $cust_main = $self->cust_main($cust_bill);
33   my $cust_main = $cust_bill->cust_main;
34
35   $cust_bill->set('mode' => $self->option('modenum'));
36   if ( $self->option('skip_nopost')
37       && ! grep { $_ eq 'POST' } $cust_main->invoicing_list
38      ) {
39     # then skip customers
40     $cust_event->set('no_action', 'Y');
41     return "customer doesn't receive postal invoices"; # as statustext
42
43   } else {
44     $cust_bill->print;
45   }
46 }
47
48 1;