X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FCron%2Fbill.pm;h=6e110e85230c80fd3d801730812c5f394599bf10;hb=a72a10f754f7465121d6137bb3dcee0a21ea6443;hp=b31880927d1df69a345f89fb933786b927afe6f7;hpb=bbabe74c658a55d27a6dda7b6579bbd332f8f789;p=freeside.git diff --git a/FS/FS/Cron/bill.pm b/FS/FS/Cron/bill.pm index b31880927..6e110e852 100644 --- a/FS/FS/Cron/bill.pm +++ b/FS/FS/Cron/bill.pm @@ -13,6 +13,8 @@ use FS::cust_main; use FS::part_event; use FS::part_event_condition; +use FS::Log; + @ISA = qw( Exporter ); @EXPORT_OK = qw ( bill bill_where ); @@ -27,6 +29,9 @@ use FS::part_event_condition; sub bill { my %opt = @_; + my $log = FS::Log->new('Cron::bill'); + $log->info('start'); + my $check_freq = $opt{'check_freq'} || '1d'; my $debug = 0; @@ -93,6 +98,7 @@ sub bill { 'check_freq' => $check_freq, 'resetup' => ( $opt{'s'} ? $opt{'s'} : 0 ), 'not_pkgpart' => $opt{'g'}, #$not_pkgpart, + 'one_recur' => $opt{'o'}, ); if ( $opt{'m'} ) { @@ -133,6 +139,7 @@ sub bill { $cursor_dbh->commit or die $cursor_dbh->errstr; + $log->info('finish'); } # freeside-daily %opt: @@ -145,7 +152,7 @@ sub bill { # (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 +# with today's date, regardless of the pretend date used to pre-generate # the invoices. # # -p: Only process customers with the specified payby (I, I, I, I, I, I, I) @@ -199,17 +206,18 @@ sub bill_where { # select * from cust_main where my $where_pkg = <<"END"; EXISTS( - SELECT 1 FROM cust_pkg + SELECT 1 FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE cust_main.custnum = cust_pkg.custnum AND ( cancel IS NULL OR cancel = 0 ) - AND ( ( ( setup IS NULL OR setup = 0 ) + AND ( ( ( cust_pkg.setup IS NULL OR cust_pkg.setup = 0 ) AND ( start_date IS NULL OR start_date = 0 OR ( start_date IS NOT NULL AND start_date <= $^T ) ) ) - OR bill IS NULL OR bill <= $billtime + OR ( freq != '0' AND ( bill IS NULL OR bill <= $billtime ) ) OR ( expire IS NOT NULL AND expire <= $^T ) OR ( adjourn IS NOT NULL AND adjourn <= $^T ) + OR ( resume IS NOT NULL AND resume <= $^T ) ) ) END