sub initial_data {
my %opt = @_;
+ my $cust_location = FS::cust_location->new({
+ 'address1' => '1234 System Lane',
+ 'city' => 'Systemtown',
+ 'state' => 'CA',
+ 'zip' => '54321',
+ 'country' => 'US',
+ });
+
#tie my %hash, 'Tie::DxHash',
tie my %hash, 'Tie::IxHash',
'refnum' => 1, #XXX
'first' => 'System',
'last' => 'Accounts',
- 'address1' => '1234 System Lane',
- 'city' => 'Systemtown',
- 'state' => 'CA',
- 'zip' => '54321',
- 'country' => 'US',
'payby' => 'COMP',
'payinfo' => 'system', #or something
'paydate' => '1/2037',
+ 'bill_location' => $cust_location,
+ 'ship_location' => $cust_location,
},
],
foreach my $l (qw(bill_location ship_location)) {
my $loc = delete $self->hashref->{$l};
# XXX if we're moving a prospect's locations, do that here
+ if ( !$loc ) {
+ return "$l not set";
+ }
if ( !$loc->locationnum ) {
# warn the location that we're going to insert it with no custnum
return "$error (in $label location)";
}
}
- elsif ( $loc->custnum != $self->custnum or $loc->prospectnum > 0 ) {
- # this shouldn't happen
+ elsif ( ($loc->custnum || 0) > 0 or $loc->prospectnum ) {
+ # then it somehow belongs to another customer--shouldn't happen
$dbh->rollback if $oldAutoCommit;
return "$l belongs to customer ".$loc->custnum;
}
|| $self->ut_textn('stateid')
|| $self->ut_textn('stateid_state')
|| $self->ut_textn('invoice_terms')
- || $self->ut_alphan('geocode')
- || $self->ut_alphan('district')
|| $self->ut_floatn('cdr_termination_percentage')
|| $self->ut_floatn('credit_limit')
|| $self->ut_numbern('billday')
sub cust_location {
my $self = shift;
- qsearch('cust_location', { 'custnum' => $self->custnum } );
+ qsearch('cust_location', { 'custnum' => $self->custnum,
+ 'prospectnum' => '' } );
}
=item cust_contact
use Carp qw(carp);
-$DEBUG = 1;
+$DEBUG = 0;
$me = '[FS::cust_main::Location]';
my $init = 0;
# just in case someone still doesn't have these
if ( !$phone_type{$_}->phonetypenum ) {
$error = $phone_type{$_}->insert;
- die "error creating phone type '$_': $error";
+ die "error creating phone type '$_': $error" if $error;
}
}