diff options
author | mark <mark> | 2011-07-12 07:54:22 +0000 |
---|---|---|
committer | mark <mark> | 2011-07-12 07:54:22 +0000 |
commit | 0b81782a6257456e04fb8a5a7faf0dbfbf7bc166 (patch) | |
tree | 91be38b299086b665d00b07c3152ba9c46465448 /FS/FS/part_event | |
parent | 970dfae19db81ed3afdd9f7e15637907f84d5341 (diff) |
credit card expiration event, #13202
Diffstat (limited to 'FS/FS/part_event')
-rw-r--r-- | FS/FS/part_event/Condition/cust_paydate_within.pm | 46 | ||||
-rw-r--r-- | FS/FS/part_event/Condition/once_every.pm | 2 |
2 files changed, 47 insertions, 1 deletions
diff --git a/FS/FS/part_event/Condition/cust_paydate_within.pm b/FS/FS/part_event/Condition/cust_paydate_within.pm new file mode 100644 index 000000000..4808e9083 --- /dev/null +++ b/FS/FS/part_event/Condition/cust_paydate_within.pm @@ -0,0 +1,46 @@ +package FS::part_event::Condition::cust_paydate_within; + +use strict; +use base qw( FS::part_event::Condition ); +use FS::Record qw( str2time_sql str2time_sql_closing ); +use Time::Local 'timelocal'; + +sub description { + 'Credit card expires within upcoming interval'; +} + +# Run the event when the customer's credit card expiration +# date is less than X days in the future. +# Combine this with a "once_every" condition so that the event +# won't repeat every day until the expiration date. + +sub eventtable_hashref { + { 'cust_main' => 1, + 'cust_bill' => 0, + 'cust_pkg' => 0, + }; +} + +sub option_fields { + ( + 'within' => { 'label' => 'Expiration date within', + 'type' => 'freq', + }, + ); +} + +sub condition { + my( $self, $cust_main, %opt ) = @_; + my $expire_time = $cust_main->paydate_epoch or return 0; + $opt{'time'} >= $self->option_age_from('within', $expire_time); +} + +sub condition_sql { + my ($self, $table, %opt) = @_; + my $expire_time = FS::cust_main->paydate_epoch_sql or return 'true'; + $opt{'time'} . ' >= ' . + $self->condition_sql_option_age_from('within', $expire_time); +} + +1; + diff --git a/FS/FS/part_event/Condition/once_every.pm b/FS/FS/part_event/Condition/once_every.pm index 2921b3a22..ef28078ed 100644 --- a/FS/FS/part_event/Condition/once_every.pm +++ b/FS/FS/part_event/Condition/once_every.pm @@ -31,7 +31,7 @@ sub condition { 'eventpart' => $self->eventpart, 'tablenum' => $tablenum, 'status' => { op=>'!=', value=>'failed' }, - '_date' => { op=>'>=', value=>$max_date }, + '_date' => { op=>'>', value=>$max_date }, }, 'extra_sql' => ( $opt{'cust_event'}->eventnum =~ /^(\d+)$/ ? " AND eventnum != $1 " |