X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_location.pm;h=f38e8efcd01db75d7d23d7479c3d443af3e5f0ce;hb=b7f8a7cfd566881a6d89117d17e391ceb58097d4;hp=7f4aa9a79faf729dbd0a74ae0a4b15c42cec234b;hpb=9aee669886202be7035e6c6049fc71bc99dd3013;p=freeside.git diff --git a/FS/FS/cust_location.pm b/FS/FS/cust_location.pm index 7f4aa9a79..f38e8efcd 100644 --- a/FS/FS/cust_location.pm +++ b/FS/FS/cust_location.pm @@ -5,7 +5,6 @@ use strict; use vars qw( $import $DEBUG $conf $label_prefix ); use Data::Dumper; use Date::Format qw( time2str ); -use Locale::Country; use FS::UID qw( dbh driver_name ); use FS::Record qw( qsearch qsearchs ); use FS::Conf; @@ -250,20 +249,22 @@ sub insert { # cust_location exports #my $export_args = $options{'export_args'} || []; - my @part_export = - map qsearch( 'part_export', {exportnum=>$_} ), - $conf->config('cust_location-exports'); #, $agentnum - - foreach my $part_export ( @part_export ) { - my $error = $part_export->export_insert($self); #, @$export_args); - if ( $error ) { - $dbh->rollback if $oldAutoCommit; - return "exporting to ". $part_export->exporttype. - " (transaction rolled back): $error"; + # don't export custnum_pending cases, let follow-up replace handle that + if ($self->custnum || $self->prospectnum) { + my @part_export = + map qsearch( 'part_export', {exportnum=>$_} ), + $conf->config('cust_location-exports'); #, $agentnum + + foreach my $part_export ( @part_export ) { + my $error = $part_export->export_insert($self); #, @$export_args); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "exporting to ". $part_export->exporttype. + " (transaction rolled back): $error"; + } } } - $dbh->commit or die $dbh->errstr if $oldAutoCommit; ''; } @@ -287,10 +288,15 @@ sub replace { warn "Warning: passed city to replace when cust_main-no_city_in_address is configured" if $conf->exists('cust_main-no_city_in_address') && $self->get('city'); - # the following fields are immutable - foreach (qw(address1 address2 city state zip country)) { - if ( $self->$_ ne $old->$_ ) { - return "can't change cust_location field $_"; + # the following fields are immutable if this is a customer location. if + # it's a prospect location, then there are no active packages, no billing + # history, no taxes, and in general no reason to keep the old location + # around. + if ( $self->custnum ) { + foreach (qw(address1 address2 city state zip country)) { + if ( $self->$_ ne $old->$_ ) { + return "can't change cust_location field $_"; + } } } @@ -307,20 +313,22 @@ sub replace { # cust_location exports #my $export_args = $options{'export_args'} || []; - my @part_export = - map qsearch( 'part_export', {exportnum=>$_} ), - $conf->config('cust_location-exports'); #, $agentnum - - foreach my $part_export ( @part_export ) { - my $error = $part_export->export_replace($self, $old); #, @$export_args); - if ( $error ) { - $dbh->rollback if $oldAutoCommit; - return "exporting to ". $part_export->exporttype. - " (transaction rolled back): $error"; + # don't export custnum_pending cases, let follow-up replace handle that + if ($self->custnum || $self->prospectnum) { + my @part_export = + map qsearch( 'part_export', {exportnum=>$_} ), + $conf->config('cust_location-exports'); #, $agentnum + + foreach my $part_export ( @part_export ) { + my $error = $part_export->export_replace($self, $old); #, @$export_args); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "exporting to ". $part_export->exporttype. + " (transaction rolled back): $error"; + } } } - $dbh->commit or die $dbh->errstr if $oldAutoCommit; ''; } @@ -412,14 +420,11 @@ sub check { =item country_full -Returns this locations's full country name +Returns this location's full country name =cut -sub country_full { - my $self = shift; - code2country($self->country); -} +#moved to geocode_Mixin.pm =item line @@ -647,6 +652,11 @@ Prospect object (see L) String used to join location elements +=item no_prefix + +Don't label the default service location as "Default service location". +May become the default at some point. + =back =cut @@ -654,8 +664,9 @@ String used to join location elements sub location_label { my( $self, %opt ) = @_; - my $prefix = $self->label_prefix; + my $prefix = $self->label_prefix(%opt); $prefix .= ($opt{join_string} || ': ') if $prefix; + $prefix = '' if $opt{'no_prefix'}; $prefix . $self->SUPER::location_label(%opt); } @@ -717,7 +728,7 @@ sub label_prefix { $prefix; } -=item county_state_county +=item county_state_country Returns a string consisting of just the county, state and country.