advanced package report: search by properties of the location object, #23582
[freeside.git] / FS / FS / cust_pkg.pm
index be5ec6a..009c81e 100644 (file)
@@ -4283,6 +4283,24 @@ boolean; if true, returns only packages with more than 0 FCC phone lines.
 Limit to packages with a service location in the specified state and country.
 For FCC 477 reporting, mostly.
 
+=item location_cust
+
+Limit to packages whose service location is the same as the customer's 
+default service location.
+
+=item location_nocust
+
+Limit to packages whose service location is not the customer's default 
+service location.
+
+=item location_census
+
+Limit to packages whose service location has a census tract.
+
+=item location_nocensus
+
+Limit to packages whose service location doesn't have a census tract.
+
 =back
 
 =cut
@@ -4515,6 +4533,18 @@ sub search {
   }
 
   ###
+  # location_* flags
+  ###
+  if ( $params->{location_cust} xor $params->{location_nocust} ) {
+    my $op = $params->{location_cust} ? '=' : '!=';
+    push @where, "cust_location.locationnum $op cust_main.ship_locationnum";
+  }
+  if ( $params->{location_census} xor $params->{location_nocensus} ) {
+    my $op = $params->{location_census} ? "IS NOT NULL" : "IS NULL";
+    push @where, "cust_location.censustract $op";
+  }
+
+  ###
   # parse part_pkg
   ###