1 package FS::part_event::Condition::pkg_next_bill_within;
4 use base qw( FS::part_event::Condition );
5 use FS::Record qw( qsearch );
8 'Next bill date within upcoming interval';
11 # Run the event when the next bill date is within X days.
12 # To clarify, that's within X days _after_ the current date,
14 # Combine this with a "once_every" condition so that the event
15 # won't repeat every day until the bill date.
17 sub eventtable_hashref {
26 'within' => { 'label' => 'Bill date within',
29 # possibly "field" to allow date fields besides 'bill'?
34 my( $self, $cust_pkg, %opt ) = @_;
36 my $pkg_date = $cust_pkg->get('bill') or return 0;
37 $pkg_date = $self->option_age_from('within', $pkg_date );
39 $opt{'time'} >= $pkg_date;
43 #XXX write me for efficiency
45 my ($self, $table, %opt) = @_;
47 $self->condition_sql_option_age_from('within', 'cust_pkg.bill')