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
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;
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
# 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,
} );
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;
"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