summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjayce <jayce>2007-09-27 18:24:33 +0000
committerjayce <jayce>2007-09-27 18:24:33 +0000
commite3dd31c479fb51c2a543ef3c0d7aff59bc44d6f4 (patch)
tree9e57bd89c270d20bef562cf3e1c7ec9e201159cf
parent5ca42e2aa31bf595a076f8c6a721c9c74fc51840 (diff)
Multi-System Billing:
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.
-rw-r--r--FS/FS/Cron/bill.pm21
-rw-r--r--FS/FS/Schema.pm1
-rw-r--r--FS/FS/cust_main.pm10
-rwxr-xr-xFS/bin/freeside-daily4
4 files changed, 29 insertions, 7 deletions
diff --git a/FS/FS/Cron/bill.pm b/FS/FS/Cron/bill.pm
index 1a6c4a7f5..38fbae524 100644
--- a/FS/FS/Cron/bill.pm
+++ b/FS/FS/Cron/bill.pm
@@ -44,7 +44,7 @@ sub bill {
)
)
END
-
+
my $where_event = join(' OR ', map {
my $eventtable = $_;
@@ -76,7 +76,7 @@ END
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
@@ -95,12 +95,23 @@ END
}
- 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 {
@@ -112,7 +123,7 @@ END
);
}
-
+
}
}
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 3084e3625..e147e6818 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -1156,6 +1156,7 @@ sub tables_hashref {
'status', 'varchar', '', $char_d, '', '',
'statustext', 'text', 'NULL', '', '', '',
'svcnum', 'int', 'NULL', '', '', '',
+ 'secure', 'char', 'NULL', 1, '', '', # Y = recur tax exempt
],
'primary_key' => 'jobnum',
'unique' => [],
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 6512888ca..9627f9ffd 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -5822,6 +5822,16 @@ sub _agent_plandata {
}
+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
diff --git a/FS/bin/freeside-daily b/FS/bin/freeside-daily
index f0ec9f041..fb855b748 100755
--- a/FS/bin/freeside-daily
+++ b/FS/bin/freeside-daily
@@ -6,7 +6,7 @@ use FS::UID qw(adminsuidsetup);
&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;
@@ -55,7 +55,7 @@ freeside-daily - Run daily billing and invoice collection events.
=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