1 package FS::part_event::Condition::cust_bill_past_promised;
5 use Time::Local 'timelocal';
7 use base qw( FS::part_event::Condition );
10 'Promised payment date has passed',
13 sub eventtable_hashref {
22 'delay' => { label => 'Delay additional days',
30 # always return true if there is no promised_date
31 my($self, $cust_bill, %opt) = @_;
33 my $delay = $self->option('delay') || 0;
34 my ($sec,$min,$hour,$mday,$mon,$year) = (localtime($opt{'time'}))[0..5];
35 my $as_of = timelocal(0,0,0,$mday,$mon,$year) - $delay * 86400;
36 $as_of >= ($cust_bill->promised_date || 0);
40 my( $class, $table, %opt ) = @_;
41 return 'true' if $opt{'driver_name'} ne 'Pg';
42 my $delay = $class->condition_sql_option_integer('delay', 'Pg');
43 my ($sec,$min,$hour,$mday,$mon,$year) = (localtime($opt{'time'}))[0..5];
44 my $as_of = timelocal(0,0,0,$mday,$mon,$year) . " - ($delay * 86400)";
45 "(cust_bill.promised_date IS NULL OR $as_of >= cust_bill.promised_date)";