RT# 37817 - added a declaration to cust bill event actions that send out invoices
authorChristopher Burger <burgerc@freeside.biz>
Tue, 15 Jan 2019 19:08:36 +0000 (14:08 -0500)
committerChristopher Burger <burgerc@freeside.biz>
Tue, 15 Jan 2019 19:08:36 +0000 (14:08 -0500)
14 files changed:
FS/FS/part_event.pm
FS/FS/part_event/Action.pm
FS/FS/part_event/Action/cust_bill_email.pm
FS/FS/part_event/Action/cust_bill_fsinc_print.pm
FS/FS/part_event/Action/cust_bill_print.pm
FS/FS/part_event/Action/cust_bill_print_pdf.pm
FS/FS/part_event/Action/cust_bill_send.pm
FS/FS/part_event/Action/cust_bill_send_agent.pm
FS/FS/part_event/Action/cust_bill_send_alternate.pm
FS/FS/part_event/Action/cust_bill_send_csv_ftp.pm
FS/FS/part_event/Action/cust_bill_send_if_newest.pm
FS/FS/part_event/Action/cust_bill_send_reminder.pm
FS/FS/part_event/Action/cust_bill_send_with_notice.pm
FS/FS/part_event/Condition/invoice_has_not_been_sent.pm

index ded5715..ba5b6d6 100644 (file)
@@ -570,7 +570,7 @@ foreach my $INC ( @INC ) {
     }
     $actions{$mod} = {
       ( map { $_ => "FS::part_event::Action::$mod"->$_() }
     }
     $actions{$mod} = {
       ( map { $_ => "FS::part_event::Action::$mod"->$_() }
-            qw( description eventtable_hashref default_weight deprecated )
+            qw( description eventtable_hashref default_weight deprecated will_send_invoice )
             #option_fields_hashref
       ),
       'option_fields' => [ "FS::part_event::Action::$mod"->option_fields() ],
             #option_fields_hashref
       ),
       'option_fields' => [ "FS::part_event::Action::$mod"->option_fields() ],
@@ -604,6 +604,20 @@ sub all_actions {
        keys %actions
 }
 
        keys %actions
 }
 
+=item invoice_send_actions
+
+Returns a list of action names that send invoices
+
+=cut
+
+sub invoice_send_actions {
+  my ( $class ) = @_;
+
+  grep { $actions{$_}->{'will_send_invoice'} }
+       keys %actions
+
+}
+
 =item process_initialize 'eventpart' => EVENTPART
 
 Job queue wrapper for "initialize".  EVENTPART identifies the 
 =item process_initialize 'eventpart' => EVENTPART
 
 Job queue wrapper for "initialize".  EVENTPART identifies the 
index 1916e40..fb63ffe 100644 (file)
@@ -152,6 +152,18 @@ sub deprecated {
   0;
 }
 
   0;
 }
 
+=item will_send_invoice
+
+Action classes may define a will_send_invoice method that returns true, indicating
+that this action is sending out an invoice.
+
+=cut
+
+#default
+sub will_send_invoice {
+  0;
+}
+
 =item do_action CUSTOMER_EVENT_OBJECT
 
 Action classes must define an action method.  This method is triggered if
 =item do_action CUSTOMER_EVENT_OBJECT
 
 Action classes must define an action method.  This method is triggered if
index 80bcaa1..0f833af 100644 (file)
@@ -5,6 +5,9 @@ use base qw( FS::part_event::Action );
 
 sub description { 'Send invoice (email only)'; }
 
 
 sub description { 'Send invoice (email only)'; }
 
+## declaring that this action will send out an invoice
+sub will_send_invoice { 1; }
+
 sub eventtable_hashref {
   { 'cust_bill' => 1 };
 }
 sub eventtable_hashref {
   { 'cust_bill' => 1 };
 }
index e1e25bf..ea98137 100644 (file)
@@ -5,6 +5,9 @@ use base qw( FS::part_event::Action );
 
 sub description { 'Send invoice to Freeside Inc. for printing and mailing'; }
 
 
 sub description { 'Send invoice to Freeside Inc. for printing and mailing'; }
 
+## declaring that this action will send out an invoice
+sub will_send_invoice { 1; }
+
 sub eventtable_hashref {
   { 'cust_bill' => 1 };
 }
 sub eventtable_hashref {
   { 'cust_bill' => 1 };
 }
index e6a27a3..4c1311f 100644 (file)
@@ -5,6 +5,9 @@ use base qw( FS::part_event::Action );
 
 sub description { 'Send invoice (print only)'; }
 
 
 sub description { 'Send invoice (print only)'; }
 
+## declaring that this action will send out an invoice
+sub will_send_invoice { 1; }
+
 sub eventtable_hashref {
   { 'cust_bill' => 1 };
 }
 sub eventtable_hashref {
   { 'cust_bill' => 1 };
 }
