diff options
author | ivan <ivan> | 2009-07-17 22:26:38 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-07-17 22:26:38 +0000 |
commit | 1b8a2cc3b3697f3921e26a31691acfabacc1efd6 (patch) | |
tree | 213a5a147f40cf98e0e870561c57660c7642bf8a | |
parent | 4bfca794e2bd03379d11b9efe437676323e7eb31 (diff) |
commit pkgpart exclusion for billing run, RT#5495
-rw-r--r-- | FS/FS/Cron/bill.pm | 7 | ||||
-rw-r--r-- | FS/FS/cust_main.pm | 15 | ||||
-rwxr-xr-x | FS/bin/freeside-daily | 10 |
3 files changed, 27 insertions, 5 deletions
diff --git a/FS/FS/Cron/bill.pm b/FS/FS/Cron/bill.pm index 61b47355a..1feba7948 100644 --- a/FS/FS/Cron/bill.pm +++ b/FS/FS/Cron/bill.pm @@ -21,6 +21,7 @@ use FS::part_event_condition; # -l: debugging level # -m: Experimental multi-process mode uses the job queue for multi-process and/or multi-machine billing. # -r: Multi-process mode dry run option +# -g: Don't bill these pkgparts sub bill { my %opt = @_; @@ -39,6 +40,9 @@ sub bill { $opt{'invoice_time'} = $opt{'n'} ? $^T : $opt{'time'}; + my $not_pkgpart = $opt{g} ? { map { $_=>1 } split(/,\s*/, $opt{g}) } + : {}; + ### # get a list of custnums ### @@ -74,6 +78,7 @@ sub bill { #(not, when using -m, freeside-queued) 'check_freq' => $check_freq, 'resetup' => ( $opt{'s'} ? $opt{'s'} : 0 ), + 'not_pkgpart' => $not_pkgpart, ); if ( $opt{'m'} ) { @@ -152,6 +157,8 @@ sub bill_where { push @search, "cust_main.agentnum = ". $opt{'a'} if $opt{'a'}; + #it would be useful if i recognized $opt{g} / $not_pkgpart... + if ( @ARGV ) { push @search, "( ". join(' OR ', map "cust_main.custnum = $_", @ARGV ). diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 1f063d950..2957579d7 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -2331,6 +2331,9 @@ Debugging level. Default is 0 (no debugging), or can be set to 1 (passed-in opt =back +Options are passed to the B<bill> and B<collect> methods verbatim, so all +options of those methods are also available. + =cut sub bill_and_collect { @@ -2448,6 +2451,10 @@ An array ref of specific packages (objects) to attempt billing, instead trying a $cust_main->bill( pkg_list => [$pkg1, $pkg2] ); +=item not_pkgpart + +A hashref of pkgparts to exclude from this billing run. + =item invoice_time Used in conjunction with the I<time> option, this option specifies the date of for the generated invoices. Other calculations, such as whether or not to generate the invoice in the first place, are not affected. @@ -2472,6 +2479,8 @@ sub bill { my $time = $options{'time'} || time; my $invoice_time = $options{'invoice_time'} || $time; + $options{'not_pkgpart'} ||= {}; + #put below somehow? local $SIG{HUP} = 'IGNORE'; local $SIG{INT} = 'IGNORE'; @@ -2497,8 +2506,10 @@ sub bill { my %taxlisthash; my @precommit_hooks = (); - $options{ pkg_list } ||= [ $self->ncancelled_pkgs ]; #param checks? - foreach my $cust_pkg ( @{ $options{ pkg_list } } ) { + $options{'pkg_list'} ||= [ $self->ncancelled_pkgs ]; #param checks? + foreach my $cust_pkg ( @{ $options{'pkg_list'} } ) { + + next if $options{'not_pkgpart'}->{$cust_pkg->pkgpart}; warn " bill package ". $cust_pkg->pkgnum. "\n" if $DEBUG > 1; diff --git a/FS/bin/freeside-daily b/FS/bin/freeside-daily index 271c436c6..119f93a59 100755 --- a/FS/bin/freeside-daily +++ b/FS/bin/freeside-daily @@ -7,7 +7,7 @@ use FS::Conf; &untaint_argv; #what it sounds like (eww) use vars qw(%opt); -getopts("p:a:d:vl:sy:nmrk", \%opt); +getopts("p:a:d:vl:sy:nmrkg:", \%opt); my $user = shift or die &usage; adminsuidsetup $user; @@ -31,8 +31,9 @@ unless ( $opt{k} ) { use FS::Cron::notify qw(notify_flat_delay); notify_flat_delay(%opt); - use FS::Cron::vacuum qw(vacuum); - vacuum(); + #Pg 8.1+ auto-vaccums, 7.4 w/postgresql-contrib + #use FS::Cron::vacuum qw(vacuum); + #vacuum(); } @@ -93,6 +94,9 @@ the bill and collect methods of a cust_main object. See L<FS::cust_main>. -a: Only process customers with the specified agentnum + -g: Don't process the provided pkgpart (or pkgparts, specified as a comma- + separated list). + -s: re-charge setup fees -v: enable debugging |