diff options
author | ivan <ivan> | 2009-06-10 19:50:01 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-06-10 19:50:01 +0000 |
commit | 876eb5c57cbd2b6686ad875b84d9400a3418719c (patch) | |
tree | 72eeb7c0ed40adf601af4dbcb51bd87cdfff1d0b /FS | |
parent | 586a2e2c99956f17899e2fbb52b11a0ac0293a17 (diff) |
don't add another queued_bill job to the queue if there's already one waiting to run for a customer, RT#5572
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Cron/bill.pm | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/FS/FS/Cron/bill.pm b/FS/FS/Cron/bill.pm index 2b5fab476..29f5f36c9 100644 --- a/FS/FS/Cron/bill.pm +++ b/FS/FS/Cron/bill.pm @@ -6,7 +6,8 @@ use Exporter; 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 @@ END 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 @@ END 'priority' => 99, #don't get in the way of provisioning jobs }; my $error = $queue->insert( 'custnum'=>$custnum, %args ); + } } else { |