index 6c01d42..38257b1 100644 (file)
@@ -5,6 +5,9 @@ use base qw( FS::part_event::Action );
 
 sub description { 'Send invoice (spool PDF only)'; }
 
 
 sub description { 'Send invoice (spool PDF only)'; }
 
+## declaring that this action will send out an invoice
+sub will_send_invoice { 1; }
+
 sub eventtable_hashref {
   { 'cust_bill' => 1 };
 }
 sub eventtable_hashref {
   { 'cust_bill' => 1 };
 }
index c6928dc..d3dc4b7 100644 (file)
@@ -5,6 +5,9 @@ use base qw( FS::part_event::Action );
 
 sub description { 'Send invoice (email/print/fax)'; }
 
 
 sub description { 'Send invoice (email/print/fax)'; }
 
+## declaring that this action will send out an invoice
+sub will_send_invoice { 1; }
+
 sub eventtable_hashref {
   { 'cust_bill' => 1 };
 }
 sub eventtable_hashref {
   { 'cust_bill' => 1 };
 }
index cb13b1f..fcd1613 100644 (file)
@@ -10,6 +10,9 @@ sub description {
 # this event is just cust_bill_send_alternate + an implicit (and inefficient)
 # 'agent' condition
 
 # this event is just cust_bill_send_alternate + an implicit (and inefficient)
 # 'agent' condition
 
+## declaring that this action will send out an invoice
+sub will_send_invoice { 1; }
+
 sub eventtable_hashref {
   { 'cust_bill' => 1 };
 }
 sub eventtable_hashref {
   { 'cust_bill' => 1 };
 }
index fb71a5a..ef8e4c0 100644 (file)
@@ -5,6 +5,9 @@ use base qw( FS::part_event::Action );
 
 sub description { 'Send invoice (email/print/fax) with alternate template'; }
 
 
 sub description { 'Send invoice (email/print/fax) with alternate template'; }
 
+## declaring that this action will send out an invoice
+sub will_send_invoice { 1; }
+
 sub eventtable_hashref {
   { 'cust_bill' => 1 };
 }
 sub eventtable_hashref {
   { 'cust_bill' => 1 };
 }
index 56ba680..9db8e02 100644 (file)
@@ -8,6 +8,9 @@ sub description { 'Upload CSV invoice data to an FTP server'; }
 
 sub deprecated { 1; }
 
 
 sub deprecated { 1; }
 
+## declaring that this action will send out an invoice
+sub will_send_invoice { 1; }
+
 sub eventtable_hashref {
   { 'cust_bill' => 1 };
 }
 sub eventtable_hashref {
   { 'cust_bill' => 1 };
 }
index c744362..f946f7e 100644 (file)
@@ -12,6 +12,9 @@ sub description {
 #  1;
 #}
 
 #  1;
 #}
 
+## declaring that this action will send out an invoice
+sub will_send_invoice { 1; }
+
 sub eventtable_hashref {
   { 'cust_bill' => 1 };
 }
 sub eventtable_hashref {
   { 'cust_bill' => 1 };
 }
index 354f969..f3326d5 100644 (file)
@@ -5,6 +5,9 @@ use base qw( FS::part_event::Action );
 
 sub description { 'Send invoice (email/print/fax) reminder'; }
 
 
 sub description { 'Send invoice (email/print/fax) reminder'; }
 
+## declaring that this action will send out an invoice
+sub will_send_invoice { 1; }
+
 sub eventtable_hashref {
   { 'cust_bill' => 1 };
 }
 sub eventtable_hashref {
   { 'cust_bill' => 1 };
 }
index efaa035..d015940 100644 (file)
@@ -7,6 +7,9 @@ use MIME::Entity;
 
 sub description { 'Email a notice to the customer with invoice attached'; }
 
 
 sub description { 'Email a notice to the customer with invoice attached'; }
 
+## declaring that this action will send out an invoice
+sub will_send_invoice { 1; }
+
 sub eventtable_hashref {
     {
       'cust_main'      => 1,
 sub eventtable_hashref {
     {
       'cust_main'      => 1,
index 4868f66..df78bf7 100644 (file)
@@ -21,15 +21,8 @@ sub eventtable_hashref {
 sub condition {
   my($self, $cust_bill, %opt) = @_;
 
 sub condition {
   my($self, $cust_bill, %opt) = @_;
 
-  ## search actions for invoice send events.
-  my @send_actions = (
-    "action LIKE 'cust_bill_send%'",
-    "action LIKE 'cust_bill_email%'",
-    "action LIKE 'cust_bill_print%'",
-    "action LIKE 'cust_bill_fsinc_print%'",
-  );
-  my $actions = join ' OR ', @send_actions;
-  my $extra_sql = " AND ($actions)";
+  my $invoice_send_actions = join "', '", (FS::part_event::invoice_send_actions());
+  my $extra_sql = " AND action in ('".$invoice_send_actions."')";
 
   my $event = qsearchs( {
     'table'     => 'cust_event',
 
   my $event = qsearchs( {
     'table'     => 'cust_event',