with a -m flag, daily will queue billing jobs instead of running each. freeside-queued will then pick it up, allowing multiple simultaneous jobs to run, as well as multiple machines.
Also adds a 'Secure' column to the queue system, allowing for billing jobs to define themselves as 'secure only' in cases where a box might be using the encryption. This allows you to
run secure only jobs (such as a collect) on boxes that can.
)
)
END
-
+
my $where_event = join(' OR ', map {
my $eventtable = $_;
my $extra_sql = ( scalar(%search) ? ' AND ' : ' WHERE ' ).
"( $where_pkg OR $where_event )";
-
+
my @cust_main;
if ( @ARGV ) {
@cust_main = map { qsearchs('cust_main', { custnum => $_, %search } ) } @ARGV
}
- foreach my $cust_main ( @cust_main ) {
+ my($cust_main,%saw);
+ foreach $cust_main ( @cust_main ) {
if ( $opt{'m'} ) {
- die "XXX multi-process mode not yet completed";
#add job to queue that calls bill_and_collect with options
+ my $queue = new FS::queue {
+ 'job' => 'FS::cust_main::queued_bill',
+ 'secure' => 'Y',
+ };
+ my $error = $queue->insert(
+ 'custnum' => $cust_main->custnum,
+ 'time' => $time,
+ 'invoice_time' => $invoice_time,
+ 'check_freq' => $check_freq,
+ 'resetup' => $opt{'s'} ? $opt{'s'} : 0,
+ );
} else {
);
}
-
+
}
}
'status', 'varchar', '', $char_d, '', '',
'statustext', 'text', 'NULL', '', '', '',
'svcnum', 'int', 'NULL', '', '', '',
+ 'secure', 'char', 'NULL', 1, '', '', # Y = recur tax exempt
],
'primary_key' => 'jobnum',
'unique' => [],
}
+sub queued_bill {
+ ## actual sub, not a method, designed to be called from the queue.
+ ## sets up the customer, and calls the bill_and_collect
+ my (%args) = @_; #, ($time, $invoice_time, $check_freq, $resetup) = @_;
+ my $cust_main = qsearchs( 'cust_main', { custnum => $args{'custnum'} } );
+ $cust_main->bill_and_collect(
+ %args,
+ );
+}
+
=back
=head1 BUGS
&untaint_argv; #what it sounds like (eww)
use vars qw(%opt);
-getopts("p:a:d:vl:sy:n", \%opt);
+getopts("p:a:d:vl:sy:nm", \%opt);
my $user = shift or die &usage;
adminsuidsetup $user;
=head1 SYNOPSIS
- freeside-daily [ -d 'date' ] [ -y days ] [ -p 'payby' ] [ -a agentnum ] [ -s ] [ -v ] [ -l level ] user [ custnum custnum ... ]
+ freeside-daily [ -d 'date' ] [ -y days ] [ -p 'payby' ] [ -a agentnum ] [ -s ] [ -v ] [ -l level ] [ -m ]user [ custnum custnum ... ]
=head1 DESCRIPTION