Merge branch 'patch-1' of https://github.com/gjones2/Freeside
[freeside.git] / FS / FS / part_event / Condition / pkg_dundate.pm
index 08b4e0a..fefee20 100644 (file)
@@ -19,14 +19,14 @@ sub condition {
 
   #my $cust_main = $self->cust_main($cust_pkg);
 
-  $cust_pkg->dundate <= $opt{time};
+  ( $cust_pkg->dundate || 0 ) <= $opt{time};
 
 }
 
-#sub condition_sql {
-#  my( $self, $table ) = @_;
-#
-#  'true';
-#}
+sub condition_sql {
+  my( $class, $table, %opt ) = @_;
+  return 'true' unless $table eq 'cust_pkg';
+  "COALESCE($table.dundate,0) <= ". $opt{'time'};
+}
 
 1;