From: Mark Wells <mark@freeside.biz>
Date: Tue, 24 Feb 2015 03:17:18 +0000 (-0800)
Subject: keep this consistent with 3.x changes on #33587
X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=62759f0a7ad3159372f7c7c6d35fea7e079084e5

keep this consistent with 3.x changes on #33587
---

diff --git a/FS/FS/cust_bill_pkg.pm b/FS/FS/cust_bill_pkg.pm
index 352ed6a12..9b9cf925e 100644
--- a/FS/FS/cust_bill_pkg.pm
+++ b/FS/FS/cust_bill_pkg.pm
@@ -899,7 +899,13 @@ sub usage {
 
     my $sql = 'SELECT SUM(COALESCE(amount,0)) FROM cust_bill_pkg_detail '.
               ' WHERE billpkgnum = '. $self->billpkgnum;
-    $sql .= " AND classnum = $classnum" if defined($classnum);
+    if (defined $classnum) {
+      if ($classnum =~ /^(\d+)$/) {
+        $sql .= " AND classnum = $1";
+      } elsif ($classnum eq '') {
+        $sql .= " AND classnum IS NULL";
+      }
+    }
 
     my $sth = dbh->prepare($sql) or die dbh->errstr;
     $sth->execute or die $sth->errstr;