X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2Fbin%2Ffreeside-prepaidd;h=05b068b02b53509cf2857b0bf1b165fba3b95ca8;hb=7d1b8dab48a9396cf0a066545750f69598f66bc8;hp=73f7523c4b28e208f3e34e1ea1fb7cd7fdb39300;hpb=7b28c0c12fe5e623324102a5ee4114f42b5ede3e;p=freeside.git diff --git a/FS/bin/freeside-prepaidd b/FS/bin/freeside-prepaidd index 73f7523c4..05b068b02 100644 --- a/FS/bin/freeside-prepaidd +++ b/FS/bin/freeside-prepaidd @@ -15,7 +15,7 @@ drop_root(); adminsuidsetup($user); -logfile( "/usr/local/etc/freeside/prepaidd-log.". $FS::UID::datasrc ); +logfile( "%%%FREESIDE_LOG%%%/prepaidd-log.". $FS::UID::datasrc ); daemonize2(); @@ -41,20 +41,31 @@ while (1) { my $work_cust_pkg = $cust_pkg; my $cust_main = $cust_pkg->cust_main; + + #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 - or $cust_main->total_credited > 0 + || $cust_main->total_unapplied_credits > 0 ) { + #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; } - #$b_error = $cust_main->apply_payments_and_credits; - $b_error = $cust_main->apply_payments; - $b_error = $cust_main->apply_credits; $work_cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $work_cust_pkg->pkgnum } );