summaryrefslogtreecommitdiff
path: root/FS/FS/quotation.pm
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2015-02-05 16:17:55 -0800
committerMark Wells <mark@freeside.biz>2015-02-05 16:18:03 -0800
commit7bc49d6e6a03b181ca2392d69e5f717e54d2f907 (patch)
tree19982fce80130d44aad8d17f99e94b4922093836 /FS/FS/quotation.pm
parent795a733714d398d4a3d427de1448b7daaf92399d (diff)
fix creation of custom discounts on quotations, and ordering of discounted quoted packages, #33099
Diffstat (limited to 'FS/FS/quotation.pm')
-rw-r--r--FS/FS/quotation.pm26
1 files changed, 17 insertions, 9 deletions
diff --git a/FS/FS/quotation.pm b/FS/FS/quotation.pm
index 38e7318..9cef3c1 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 );
}