+sub _upgrade_data {
+ my $class = shift;
+
+ # are we going to need to update tax districts?
+ my $use_districts = $conf->config('tax_district_method') ? 1 : 0;
+
+ # trim whitespace on records that need it
+ local $allow_location_edit = 1;
+ foreach my $field (@essential) {
+ next if $field eq 'custnum';
+ next if $field eq 'disabled';
+ foreach my $location (qsearch({
+ table => 'cust_location',
+ extra_sql => " WHERE disabled IS NULL AND ($field LIKE ' %' OR $field LIKE '% ')"
+ })) {
+ my $error = $location->replace;
+ die "$error (fixing whitespace in $field, locationnum ".$location->locationnum.')'
+ if $error;
+
+ if (
+ $use_districts
+ && !$location->district
+ && lc $location->state eq 'wa'
+ ) {
+ my $queue = new FS::queue {
+ 'job' => 'FS::geocode_Mixin::process_district_update'
+ };
+ $error = $queue->insert( 'FS::cust_location' => $location->locationnum );
+ die $error if $error;
+ }
+ } # foreach $location
+ } # foreach $field
+ '';
+}
+