X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2Fbin%2Ffreeside-prepaidd;h=cb831543597c806dc424c4e89f04483d83684327;hp=86bfe8794e13864211a1ff349873d464189d92b5;hb=1f1190b8fb6d06852dbd16c6a288f9acd9cc83dd;hpb=624b2d44625f69d71175c3348cae635d580c890b diff --git a/FS/bin/freeside-prepaidd b/FS/bin/freeside-prepaidd old mode 100644 new mode 100755 index 86bfe8794..cb8315435 --- a/FS/bin/freeside-prepaidd +++ b/FS/bin/freeside-prepaidd @@ -4,6 +4,7 @@ use strict; use FS::Daemon qw(daemonize1 drop_root logfile daemonize2 sigint sigterm); use FS::UID qw(adminsuidsetup); use FS::Record qw(qsearch qsearchs); +use FS::Conf; use FS::cust_pkg; my $user = shift or die &usage; @@ -41,21 +42,32 @@ while (1) { my $work_cust_pkg = $cust_pkg; my $cust_main = $cust_pkg->cust_main; - if ( $cust_main->total_unapplied_payments > 0 - or $cust_main->total_credited > 0 + + #insurance: somehow winding up here without things properly applied... + my $a_error = $cust_main->apply_payments_and_credits; + if ( $a_error ) { + warn "Error applying payments&credits, customer #". $cust_main->custnum; + next; + } + + if ( ( $cust_main->total_unapplied_payments > 0 + || $cust_main->total_unapplied_credits > 0 + ) + && ! FS::Conf->new->exists('prepaid-never_renew') ) { + #this needs a flag to say only do the prepaid packages... # and only try em if the renewal price matches.. but this will do for now my $b_error = $cust_main->bill; if ( $b_error ) { warn "Error billing customer #". $cust_main->custnum; - next; + next; } $b_error = $cust_main->apply_payments_and_credits; if ( $b_error ) { warn "Error applying payments&credits, customer #". $cust_main->custnum; - next; + next; } $work_cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $work_cust_pkg->pkgnum } ); @@ -76,7 +88,7 @@ while (1) { } die "exiting" if sigterm() || sigint(); - sleep 5; + sleep 60; }