X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=FS%2FFS%2Fquotation.pm;h=0350047a2d2a9c772620e0ea6fdfa3b7247a29c4;hb=c6df7ad114570d49e51ef1f806b83bb7e1a1bca8;hp=1c9d2c4a160f6bb7af412c69dbca83db6bebd723;hpb=4792471dbc3eb9e05f03bbff17b100ea89486d07;p=freeside.git diff --git a/FS/FS/quotation.pm b/FS/FS/quotation.pm index 1c9d2c4a1..0350047a2 100644 --- a/FS/FS/quotation.pm +++ b/FS/FS/quotation.pm @@ -356,15 +356,23 @@ If there is an error, returns an error message, otherwise returns false. sub order { my $self = shift; - tie my %cust_pkg, 'Tie::RefHash', - map { FS::cust_pkg->new({ pkgpart => $_->pkgpart, - quantity => $_->quantity, - }) - => [] #services - } - $self->quotation_pkg ; - - $self->cust_main->order_pkgs( \%cust_pkg ); + tie my %all_cust_pkg, 'Tie::RefHash'; + foreach my $quotation_pkg ($self->quotation_pkg) { + my $cust_pkg = FS::cust_pkg->new; + foreach (qw(pkgpart locationnum start_date contract_end quantity waive_setup)) { + $cust_pkg->set( $_, $quotation_pkg->get($_) ); + } + + # currently only one discount each + my ($pkg_discount) = $quotation_pkg->quotation_pkg_discount; + if ( $pkg_discount ) { + $cust_pkg->set('discountnum', $pkg_discount->discountnum); + } + + $all_cust_pkg{$cust_pkg} = []; # no services + } + + $self->cust_main->order_pkgs( \%all_cust_pkg ); }