X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_event%2FCondition%2Fcust_bill_past_due.pm;h=5e24acfc941ee289a296b7d1b28bbe8dfa1408fc;hb=f4daf7e8c831fe126dc3fd1d6d0db5ee3b46d602;hp=a889a0090daba391c3029cfc5a2f7fdb91941c46;hpb=0fb307c305e4bc2c9c27dc25a3308beae3a4d33c;p=freeside.git diff --git a/FS/FS/part_event/Condition/cust_bill_past_due.pm b/FS/FS/part_event/Condition/cust_bill_past_due.pm index a889a0090..5e24acfc9 100644 --- a/FS/FS/part_event/Condition/cust_bill_past_due.pm +++ b/FS/FS/part_event/Condition/cust_bill_past_due.pm @@ -17,25 +17,32 @@ sub eventtable_hashref { }; } +sub option_fields { + ( + 'delay' => { label => 'Delay additional days', + type => 'text', + value => '0', + }, + ); +} + sub condition { my($self, $cust_bill, %opt) = @_; - # If the invoice date is 1/1 at noon and the terms are Net 15, - # the due_date will be 1/16 at noon. Past due events will not - # trigger until after the start of 1/17. + my $delay = $self->option('delay') || 0; my ($sec,$min,$hour,$mday,$mon,$year) = (localtime($opt{'time'}))[0..5]; - my $start_of_today = timelocal(0,0,0,$mday,$mon,$year)+1; - ($cust_bill->due_date || $cust_bill->_date) < $start_of_today; + my $as_of = timelocal(0,0,0,$mday,$mon,$year) - $delay * 86400; + $as_of >= ($cust_bill->due_date || $cust_bill->_date); } -sub condition_sql { - return 'true' if $FS::UID::driver_name ne 'Pg'; - my( $class, $table, %opt ) = @_; - my ($sec,$min,$hour,$mday,$mon,$year) = (localtime($opt{'time'}))[0..5]; - my $start_of_today = timelocal(0,0,0,$mday,$mon,$year)+1; - - FS::cust_bill->due_date_sql . " < $start_of_today"; - -} +#->due_date_sql can't cope with agent-specific invoice_default_terms +#sub condition_sql { +# my( $class, $table, %opt ) = @_; +# return 'true' if $opt{'driver_name'} ne 'Pg'; +# my $delay = $class->condition_sql_option_integer('delay', 'Pg'); +# my ($sec,$min,$hour,$mday,$mon,$year) = (localtime($opt{'time'}))[0..5]; +# my $as_of = timelocal(0,0,0,$mday,$mon,$year) . " - ($delay * 86400)"; +# "( $as_of ) >= ".FS::cust_bill->due_date_sql; +#} 1;