X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fquotation.pm;h=0350047a2d2a9c772620e0ea6fdfa3b7247a29c4;hb=96a06f1743cf1215a41bd5391d9604a178ad5b54;hp=b3595efcf6ae588ee9389d1f227261b727c73c5d;hpb=1553b7eca477f52824b6b352a0e87df68622411b;p=freeside.git diff --git a/FS/FS/quotation.pm b/FS/FS/quotation.pm index b3595efcf..0350047a2 100644 --- a/FS/FS/quotation.pm +++ b/FS/FS/quotation.pm @@ -198,8 +198,7 @@ sub email { # this is where we set the From: address $from ||= $conf->config('quotation_from', $self->cust_or_prospect->agentnum ) - || $conf->config('invoice_from', $self->cust_or_prospect->agentnum ); - + || $conf->invoice_from_full( $self->cust_or_prospect->agentnum ); $self->SUPER::email( { 'from' => $from, %$opt, @@ -357,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 ; + 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($_) ); + } - $self->cust_main->order_pkgs( \%cust_pkg ); + # 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 ); } @@ -656,6 +663,27 @@ sub search_sql_where { } +=item _items_pkg + +Return line item hashes for each package on this quotation. Differs from the +base L version in that it recalculates each quoted package +first, and doesn't implement the "condensed" option. + +=cut + +sub _items_pkg { + my ($self, %options) = @_; + my @quotation_pkg = $self->quotation_pkg; + foreach (@quotation_pkg) { + my $error = $_->estimate; + die "error calculating estimate for pkgpart " . $_->pkgpart.": $error\n" + if $error; + } + + # run it through the Template_Mixin engine + return $self->_items_cust_bill_pkg(\@quotation_pkg, %options); +} + =back =head1 BUGS