summaryrefslogtreecommitdiff
path: root/FS/FS
diff options
context:
space:
mode:
authorivan <ivan>2009-12-12 21:38:42 +0000
committerivan <ivan>2009-12-12 21:38:42 +0000
commitce1fa204e25ae8605bdb4f3dbfdf9bd1bff1a590 (patch)
tree974b282b982af70b3c50ce24341201ba53c0a283 /FS/FS
parent301007875822fa4a694e34eda561bc5525b836b3 (diff)
reporting with city taxes, RT#6776
Diffstat (limited to 'FS/FS')
-rw-r--r--FS/FS/cust_pkg.pm14
1 files changed, 6 insertions, 8 deletions
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index d75113f6e..7632d9ae5 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -2643,13 +2643,8 @@ sub location_sql {
my $conf = new FS::Conf;
# '?' placeholders in _location_sql_where
- my @bill_param;
- if ( $ornull ) {
- @bill_param = qw( county county state state state country );
- } else {
- @bill_param = qw( county state state country );
- }
- unshift @bill_param, 'county'; # unless $nec;
+ my $x = $ornull ? 3 : 2;
+ my @bill_param = ( ('city')x3, ('county')x$x, ('state')x$x, 'country' );
my $main_where;
my @main_param;
@@ -2708,11 +2703,14 @@ 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 ) ";
+# ( $table.${prefix}city = ? $or_empty_city $ornull )
"
- ( $table.${prefix}county = ? $or_empty_county $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 = ?
";