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 );
}
}
+=item _items_pkg
+
+Return line item hashes for each package on this quotation. Differs from the
+base L<FS::Template_Mixin> 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