X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_location.pm;h=90400984ce43e8aa683083971124650f7bb0a466;hb=c22d84e565ab16db142395dce2e8621624eff140;hp=9415cc77cad178ad06c3f0b4cb44db227be2a944;hpb=49432ea28e2f6b274d614b8317fc18c423211e4f;p=freeside.git diff --git a/FS/FS/cust_location.pm b/FS/FS/cust_location.pm index 9415cc77c..90400984c 100644 --- a/FS/FS/cust_location.pm +++ b/FS/FS/cust_location.pm @@ -249,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; ''; } @@ -311,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; ''; } @@ -377,10 +381,12 @@ sub check { $self->censustract("$1.$2"); } - if ( $conf->exists('cust_main-require_address2') and - !$self->ship_address2 =~ /\S/ ) { - return "Unit # is required"; - } + #yikes... this is ancient, pre-dates cust_location and will be harder to + # implement now... how do we know this location is a service location from + # here and not a billing? we can't just check locationnums, we might be new :/ + return "Unit # is required" + if $conf->exists('cust_main-require_address2') + && ! $self->address2 =~ /\S/; # tricky...we have to allow for the customer to not be inserted yet return "No prospect or customer!" unless $self->prospectnum @@ -660,7 +666,7 @@ May become the default at some point. 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'}; @@ -716,15 +722,18 @@ sub label_prefix { } elsif ( $label_prefix eq '_location' && $self->locationname ) { $prefix = $self->locationname; - } elsif ( ( $opt{'cust_main'} || $self->custnum ) - && $self->locationnum == $cust_or_prospect->ship_locationnum ) { - $prefix = 'Default service location'; + #} elsif ( ( $opt{'cust_main'} || $self->custnum ) + # && $self->locationnum == $cust_or_prospect->ship_locationnum ) { + # $prefix = 'Default service location'; + #} + } else { + $prefix = ''; } $prefix; } -=item county_state_county +=item county_state_country Returns a string consisting of just the county, state and country.