X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fquotation.pm;h=9cef3c19146433716a9a2759f4232e5166a7d9a0;hb=4f0250a76508176cdf5336c199c883a3912f5274;hp=774495a978fb6821da4623e6b858a6c835a5e449;hpb=2e4fa975e054554beac71883436b143267d7aa12;p=freeside.git diff --git a/FS/FS/quotation.pm b/FS/FS/quotation.pm index 774495a97..9cef3c191 100644 --- a/FS/FS/quotation.pm +++ b/FS/FS/quotation.pm @@ -183,10 +183,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_name', $self->cust_or_prospect->agentnum ) ? - $conf->config('invoice_from_name', $self->cust_or_prospect->agentnum ) . ' <' . - $conf->config('invoice_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, @@ -344,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 ; + 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); + } - $self->cust_main->order_pkgs( \%cust_pkg ); + $all_cust_pkg{$cust_pkg} = []; # no services + } + + $self->cust_main->order_pkgs( \%all_cust_pkg ); } @@ -634,6 +639,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