882762dfe95fb1b8fc80c4c2062ef58c367a7d78
[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 $event = qsearchs( {
25     'table'     => 'cust_event',
26     'addl_from' => 'LEFT JOIN part_event USING ( eventpart )',
27     'hashref'   => {
28                 'tablenum'  => $cust_bill->{Hash}->{invnum},
29                 'eventtable'  => 'cust_bill',
30                 'status'    => 'done',
31         },
32     'order_by'  => " LIMIT 1",
33   } );
34
35   return 0 if $event;
36
37   1;
38
39 }
40
41 1;