[freeside-commits] freeside/FS/FS cust_main.pm,1.312,1.313

Ivan,,, ivan at wavetail.420.am
Thu Oct 4 16:41:57 PDT 2007


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv24223

Modified Files:
	cust_main.pm 
Log Message:
don't leave stray 'new' events around if they don't pass their final condition check

Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.312
retrieving revision 1.313
diff -u -d -r1.312 -r1.313
--- cust_main.pm	4 Oct 2007 19:04:40 -0000	1.312
+++ cust_main.pm	4 Oct 2007 23:41:55 -0000	1.313
@@ -1912,7 +1912,6 @@
 
 Debugging level.  Default is 0 (no debugging), or can be set to 1 (passed-in options), 2 (traces progress), 3 (more information), or 4 (include full search queries)
 
-
 =back
 
 =cut
@@ -1980,11 +1979,11 @@
 
 =item resetup
 
-if set true, re-charges setup fees.
+If set true, re-charges setup fees.
 
 =item time
 
-bills the customer as if it were that time.  Specified as a UNIX timestamp; see L<perlfunc/"time">).  Also see L<Time::Local> and L<Date::Parse> for conversion functions.  For example:
+Bills the customer as if it were that time.  Specified as a UNIX timestamp; see L<perlfunc/"time">).  Also see L<Time::Local> and L<Date::Parse> for conversion functions.  For example:
 
  use Date::Parse;
  ...
@@ -1998,7 +1997,7 @@
 
 =item invoice_time
 
-used in conjunction with the I<time> option, this option specifies the date of for the generated invoices.  Other calculations, such as whether or not to generate the invoice in the first place, are not affected.
+Used in conjunction with the I<time> option, this option specifies the date of for the generated invoices.  Other calculations, such as whether or not to generate the invoice in the first place, are not affected.
 
 =back
 
@@ -2525,7 +2524,16 @@
     #XXX lock event
     
     #re-eval event conditions (a previous event could have changed things)
-    next unless $cust_event->test_conditions( 'time' => $invoice_time );
+    unless ( $cust_event->test_conditions( 'time' => $invoice_time ) ) {
+      #don't leave stray "new/locked" records around
+      my $error = $cust_event->delete;
+      if ( $error ) {
+        #gah, even with transactions
+        $dbh->commit if $oldAutoCommit; #well.
+        return $error;
+      }
+      next;
+    }
 
     {
       local $realtime_bop_decline_quiet = 1 if $options{'quiet'};
@@ -2579,11 +2587,11 @@
 
 =item eventtable
 
-nly return events for the specified eventtable (by default, events of all eventtables are returned)
+Only return events for the specified eventtable (by default, events of all eventtables are returned)
 
 =item objects
 
-xplicitly pass the objects to be tested (typically used with eventtable).
+Explicitly pass the objects to be tested (typically used with eventtable).
 
 =back
 
@@ -2673,6 +2681,8 @@
 
       $extra_sql .= " $order";
 
+      warn "searching for events for $eventtable ". $object->$pkey. "\n"
+        if $opt{'debug'} > 2;
       my @part_event = qsearch( {
         'debug'     => ( $opt{'debug'} > 3 ? 1 : 0 ),
         'select'    => 'part_event.*',



More information about the freeside-commits mailing list