summaryrefslogtreecommitdiff
path: root/FS/FS/Cron
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2014-10-31 15:45:50 -0700
committerMark Wells <mark@freeside.biz>2014-10-31 15:45:50 -0700
commit7516e3da0f17eeecba27219ef96a8b5f46af2083 (patch)
tree772fe13627910a7d0774871633697f2a4d1c6faf /FS/FS/Cron
parentf31a9212ab3835b815aa87a86cca3b19babcaaff (diff)
tax engine refactoring for Avalara and Billsoft tax vendors, #25718
Diffstat (limited to 'FS/FS/Cron')
-rw-r--r--FS/FS/Cron/tax_batch.pm26
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;