[freeside-commits] branch FREESIDE_3_BRANCH updated. 4d81504d903cc11cc3637ecc3e6f4af44c59addd
Mark Wells
mark at 420.am
Tue Mar 10 12:40:09 PDT 2015
The branch, FREESIDE_3_BRANCH has been updated
via 4d81504d903cc11cc3637ecc3e6f4af44c59addd (commit)
from 3244e4dcb9d88c728f3bfa1294b3f78cb7a96a20 (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 4d81504d903cc11cc3637ecc3e6f4af44c59addd
Author: Mark Wells <mark at freeside.biz>
Date: Tue Mar 10 12:38:57 2015 -0700
set a default location for quotation_pkg records, #32340
diff --git a/FS/FS/Upgrade.pm b/FS/FS/Upgrade.pm
index 3146222..3694f8a 100644
--- a/FS/FS/Upgrade.pm
+++ b/FS/FS/Upgrade.pm
@@ -406,6 +406,9 @@ sub upgrade_data {
#populate state FIPS codes if not already done
'state' => [],
+
+ #set default locations on quoted packages
+ 'quotation_pkg' => [],
;
\%hash;
diff --git a/FS/FS/quotation_pkg.pm b/FS/FS/quotation_pkg.pm
index 107b271..342e9bb 100644
--- a/FS/FS/quotation_pkg.pm
+++ b/FS/FS/quotation_pkg.pm
@@ -195,6 +195,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;
@@ -444,6 +454,24 @@ sub cust_location {
$self->locationnum ? qsearchs('cust_location', { locationnum => $self->locationnum }) : '';
}
+
+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