proper fix for once.pm bug? hopefully it works :)
authorivan <ivan>
Tue, 2 Oct 2007 00:22:41 +0000 (00:22 +0000)
committerivan <ivan>
Tue, 2 Oct 2007 00:22:41 +0000 (00:22 +0000)
FS/FS/cust_event.pm
FS/FS/part_event/Condition.pm
FS/FS/part_event/Condition/once.pm

index 13b3efa..355bc25 100644 (file)
@@ -190,6 +190,7 @@ sub test_conditions {
   my $part_event = $self->part_event;
   my $object = $self->cust_X;
   my @conditions = $part_event->part_event_condition;
+  %opt{'cust_event'} = $self;
 
   #no unsatisfied conditions
   #! grep ! $_->condition( $object, %opt ), @conditions;
index 268b9e6..0b9d579 100644 (file)
@@ -125,6 +125,8 @@ Available additional arguments:
 
   $time = $opt{'time'}; #use this instead of time or $^T
 
+  $cust_event = $opt{'cust_event'}; #to retreive the cust_event object being tested
+
 Return a true value if the condition has been met, and a false value if it has
 not.
 
index ba3ccbb..bb0fa22 100644 (file)
@@ -16,7 +16,7 @@ sub remove_warning {
 }
 
 sub condition {
-  my($self, $object) = @_;
+  my($self, $object, %opt) = @_;
 
   my $obj_pkey = $object->primary_key;
   my $tablenum = $object->$obj_pkey();
@@ -24,7 +24,12 @@ sub condition {
   my @existing = qsearch( 'cust_event', {
     'eventpart' => $self->eventpart,
     'tablenum'  => $tablenum,
-    'status'    => { op=>'NOT IN', value=>"('failed','new')" },
+    #'status'    => { op=>'NOT IN', value=>"('failed','new')" },
+    'status'    => { op=>'!=', value=>'failed' },
+    'addl_sql'  => ( $opt{'cust_event'}->eventnum =~ /^(\d+)$/
+                       ? " AND eventnum != $1 "
+                       : ''
+                   ),
   } );
 
   ! scalar(@existing);