X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fgeocode_Mixin.pm;h=611b9e5c1d54dafc0e1a9b5b4296589c59c2052f;hb=80c2d997c5c983344c530ecbb46f94f1c299b35f;hp=29491db61f896d8ef8aa33145d705f6b89906901;hpb=fb4ab1073f0d15d660c6cdc4e07afebf68ef3924;p=freeside.git diff --git a/FS/FS/geocode_Mixin.pm b/FS/FS/geocode_Mixin.pm index 29491db61..611b9e5c1 100644 --- a/FS/FS/geocode_Mixin.pm +++ b/FS/FS/geocode_Mixin.pm @@ -186,12 +186,17 @@ sub geocode { my $geocode = $self->get('geocode'); #XXX only one data_vendor for geocode return $geocode if $geocode; - my $prefix = - ( FS::Conf->new->exists('tax-ship_address') && $self->has_ship_address ) - ? 'ship_' - : ''; + if ( $self->isa('FS::cust_main') ) { + warn "WARNING: FS::cust_main->geocode deprecated"; + + # do the best we can + my $m = FS::Conf->new->exists('tax-ship_address') ? 'ship_location' + : 'bill_location'; + my $location = $self->$m or return ''; + return $location->geocode($data_vendor); + } - my($zip,$plus4) = split /-/, $self->get("${prefix}zip") + my($zip,$plus4) = split /-/, $self->get('zip') if $self->country eq 'US'; $zip ||= ''; @@ -212,7 +217,7 @@ sub geocode { if scalar(@cust_tax_location); warn "WARNING: customer ". $self->custnum. - ": multiple locations for zip ". $self->get("${prefix}zip"). + ": multiple locations for zip ". $self->get("zip"). "; using arbitrary geocode $geocode\n" if scalar(@cust_tax_location) > 1; @@ -231,6 +236,8 @@ sub process_district_update { my $class = shift; my $id = shift; + local $DEBUG = 1; + eval "use FS::Misc::Geo qw(get_district); use FS::Conf; use $class;"; die $@ if $@; die "$class has no location data" if !$class->can('location_hash'); @@ -250,6 +257,8 @@ sub process_district_update { my %hash = map { $_ => $tax_info->{$_} } qw( district city county state country ); + $hash{'taxname'} = ''; + my $old = qsearchs('cust_main_county', \%hash); if ( $old ) { my $new = new FS::cust_main_county { $old->hash, %$tax_info };