[freeside-commits] branch FREESIDE_3_BRANCH updated. ada72090e5e5c97b81388f7591e9c20a54a293ab
Mark Wells
mark at 420.am
Wed Dec 18 17:12:53 PST 2013
The branch, FREESIDE_3_BRANCH has been updated
via ada72090e5e5c97b81388f7591e9c20a54a293ab (commit)
from ed69bcfeef7bd66fca09e5e5c8056abee0060126 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit ada72090e5e5c97b81388f7591e9c20a54a293ab
Author: Mark Wells <mark at freeside.biz>
Date: Wed Dec 18 17:12:21 2013 -0800
Melissa Data address standardization, #25557
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 2d79909..268b603 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -4232,6 +4232,7 @@ and customer address. Include units.',
'usps' => 'U.S. Postal Service',
'ezlocate' => 'EZLocate',
'tomtom' => 'TomTom',
+ 'melissa' => 'Melissa WebSmart',
],
},
@@ -4271,6 +4272,20 @@ and customer address. Include units.',
},
{
+ 'key' => 'melissa-userid',
+ 'section' => 'UI', # it's really not...
+ 'description' => 'User ID for Melissa WebSmart service. See <a href="http://www.melissadata.com/">the Melissa website</a> for access and pricing.',
+ 'type' => 'text',
+ },
+
+ {
+ 'key' => 'melissa-enable_geocoding',
+ 'section' => 'UI',
+ 'description' => 'Use the Melissa service for census tract and coordinate lookups. Enable this only if your subscription includes geocoding access.',
+ 'type' => 'checkbox',
+ },
+
+ {
'key' => 'cust_main-auto_standardize_address',
'section' => 'UI',
'description' => 'When using USPS web tools, automatically standardize the address without asking.',
diff --git a/FS/FS/Misc/Geo.pm b/FS/FS/Misc/Geo.pm
index aa75564..eb861f3 100644
--- a/FS/FS/Misc/Geo.pm
+++ b/FS/FS/Misc/Geo.pm
@@ -652,6 +652,57 @@ sub subloc_address2 {
($subloc, $addr2);
}
+sub standardize_melissa {
+ my $class = shift;
+ my $location = shift;
+
+ local $@;
+ eval "use Geo::Melissa::WebSmart";
+ die $@ if $@;
+
+ my $id = $conf->config('melissa-userid')
+ or die "no melissa-userid configured\n";
+ my $geocode = $conf->exists('melissa-enable_geocoding') ? 1 : 0;
+
+ my $request = {
+ id => $id,
+ a1 => $location->{address1},
+ a2 => $location->{address2},
+ city => $location->{city},
+ state => $location->{state},
+ ctry => $location->{country},
+ zip => $location->{zip},
+ geocode => $geocode,
+ };
+ my $result = Geo::Melissa::WebSmart->query($request);
+ if ( $result->code =~ /AS01/ ) { # always present on success
+ my $addr = $result->address;
+ warn Dumper $addr if $DEBUG > 1;
+ my $out = {
+ address1 => $addr->{Address1},
+ address2 => $addr->{Address2},
+ city => $addr->{City}->{Name},
+ state => $addr->{State}->{Abbreviation},
+ country => $addr->{Country}->{Abbreviation},
+ zip => $addr->{Zip},
+ latitude => $addr->{Latitude},
+ longitude => $addr->{Longitude},
+ addr_clean => 'Y',
+ };
+ if ( $addr->{Census}->{Tract} ) {
+ my $censustract = $addr->{County}->{Fips} . $addr->{Census}->{Tract};
+ # insert decimal point two digits from the end
+ $censustract =~ s/(\d\d)$/\.$1/;
+ $out->{censustract} = $censustract;
+ $out->{censusyear} = $conf->config('census_year');
+ }
+ # we could do a lot more nuanced reporting of the warning/status codes,
+ # but the UI doesn't support that yet.
+ return $out;
+ } else {
+ die $result->status_message;
+ }
+}
=back
-----------------------------------------------------------------------
Summary of changes:
FS/FS/Conf.pm | 15 +++++++++++++++
FS/FS/Misc/Geo.pm | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+), 0 deletions(-)
More information about the freeside-commits
mailing list