X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fquotation.pm;h=9cef3c19146433716a9a2759f4232e5166a7d9a0;hb=dba9a62fa32e07d4461e9c081201f69c0cda7015;hp=38e73188958400e76156471a0ad10d32a77c0f39;hpb=f6abf4cd6d8e7a0121124e9394b5f28f5bc4daa5;p=freeside.git diff --git a/FS/FS/quotation.pm b/FS/FS/quotation.pm index 38e731889..9cef3c191 100644 --- a/FS/FS/quotation.pm +++ b/FS/FS/quotation.pm @@ -341,15 +341,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 ); }