[freeside-commits] freeside/FS/FS cust_pkg.pm,1.71,1.72

Ivan,,, ivan at wavetail.420.am
Sat Feb 3 05:05:55 PST 2007


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv9269

Modified Files:
	cust_pkg.pm 
Log Message:
this should fix services with negative num_avail showing up for provisioning

Index: cust_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_pkg.pm,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- cust_pkg.pm	23 Jan 2007 23:42:59 -0000	1.71
+++ cust_pkg.pm	3 Feb 2007 13:05:53 -0000	1.72
@@ -2,6 +2,7 @@
 
 use strict;
 use vars qw(@ISA $disable_agentcheck $DEBUG);
+use List::Util qw(max);
 use Tie::IxHash;
 use FS::UID qw( getotaker dbh );
 use FS::Misc qw( send_email );
@@ -901,7 +902,8 @@
     my $part_svc = $pkg_svc->part_svc;
     my $num_cust_svc = $self->num_cust_svc($part_svc->svcpart);
     $part_svc->{'Hash'}{'num_cust_svc'} = $num_cust_svc; #more evil
-    $part_svc->{'Hash'}{'num_avail'}    = $pkg_svc->quantity - $num_cust_svc;
+    $part_svc->{'Hash'}{'num_avail'}    =
+      max( 0, $pkg_svc->quantity - $num_cust_svc );
     $part_svc->{'Hash'}{'cust_pkg_svc'} = [ $self->cust_svc($part_svc->svcpart) ];
     $part_svc;
   } $self->part_pkg->pkg_svc;



More information about the freeside-commits mailing list