diff options
author | Jonathan Prykop <jonathan@freeside.biz> | 2016-01-29 20:24:46 -0600 |
---|---|---|
committer | Jonathan Prykop <jonathan@freeside.biz> | 2016-01-29 20:24:46 -0600 |
commit | 9db332d80967969856c5b5fe8b6ac91304734b04 (patch) | |
tree | bf688a2a3dbfa31502de4a11a338712901430559 /FS/FS/quotation.pm | |
parent | 49432ea28e2f6b274d614b8317fc18c423211e4f (diff) |
RT#39831 Quotation extra information for line items
Diffstat (limited to 'FS/FS/quotation.pm')
-rw-r--r-- | FS/FS/quotation.pm | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/FS/FS/quotation.pm b/FS/FS/quotation.pm index c400493..cb3d80b 100644 --- a/FS/FS/quotation.pm +++ b/FS/FS/quotation.pm @@ -399,12 +399,18 @@ as ordered. sub order { my $self = shift; my $pkgnum_map = shift || {}; + my $details_map = {}; tie my %all_cust_pkg, 'Tie::RefHash'; foreach my $quotation_pkg ($self->quotation_pkg) { my $cust_pkg = FS::cust_pkg->new; $pkgnum_map->{ $quotation_pkg->quotationpkgnum } = $cust_pkg; + # details will be copied below, after package is ordered + $details_map->{ $quotation_pkg->quotationpkgnum } = [ + map { $_->copy_on_order ? $_->detail : () } $quotation_pkg->quotation_pkg_detail + ]; + foreach (qw(pkgpart locationnum start_date contract_end quantity waive_setup)) { $cust_pkg->set( $_, $quotation_pkg->get($_) ); } @@ -418,15 +424,45 @@ sub order { $all_cust_pkg{$cust_pkg} = []; # no services } + local $SIG{HUP} = 'IGNORE'; + local $SIG{INT} = 'IGNORE'; + local $SIG{QUIT} = 'IGNORE'; + local $SIG{TERM} = 'IGNORE'; + local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; + + my $oldAutoCommit = $FS::UID::AutoCommit; + local $FS::UID::AutoCommit = 0; + my $dbh = dbh; + my $error = $self->cust_main->order_pkgs( \%all_cust_pkg ); + unless ($error) { + # copy details (copy_on_order filtering handled above) + foreach my $quotationpkgnum (keys %$details_map) { + next unless @{$details_map->{$quotationpkgnum}}; + $error = $pkgnum_map->{$quotationpkgnum}->set_cust_pkg_detail( + 'I', + @{$details_map->{$quotationpkgnum}} + ); + last if $error; + } + } + foreach my $quotationpkgnum (keys %$pkgnum_map) { # convert the objects to just pkgnums my $cust_pkg = $pkgnum_map->{$quotationpkgnum}; $pkgnum_map->{$quotationpkgnum} = $cust_pkg->pkgnum; } - $error; + if ($error) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + + $dbh->commit or die $dbh->errstr if $oldAutoCommit; + ''; #no error + } =item charge |