diff options
author | cvs2git <cvs2git> | 2010-12-27 00:04:45 +0000 |
---|---|---|
committer | cvs2git <cvs2git> | 2010-12-27 00:04:45 +0000 |
commit | c82d349f864e6bd9f96fd1156903bc1f7193a203 (patch) | |
tree | e117a87533656110b6acd56fc0ca64289892a9f5 /FS/bin/freeside-prepaidd | |
parent | 74e058c8a010ef6feb539248a550d0bb169c1e94 (diff) |
This commit was manufactured by cvs2svn to create tag 'TORRUS_1_0_9'.TORRUS_1_0_9
Diffstat (limited to 'FS/bin/freeside-prepaidd')
-rw-r--r-- | FS/bin/freeside-prepaidd | 115 |
1 files changed, 0 insertions, 115 deletions
diff --git a/FS/bin/freeside-prepaidd b/FS/bin/freeside-prepaidd deleted file mode 100644 index 05b068b02..000000000 --- a/FS/bin/freeside-prepaidd +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/perl -w - -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::cust_pkg; - -my $user = shift or die &usage; - -#daemonize1('freeside-sprepaidd', $user); #keep unique pid files w/multi installs -daemonize1('freeside-prepaidd'); - -drop_root(); - -adminsuidsetup($user); - -logfile( "%%%FREESIDE_LOG%%%/prepaidd-log.". $FS::UID::datasrc ); - -daemonize2(); - -#-- - -while (1) { - - foreach my $cust_pkg ( - qsearch( { - 'select' => 'cust_pkg.*, part_pkg.plan', - 'table' => 'cust_pkg', - 'addl_from' => 'LEFT JOIN part_pkg USING ( pkgpart )', - #'hashref' => { 'plan' => 'prepaid' },#should check part_pkg::is_prepaid - #'extra_sql' => "AND bill < ". time. - 'hashref' => {}, - 'extra_sql' => "WHERE plan = 'prepaid' AND bill < ". time. - " AND bill IS NOT NULL". - " AND ( susp IS NULL OR susp = 0)". - " AND ( cancel IS NULL OR cancel = 0)" - } ) - ) { - - 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 - || $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; - } - $b_error = $cust_main->apply_payments_and_credits; - if ( $b_error ) { - warn "Error applying payments&credits, customer #". $cust_main->custnum; - next; - } - - $work_cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $work_cust_pkg->pkgnum } ); - - next - if $cust_main->balance <= 0 - and $work_cust_pkg->bill >= time; - } - - my $action = $work_cust_pkg->part_pkg->option('recur_action') || 'suspend'; - - my $error = $work_cust_pkg->$action(); - - warn "Error ${action}ing package ". $work_cust_pkg->pkgnum. - " for custnum ". $work_cust_pkg->custnum. - ": $error\n" - if $error; - } - - die "exiting" if sigterm() || sigint(); - sleep 5; - -} - -#-- - -sub usage { - die "Usage:\n\n freeside-prepaidd user\n"; -} - -=head1 NAME - -freeside-prepaidd - Real-time daemon for prepaid packages - -=head1 SYNOPSIS - - freeside-prepaidd - -=head1 DESCRIPTION - -Runs continuously and suspends or cancels any prepaid customer packages which -have passed their renewal date (next bill date). - -=head1 SEE ALSO - -=cut - -1; |