summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/Upgrade.pm3
-rw-r--r--FS/FS/quotation_pkg.pm28
2 files changed, 31 insertions, 0 deletions
diff --git a/FS/FS/Upgrade.pm b/FS/FS/Upgrade.pm
index 6333a834e..d4ba7b828 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 1c4766e79..dae459e29 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