From 1c2774bbe1aefb37fb69c8643443c02a650282f8 Mon Sep 17 00:00:00 2001
From: Mark Wells <mark@freeside.biz>
Date: Sat, 31 Jan 2015 16:29:38 -0800
Subject: [PATCH] discounts + quotations, #33099

---
 FS/FS/quotation_pkg.pm          | 16 ++++++++++++++--
 FS/FS/quotation_pkg_discount.pm | 13 +++++++++++++
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/FS/FS/quotation_pkg.pm b/FS/FS/quotation_pkg.pm
index 28677d0dc..914e1ce4e 100644
--- a/FS/FS/quotation_pkg.pm
+++ b/FS/FS/quotation_pkg.pm
@@ -2,7 +2,7 @@ package FS::quotation_pkg;
 
 use strict;
 use base qw( FS::TemplateItem_Mixin FS::Record );
-use FS::Record qw( qsearchs dbh ); #qsearch
+use FS::Record qw( qsearch qsearchs dbh );
 use FS::part_pkg;
 use FS::cust_location;
 use FS::quotation;
@@ -227,7 +227,7 @@ sub estimate {
   if ( $self->waive_setup eq 'Y' || $self->{'_NO_SETUP_KLUDGE'} ) {
     $unitsetup = '0.00';
   } else {
-    $unitsetup = $part_pkg->base_setup;
+    $unitsetup = $part_pkg->option('setup_fee',1) || '0.00'; # XXX 3.x only
   }
   if ( $self->{'_NO_RECUR_KLUDGE'} ) {
     $unitrecur = '0.00';
@@ -414,6 +414,18 @@ sub cust_main {
   $quotation->cust_main;
 }
 
+#stub for 3.x
+
+sub quotation {
+  my $self = shift;
+  FS::quotation->by_key($self->quotationnum);
+}
+
+sub quotation_pkg_discount {
+  my $self = shift;
+  qsearch('quotation_pkg_discount', { quotationpkgnum => $self->quotationpkgnum });
+}
+
 =back
 
 =head1 BUGS
diff --git a/FS/FS/quotation_pkg_discount.pm b/FS/FS/quotation_pkg_discount.pm
index 15b1bfeb8..24cb204a5 100644
--- a/FS/FS/quotation_pkg_discount.pm
+++ b/FS/FS/quotation_pkg_discount.pm
@@ -3,6 +3,8 @@ package FS::quotation_pkg_discount;
 use strict;
 use base qw( FS::Record );
 use FS::Record qw( qsearch qsearchs );
+use FS::quotation_pkg;
+use FS::discount;
 use FS::Maketext 'mt';
 
 =head1 NAME
@@ -161,6 +163,17 @@ sub description {
   return $desc;
 }
 
+#stub for 3.x
+sub quotation_pkg {
+  my $self = shift;
+  FS::quotation_pkg->by_key($self->quotationpkgnum);
+}
+
+sub discount {
+  my $self = shift;
+  FS::discount->by_key($self->discountnum);
+}
+
 =head1 BUGS
 
 =head1 SEE ALSO
-- 
2.20.1