From 39fe6499bd38e6e7c468f549b1d4919a7cf2c44d Mon Sep 17 00:00:00 2001 From: Christopher Burger Date: Tue, 15 Jan 2019 14:08:36 -0500 Subject: [PATCH] RT# 37817 - added a declaration to cust bill event actions that send out invoices --- FS/FS/part_event.pm | 16 +++++++++++++++- FS/FS/part_event/Action.pm | 12 ++++++++++++ FS/FS/part_event/Action/cust_bill_email.pm | 3 +++ FS/FS/part_event/Action/cust_bill_fsinc_print.pm | 3 +++ FS/FS/part_event/Action/cust_bill_print.pm | 3 +++ FS/FS/part_event/Action/cust_bill_print_pdf.pm | 3 +++ FS/FS/part_event/Action/cust_bill_send.pm | 3 +++ FS/FS/part_event/Action/cust_bill_send_agent.pm | 3 +++ FS/FS/part_event/Action/cust_bill_send_alternate.pm | 3 +++ FS/FS/part_event/Action/cust_bill_send_csv_ftp.pm | 3 +++ FS/FS/part_event/Action/cust_bill_send_if_newest.pm | 3 +++ FS/FS/part_event/Action/cust_bill_send_reminder.pm | 3 +++ FS/FS/part_event/Action/cust_bill_send_with_notice.pm | 3 +++ FS/FS/part_event/Condition/invoice_has_not_been_sent.pm | 11 ++--------- 14 files changed, 62 insertions(+), 10 deletions(-) diff --git a/FS/FS/part_event.pm b/FS/FS/part_event.pm index ded57154f..ba5b6d641 100644 --- a/FS/FS/part_event.pm +++ b/FS/FS/part_event.pm @@ -570,7 +570,7 @@ foreach my $INC ( @INC ) { } $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() ], @@ -604,6 +604,20 @@ sub all_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 diff --git a/FS/FS/part_event/Action.pm b/FS/FS/part_event/Action.pm index 1916e40a1..fb63ffe2e 100644 --- a/FS/FS/part_event/Action.pm +++ b/FS/FS/part_event/Action.pm @@ -152,6 +152,18 @@ sub deprecated { 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 diff --git a/FS/FS/part_event/Action/cust_bill_email.pm b/FS/FS/part_event/Action/cust_bill_email.pm index 80bcaa1a7..0f833af77 100644 --- a/FS/FS/part_event/Action/cust_bill_email.pm +++ b/FS/FS/part_event/Action/cust_bill_email.pm @@ -5,6 +5,9 @@ use base qw( FS::part_event::Action ); 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 }; } diff --git a/FS/FS/part_event/Action/cust_bill_fsinc_print.pm b/FS/FS/part_event/Action/cust_bill_fsinc_print.pm index e1e25bf26..ea981370e 100644 --- a/FS/FS/part_event/Action/cust_bill_fsinc_print.pm +++ b/FS/FS/part_event/Action/cust_bill_fsinc_print.pm @@ -5,6 +5,9 @@ use base qw( FS::part_event::Action ); 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 }; } diff --git a/FS/FS/part_event/Action/cust_bill_print.pm b/FS/FS/part_event/Action/cust_bill_print.pm index e6a27a34e..4c1311fc1 100644 --- a/FS/FS/part_event/Action/cust_bill_print.pm +++ b/FS/FS/part_event/Action/cust_bill_print.pm @@ -5,6 +5,9 @@ use base qw( FS::part_event::Action ); 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 }; } diff --git a/FS/FS/part_event/Action/cust_bill_print_pdf.pm b/FS/FS/part_event/Action/cust_bill_print_pdf.pm index 6c01d4294..38257b1d4 100644 --- a/FS/FS/part_event/Action/cust_bill_print_pdf.pm +++ b/FS/FS/part_event/Action/cust_bill_print_pdf.pm @@ -5,6 +5,9 @@ use base qw( FS::part_event::Action ); 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 }; } diff --git a/FS/FS/part_event/Action/cust_bill_send.pm b/FS/FS/part_event/Action/cust_bill_send.pm index c6928dc00..d3dc4b722 100644 --- a/FS/FS/part_event/Action/cust_bill_send.pm +++ b/FS/FS/part_event/Action/cust_bill_send.pm @@ -5,6 +5,9 @@ use base qw( FS::part_event::Action ); 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 }; } diff --git a/FS/FS/part_event/Action/cust_bill_send_agent.pm b/FS/FS/part_event/Action/cust_bill_send_agent.pm index cb13b1f09..fcd16139b 100644 --- a/FS/FS/part_event/Action/cust_bill_send_agent.pm +++ b/FS/FS/part_event/Action/cust_bill_send_agent.pm @@ -10,6 +10,9 @@ sub description { # 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 }; } diff --git a/FS/FS/part_event/Action/cust_bill_send_alternate.pm b/FS/FS/part_event/Action/cust_bill_send_alternate.pm index fb71a5a39..ef8e4c041 100644 --- a/FS/FS/part_event/Action/cust_bill_send_alternate.pm +++ b/FS/FS/part_event/Action/cust_bill_send_alternate.pm @@ -5,6 +5,9 @@ use base qw( FS::part_event::Action ); 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 }; } diff --git a/FS/FS/part_event/Action/cust_bill_send_csv_ftp.pm b/FS/FS/part_event/Action/cust_bill_send_csv_ftp.pm index 56ba680e1..9db8e024f 100644 --- a/FS/FS/part_event/Action/cust_bill_send_csv_ftp.pm +++ b/FS/FS/part_event/Action/cust_bill_send_csv_ftp.pm @@ -8,6 +8,9 @@ sub description { 'Upload CSV invoice data to an FTP server'; } sub deprecated { 1; } +## declaring that this action will send out an invoice +sub will_send_invoice { 1; } + sub eventtable_hashref { { 'cust_bill' => 1 }; } diff --git a/FS/FS/part_event/Action/cust_bill_send_if_newest.pm b/FS/FS/part_event/Action/cust_bill_send_if_newest.pm index c744362ce..f946f7e2c 100644 --- a/FS/FS/part_event/Action/cust_bill_send_if_newest.pm +++ b/FS/FS/part_event/Action/cust_bill_send_if_newest.pm @@ -12,6 +12,9 @@ sub description { # 1; #} +## declaring that this action will send out an invoice +sub will_send_invoice { 1; } + sub eventtable_hashref { { 'cust_bill' => 1 }; } diff --git a/FS/FS/part_event/Action/cust_bill_send_reminder.pm b/FS/FS/part_event/Action/cust_bill_send_reminder.pm index 354f969d4..f3326d52c 100644 --- a/FS/FS/part_event/Action/cust_bill_send_reminder.pm +++ b/FS/FS/part_event/Action/cust_bill_send_reminder.pm @@ -5,6 +5,9 @@ use base qw( FS::part_event::Action ); 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 }; } diff --git a/FS/FS/part_event/Action/cust_bill_send_with_notice.pm b/FS/FS/part_event/Action/cust_bill_send_with_notice.pm index efaa03537..d015940cd 100644 --- a/FS/FS/part_event/Action/cust_bill_send_with_notice.pm +++ b/FS/FS/part_event/Action/cust_bill_send_with_notice.pm @@ -7,6 +7,9 @@ use MIME::Entity; 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, diff --git a/FS/FS/part_event/Condition/invoice_has_not_been_sent.pm b/FS/FS/part_event/Condition/invoice_has_not_been_sent.pm index 4868f6636..df78bf728 100644 --- a/FS/FS/part_event/Condition/invoice_has_not_been_sent.pm +++ b/FS/FS/part_event/Condition/invoice_has_not_been_sent.pm @@ -21,15 +21,8 @@ sub eventtable_hashref { 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', -- 2.11.0