1 package FS::Cron::export_batch;
4 use vars qw( @ISA @EXPORT_OK $me $DEBUG );
7 use FS::Record qw( qsearch qsearchs );
11 @ISA = qw( Exporter );
12 @EXPORT_OK = qw ( export_batch_submit );
14 $me = '[FS::Cron::export_batch]';
17 # -v: enable debugging
19 # -m: Experimental multi-process mode uses the job queue for multi-process and/or multi-machine billing.
20 # -r: Multi-process mode dry run option
21 # -a: Only process customers with the specified agentnum
23 sub export_batch_submit {
25 local $DEBUG = ($opt{l} || 1) if $opt{v};
27 warn "$me batch_submit\n" if $DEBUG;
29 # like pay_batch, none of this is per-agent
31 warn "Export batch processing skipped in per-agent mode.\n" if $DEBUG;
34 my @batches = qsearch({
35 table => 'export_batch',
36 extra_sql => "WHERE status IN ('open', 'closed')",
39 foreach my $batch (@batches) {
40 my $export = $batch->part_export;
41 next if $export->disabled;
42 warn "processing batchnum ".$batch->batchnum.
43 " via ".$export->exporttype. "\n"
47 $export->process($batch);
51 warn "export batch ".$batch->batchnum." failed: $@\n";
52 $batch->set(status => 'failed');
53 $batch->set(statustext => $@);
54 my $error = $batch->replace;
55 die "error recording batch status: $error"
62 # currently there's no batch_receive() or anything of that sort