[freeside-commits] freeside/FS/bin freeside-prepaidd,1.2,1.3
Ivan,,,
ivan at wavetail.420.am
Fri Nov 17 02:16:13 PST 2006
Update of /home/cvs/cvsroot/freeside/FS/bin
In directory wavetail:/tmp/cvs-serv13540
Modified Files:
freeside-prepaidd
Log Message:
initial fix for prepaid renewal problem; attempt to use an existing credit/payment before suspending
Index: freeside-prepaidd
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/bin/freeside-prepaidd,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- freeside-prepaidd 22 Oct 2006 05:18:37 -0000 1.2
+++ freeside-prepaidd 17 Nov 2006 10:16:10 -0000 1.3
@@ -3,7 +3,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::Record qw(qsearch qsearchs);
use FS::cust_pkg;
my $user = shift or die &usage;
@@ -38,12 +38,37 @@
} )
) {
- my $action = $cust_pkg->part_pkg->option('recur_action') || 'suspend';
+ my $work_cust_pkg = $cust_pkg;
- my $error = $cust_pkg->$action();
+ my $cust_main = $cust_pkg->cust_main;
+ if ( $cust_main->total_unapplied_payments > 0
+ or $cust_main->total_credited > 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;
+ $b_error = $cust_main->apply_payments;
+ $b_error = $cust_main->apply_credits;
- warn "Error ${action}ing package ". $cust_pkg->pkgnum.
- " for custnum ". $cust_pkg->custnum.
+ $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;
}
More information about the freeside-commits
mailing list