summaryrefslogtreecommitdiff
path: root/bin/cust_main-find_bogus_geocode
blob: 04a38a9c48fd52d2f06fbd1997acb7653d539fb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/perl -w

use strict;
use FS::UID qw(adminsuidsetup);
use FS::Record qw( qsearch );
use FS::cust_main;

my $user = shift or die "usage: cust_main-find_bogus_geocode username\n";
adminsuidsetup $user;

my @cust_main = qsearch({
  'table' => 'cust_main',
  'extra_sql' => 'WHERE geocode IS NOT NULL',
});

foreach my $cust_main ( @cust_main ) {

  my $db_geocode = $cust_main->geocode;

  $cust_main->set('geocode', '');

  my $calc_geocode = $cust_main->geocode('cch');

  next unless $calc_geocode;

  my $cust = $cust_main->custnum.': '. $cust_main->name. "\n";

  if ( $db_geocode eq $calc_geocode ) {
    warn "unnecessary geocode override for $cust";
  } else {
    warn "bogus geocode override $db_geocode overrides $calc_geocode for $cust";
  }

}

1;