[freeside-commits] branch master updated. a3c90ed7984e1c0ef73cb969183597545113221d

Mark Wells mark at 420.am
Tue Mar 10 12:40:09 PDT 2015


The branch, master has been updated
       via  a3c90ed7984e1c0ef73cb969183597545113221d (commit)
      from  22013d43001ca65572904a5a1484f6906727d430 (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 a3c90ed7984e1c0ef73cb969183597545113221d
Author: Mark Wells <mark at freeside.biz>
Date:   Tue Mar 10 12:40:05 2015 -0700

    set a default location for quotation_pkg records, #32340

diff --git a/FS/FS/Upgrade.pm b/FS/FS/Upgrade.pm
index 6333a83..d4ba7b8 100644
--- a/FS/FS/Upgrade.pm
+++ b/FS/FS/Upgrade.pm
@@ -430,6 +430,9 @@ sub upgrade_data {
     #populate state FIPS codes if not already done
     'state' => [],
 
+    #set default locations on quoted packages
+    'quotation_pkg' => [],
+
     #populate tax statuses
     'tax_status' => [],
   ;
diff --git a/FS/FS/quotation_pkg.pm b/FS/FS/quotation_pkg.pm
index 1c4766e..dae459e 100644
--- a/FS/FS/quotation_pkg.pm
+++ b/FS/FS/quotation_pkg.pm
@@ -193,6 +193,16 @@ sub check {
     || $self->ut_enum('waive_setup', [ '', 'Y'] )
   ;
 
+  if ($self->locationnum eq '') {
+    # use the customer default
+    my $quotation = $self->quotation;
+    if ($quotation->custnum) {
+      $self->set('locationnum', $quotation->cust_main->ship_locationnum);
+    } elsif ($quotation->prospectnum) {
+      $self->set('locationnum', $quotation->prospect_main->locationnum);
+    } # else the quotation is invalid
+  }
+
   return $error if $error;
 
   $self->SUPER::check;
@@ -458,6 +468,24 @@ sub prospect_main {
   $quotation->prospect_main;
 }
 
+
+sub _upgrade_data {
+  my $class = shift;
+  my @quotation_pkg_without_location =
+    qsearch( 'quotation_pkg', { locationnum => '' } );
+  if (@quotation_pkg_without_location) {
+    warn "setting default location on quotation_pkg records\n";
+    foreach my $quotation_pkg (@quotation_pkg_without_location) {
+      # check() will fix this
+      my $error = $quotation_pkg->replace;
+      if ($error) {
+        die "quotation #".$quotation_pkg->quotationnum.": $error\n";
+      }
+    }
+  }
+  '';
+}
+
 =back
 
 =head1 BUGS

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

Summary of changes:
 FS/FS/Upgrade.pm       |    3 +++
 FS/FS/quotation_pkg.pm |   28 ++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)




More information about the freeside-commits mailing list