diff options
| author | Mike Robinson <miker@freeside.biz> | 2012-04-26 12:21:24 -0500 |
|---|---|---|
| committer | Mike Robinson <miker@freeside.biz> | 2012-04-26 15:53:21 -0500 |
| commit | 7a4799ade451508cea6423ac2a90d3b1b1c0f1e0 (patch) | |
| tree | 4ce939db4efe24056a9604a8668e36beee09686d | |
| parent | 6eac2876e787aa44191f9af04ac3124aa92634c5 (diff) | |
pkg_dundate_age condition (#17394)
| -rw-r--r-- | FS/FS/part_event/Condition/pkg_dundate_age.pm | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/FS/FS/part_event/Condition/pkg_dundate_age.pm b/FS/FS/part_event/Condition/pkg_dundate_age.pm new file mode 100644 index 000000000..2ea2a2041 --- /dev/null +++ b/FS/FS/part_event/Condition/pkg_dundate_age.pm @@ -0,0 +1,43 @@ +package FS::part_event::Condition::pkg_dundate_age; +use base qw( FS::part_event::Condition ); + +use strict; + +sub description { + "Skip until specified #days before package suspension delay date"; +} + + +sub option_fields { + ( + 'age' => { 'label' => 'Time before suspension delay date', + 'type' => 'freq', + }, + ); +} + +sub eventtable_hashref { + { 'cust_main' => 0, + 'cust_bill' => 0, + 'cust_pkg' => 1, + }; +} + +sub condition { + my($self, $cust_pkg, %opt) = @_; + + my $age = $self->option_age_from('age', $opt{'time'} ); + + $cust_pkg->dundate <= $age; +} + +sub condition_sql { + my( $class, $table, %opt ) = @_; + return 'true' unless $table eq 'cust_pkg'; + + my $age = $class->condition_sql_option_age_from('age', $opt{'time'}); + + "COALESCE($table.dundate,0) <= ". $age; +} + +1; |
