[freeside-commits] branch master updated. b1f580c37e3da920fd6669e7431fd8cb06810f35

Mark Wells mark at 420.am
Thu May 31 14:49:02 PDT 2012


The branch, master has been updated
       via  b1f580c37e3da920fd6669e7431fd8cb06810f35 (commit)
      from  dda70549e974d4b559f9d5a117948b931813c7d1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b1f580c37e3da920fd6669e7431fd8cb06810f35
Author: Mark Wells <mark at freeside.biz>
Date:   Thu May 31 14:48:51 2012 -0700

    fix some issues with upgrade/initial setup, #940

diff --git a/FS/FS/Setup.pm b/FS/FS/Setup.pm
index e2c5a5a..e27b66f 100644
--- a/FS/FS/Setup.pm
+++ b/FS/FS/Setup.pm
@@ -209,6 +209,14 @@ sub populate_initial_data {
 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', 
 
@@ -351,14 +359,11 @@ sub initial_data {
         '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,
       },
     ],
 
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 62cb837..d4ddacc 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -400,6 +400,9 @@ sub insert {
   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
@@ -413,8 +416,8 @@ sub insert {
         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;
     }
@@ -1783,8 +1786,6 @@ sub check {
     || $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')
@@ -2123,7 +2124,8 @@ Returns all locations (see L<FS::cust_location>) for this customer.
 
 sub cust_location {
   my $self = shift;
-  qsearch('cust_location', { 'custnum' => $self->custnum } );
+  qsearch('cust_location', { 'custnum' => $self->custnum,
+                             'prospectnum' => '' } );
 }
 
 =item cust_contact
diff --git a/FS/FS/cust_main/Location.pm b/FS/FS/cust_main/Location.pm
index d1d6d67..8e30bb6 100644
--- a/FS/FS/cust_main/Location.pm
+++ b/FS/FS/cust_main/Location.pm
@@ -8,7 +8,7 @@ use FS::cust_location;
 
 use Carp qw(carp);
 
-$DEBUG = 1;
+$DEBUG = 0;
 $me = '[FS::cust_main::Location]';
 
 my $init = 0;
@@ -146,7 +146,7 @@ sub _upgrade_data {
     # 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;
     }
   }
 

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Setup.pm              |   15 ++++++++++-----
 FS/FS/cust_main.pm          |   12 +++++++-----
 FS/FS/cust_main/Location.pm |    4 ++--
 3 files changed, 19 insertions(+), 12 deletions(-)




More information about the freeside-commits mailing list