diff options
author | Mark Wells <mark@freeside.biz> | 2015-03-10 12:40:05 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2015-03-10 12:40:05 -0700 |
commit | a3c90ed7984e1c0ef73cb969183597545113221d (patch) | |
tree | fc5849db6e4975a45066d71bb655f5722f4e1e3e /FS/FS/quotation_pkg.pm | |
parent | 22013d43001ca65572904a5a1484f6906727d430 (diff) |
set a default location for quotation_pkg records, #32340
Diffstat (limited to 'FS/FS/quotation_pkg.pm')
-rw-r--r-- | FS/FS/quotation_pkg.pm | 28 |
1 files changed, 28 insertions, 0 deletions
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 |