[freeside-commits] freeside/FS/FS/Cron bill.pm,1.23,1.24

Ivan,,, ivan at wavetail.420.am
Wed Jun 10 12:50:03 PDT 2009


Update of /home/cvs/cvsroot/freeside/FS/FS/Cron
In directory wavetail.420.am:/tmp/cvs-serv2587

Modified Files:
	bill.pm 
Log Message:
don't add another queued_bill job to the queue if there's already one waiting to run for a customer, RT#5572

Index: bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Cron/bill.pm,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- bill.pm	25 Apr 2009 22:42:40 -0000	1.23
+++ bill.pm	10 Jun 2009 19:50:01 -0000	1.24
@@ -6,7 +6,8 @@
 use Date::Parse;
 use DBI 1.33; #The "clone" method was added in DBI 1.33. 
 use FS::UID qw(dbh);
-use FS::Record qw(qsearchs);
+use FS::Record qw( qsearch qsearchs );
+use FS::queue;
 use FS::cust_main;
 use FS::part_event;
 use FS::part_event_condition;
@@ -141,6 +142,14 @@
         if ( $opt{'r'} ) {
           warn "DRY RUN: would add custnum $custnum for queued_bill\n";
         } else {
+
+          #avoid queuing another job if there's one still waiting to run
+          next if qsearch( 'queue', { 'job'     => 'FS::cust_main::queued_bill',
+                                      'custnum' => $custnum,
+                                      'status'  => 'new',
+                                    }
+                         );
+
           #add job to queue that calls bill_and_collect with options
           my $queue = new FS::queue {
             'job'      => 'FS::cust_main::queued_bill',
@@ -148,6 +157,7 @@
             'priority' => 99, #don't get in the way of provisioning jobs
           };
           my $error = $queue->insert( 'custnum'=>$custnum, %args );
+
         }
 
       } else {



More information about the freeside-commits mailing list