summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2012-04-25 11:26:36 -0700
committerMark Wells <mark@freeside.biz>2012-04-25 11:26:36 -0700
commit5fd66da492a1b206fa4e944eb0caa2e2642d454a (patch)
tree0bd9b1b8fc8222572d1bf69d2f4b4d20dc5249f3 /FS
parent998dcad2d8f4b8e22b9a2f042f006b9167b8cdf3 (diff)
consider districts in tax liability report, #17051
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/cust_main_county.pm2
-rw-r--r--FS/FS/cust_pkg.pm23
2 files changed, 16 insertions, 9 deletions
diff --git a/FS/FS/cust_main_county.pm b/FS/FS/cust_main_county.pm
index e937b205c..6316f239a 100644
--- a/FS/FS/cust_main_county.pm
+++ b/FS/FS/cust_main_county.pm
@@ -176,7 +176,7 @@ with different tax classes.
sub sql_taxclass_sameregion {
my $self = shift;
- my $same_query = 'SELECT taxclass FROM cust_main_county '.
+ my $same_query = 'SELECT DISTINCT taxclass FROM cust_main_county '.
' WHERE taxnum != ? AND country = ?';
my @same_param = ( 'taxnum', 'country' );
foreach my $opt_field (qw( state county )) {
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index bee1b82fb..612ffa0f6 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -3445,7 +3445,13 @@ sub location_sql {
# '?' placeholders in _location_sql_where
my $x = $ornull ? 3 : 2;
- my @bill_param = ( ('city')x3, ('county')x$x, ('state')x$x, 'country' );
+ my @bill_param = (
+ ('district')x3,
+ ('city')x3,
+ ('county')x$x,
+ ('state')x$x,
+ 'country'
+ );
my $main_where;
my @main_param;
@@ -3504,16 +3510,17 @@ sub _location_sql_where {
$ornull = $ornull ? ' OR ? IS NULL ' : '';
- my $or_empty_city = " OR ( ? = '' AND $table.${prefix}city IS NULL ) ";
- my $or_empty_county = " OR ( ? = '' AND $table.${prefix}county IS NULL ) ";
- my $or_empty_state = " OR ( ? = '' AND $table.${prefix}state IS NULL ) ";
+ my $or_empty_city = " OR ( ? = '' AND $table.${prefix}city IS NULL )";
+ my $or_empty_county = " OR ( ? = '' AND $table.${prefix}county IS NULL )";
+ my $or_empty_state = " OR ( ? = '' AND $table.${prefix}state IS NULL )";
# ( $table.${prefix}city = ? $or_empty_city $ornull )
"
- ( $table.${prefix}city = ? OR ? = '' OR CAST(? AS text) IS NULL )
- AND ( $table.${prefix}county = ? $or_empty_county $ornull )
- AND ( $table.${prefix}state = ? $or_empty_state $ornull )
- AND $table.${prefix}country = ?
+ ( $table.${prefix}district = ? OR ? = '' OR CAST(? AS text) IS NULL )
+ AND ( $table.${prefix}city = ? OR ? = '' OR CAST(? AS text) IS NULL )
+ AND ( $table.${prefix}county = ? $or_empty_county $ornull )
+ AND ( $table.${prefix}state = ? $or_empty_state $ornull )
+ AND $table.${prefix}country = ?
";
}