RT# 37817 - added a declaration to cust bill event actions that send out invoices
[freeside.git] / FS / FS / part_event / Condition / invoice_has_not_been_sent.pm
1 package FS::part_event::Condition::invoice_has_not_been_sent;
2
3 use strict;
4 use FS::Record qw( qsearchs );
5 use FS::cust_bill;
6 use Time::Local 'timelocal';
7
8 use base qw( FS::part_event::Condition );
9
10 sub description {
11   'Invoice has not been sent previously';
12 }
13
14 sub eventtable_hashref {
15     { 'cust_main' => 0,
16       'cust_bill' => 1,
17       'cust_pkg'  => 0,
18     };
19 }
20
21 sub condition {
22   my($self, $cust_bill, %opt) = @_;
23
24   my $invoice_send_actions = join "', '", (FS::part_event::invoice_send_actions());
25   my $extra_sql = " AND action in ('".$invoice_send_actions."')";
26
27   my $event = qsearchs( {
28     'table'     => 'cust_event',
29     'addl_from' => 'LEFT JOIN part_event USING ( eventpart )',
30     'hashref'   => {
31       'tablenum'   => $cust_bill->{Hash}->{invnum},
32       'eventtable' => 'cust_bill',
33       'status'     => 'done',
34     },
35     'order_by'  => " LIMIT 1",
36     'extra_sql' => $extra_sql,
37   } );
38
39   return 0 if $event;
40
41   1;
42
43 }
44
45 1;