fix times condition vs. mysql (causes billing errors even if not using), RT#10574
[freeside.git] / FS / FS / part_event / Condition / times.pm
index 91212e7..46c2967 100644 (file)
@@ -39,17 +39,20 @@ sub condition {
 }
 
 sub condition_sql {
-  my( $class, $table ) = @_;
+  my( $class, $table, %opt ) = @_;
 
   my %tablenum = %{ FS::part_event->eventtable_pkey_sql };
 
+  my $run_times =
+    $class->condition_sql_option_integer('run_times', $opt{'driver_name'});
+
   my $existing = "( SELECT COUNT(*) FROM cust_event
                       WHERE cust_event.eventpart = part_event.eventpart
                         AND cust_event.tablenum = $tablenum{$table}
                         AND status != 'failed'
                   )";
 
-  "$existing <= ". $class->condition_sql_option_integer('run_times');
+  "$existing <= $run_times";
 
 }