fix RADIUS report fallout from adding closed session option, RT#22169, RT#21483
[freeside.git] / FS / FS / part_export / sqlradius.pm
index db66c39..833dd9a 100644 (file)
@@ -741,8 +741,11 @@ sub usage_sessions {
     }
   }
   if ( $opt->{session_status} ne 'closed' ) {
-    $acctstoptime = "( $acctstoptime ) OR " if $acctstoptime;
-    $acctstoptime .= 'AcctStopTime IS NULL';
+    if ( $acctstoptime ) {
+      $acctstoptime = "( ( $acctstoptime ) OR AcctStopTime IS NULL )";
+    } else {
+      $acctstoptime = 'AcctStopTime IS NULL';
+    }
   }
   push @where, $acctstoptime;