add option to skip customers without postal invocing to print event instead of the...
[freeside.git] / FS / FS / part_event / Action / cust_bill_print.pm
index 6b3e6f4..b94e882 100644 (file)
@@ -9,6 +9,18 @@ sub eventtable_hashref {
   { 'cust_bill' => 1 };
 }
 
+sub option_fields {
+  (
+    'modenum' => {  label => 'Invoice mode',
+                    type  => 'select-invoice_mode',
+                 },
+    'skip_nopost' => { label => 'Skip customers without postal billing enabled',
+                       type  => 'checkbox',
+                       value => 'Y',
+                     },
+  );
+}
+
 sub default_weight { 51; }
 
 sub do_action {
@@ -17,7 +29,9 @@ sub do_action {
   #my $cust_main = $self->cust_main($cust_bill);
   my $cust_main = $cust_bill->cust_main;
 
-  $cust_bill->print;
+  $cust_bill->set('mode' => $self->option('modenum'));
+  $cust_bill->print unless $self->option('skip_nopost')
+                        && ! grep { $_ eq 'POST' } $cust_main->invoicing_list;
 }
 
 1;