diff options
Diffstat (limited to 'FS/FS/Cron')
-rw-r--r-- | FS/FS/Cron/tax_batch.pm | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/FS/FS/Cron/tax_batch.pm b/FS/FS/Cron/tax_batch.pm new file mode 100644 index 0000000..59da135 --- /dev/null +++ b/FS/FS/Cron/tax_batch.pm @@ -0,0 +1,26 @@ +package FS::Cron::tax_batch; + +use FS::TaxEngine; +use FS::queue; +use base qw( Exporter ); +@EXPORT_OK = 'process_tax_batch'; + +sub process_tax_batch { + my %opt = @_; + my $engine = FS::TaxEngine->new; + return unless $engine->info->{batch}; + if ( $opt{'m'} ) { + # then there may be queued_bill jobs running; wait for them to finish + while(1) { + my $num_jobs = + FS::queue->count("job = 'FS::cust_main::queued_bill' AND ". + "status != 'failed'"); + last if $num_jobs == 0; + warn "Waiting for billing jobs to finish ($num_jobs still active)...\n"; + sleep(30); + } + } + $engine->transfer_batch(%opt); +} + +1; |