diff options
-rw-r--r-- | FS/FS/Cron/bill.pm | 7 | ||||
-rw-r--r-- | FS/FS/cust_main.pm | 17 | ||||
-rwxr-xr-x | FS/bin/freeside-daily | 7 |
3 files changed, 19 insertions, 12 deletions
diff --git a/FS/FS/Cron/bill.pm b/FS/FS/Cron/bill.pm index 4d77fd08d..9926fea9e 100644 --- a/FS/FS/Cron/bill.pm +++ b/FS/FS/Cron/bill.pm @@ -24,6 +24,8 @@ sub bill { my($time)= $opt{'d'} ? str2time($opt{'d'}) : $^T; $time += $opt{'y'} * 86400 if $opt{'y'}; + my $invoice_time = $opt{'n'} ? $^T : $time; + # select * from cust_main where my $where_pkg = <<"END"; 0 < ( select count(*) from cust_pkg @@ -102,8 +104,9 @@ END if $error; } - my $error = $cust_main->bill( 'time' => $time, - 'resetup' => $opt{'s'}, + my $error = $cust_main->bill( 'time' => $time, + 'invoice_time' => $invoice_time, + 'resetup' => $opt{'s'}, ); warn "Error billing, custnum ". $cust_main->custnum. ": $error" if $error; diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 252a5ca95..3dbd9c4d5 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -1815,22 +1815,23 @@ sub agent { Generates invoices (see L<FS::cust_bill>) for this customer. Usually used in conjunction with the collect method. -Options are passed as name-value pairs. +If there is an error, returns the error, otherwise returns false. -Currently available options are: +Options are passed as name-value pairs. Currently available options are: -resetup - if set true, re-charges setup fees. +=over 4 -time - bills the customer as if it were that time. Specified as a UNIX -timestamp; see L<perlfunc/"time">). Also see L<Time::Local> and -L<Date::Parse> for conversion functions. For example: +=item resetup - if set true, re-charges setup fees. + +=item time - bills the customer as if it were that time. Specified as a UNIX timestamp; see L<perlfunc/"time">). Also see L<Time::Local> and L<Date::Parse> for conversion functions. For example: use Date::Parse; ... $cust_main->bill( 'time' => str2time('April 20th, 2001') ); +=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. -If there is an error, returns the error, otherwise returns false. +=back =cut @@ -1863,7 +1864,7 @@ sub bill { # no line items] and we're inside a transaciton so nothing else will see it) my $cust_bill = new FS::cust_bill ( { 'custnum' => $self->custnum, - '_date' => $time, + '_date' => ( $options{'invoice_time'} || $time ), #'charged' => $charged, 'charged' => 0, } ); diff --git a/FS/bin/freeside-daily b/FS/bin/freeside-daily index a06a2b185..d5748d6b9 100755 --- a/FS/bin/freeside-daily +++ b/FS/bin/freeside-daily @@ -5,9 +5,8 @@ use Getopt::Std; use FS::UID qw(adminsuidsetup); &untaint_argv; #what it sounds like (eww) -#use vars qw($opt_d $opt_v $opt_p $opt_a $opt_s $opt_y); use vars qw(%opt); -getopts("p:a:d:vsy:", \%opt); +getopts("p:a:d:vsy:n", \%opt); my $user = shift or die &usage; adminsuidsetup $user; @@ -69,6 +68,10 @@ the bill and collect methods of a cust_main object. See L<FS::cust_main>. "pretend date" 15 days from whatever was specified by the -d switch (or now, if no -d switch was given). + -n: When used with "-d" and/or "-y", specifies that invoices should be dated + with today's date, irregardless of the pretend date used to pre-generate + the invoices. + -p: Only process customers with the specified payby (I<CARD>, I<DCRD>, I<CHEK>, I<DCHK>, I<BILL>, I<COMP>, I<LECB>) -a: Only process customers with the specified agentnum |