summaryrefslogtreecommitdiff
path: root/FS/FS/quotation_pkg.pm
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2013-03-11 02:13:24 -0700
committerIvan Kohler <ivan@freeside.biz>2013-03-11 02:13:24 -0700
commit53a1130923c4905b267239c369949aadde657c7c (patch)
tree15566fd5de27866887ae4dfa05c4f37ae7b4bd62 /FS/FS/quotation_pkg.pm
parenta2ff7564f36a5db81bdba053ff70017b8f438904 (diff)
fix quotations, RT#21103
Diffstat (limited to 'FS/FS/quotation_pkg.pm')
-rw-r--r--FS/FS/quotation_pkg.pm52
1 files changed, 47 insertions, 5 deletions
diff --git a/FS/FS/quotation_pkg.pm b/FS/FS/quotation_pkg.pm
index 47045cd..b5823f4 100644
--- a/FS/FS/quotation_pkg.pm
+++ b/FS/FS/quotation_pkg.pm
@@ -5,6 +5,7 @@ use base qw( FS::TemplateItem_Mixin FS::Record );
use FS::Record qw( qsearchs ); #qsearch
use FS::part_pkg;
use FS::cust_location;
+use FS::quotation;
use FS::quotation_pkg_discount; #so its loaded when TemplateItem_Mixin needs it
=head1 NAME
@@ -82,8 +83,11 @@ points to. You can ask the object for a copy with the I<hash> method.
sub table { 'quotation_pkg'; }
sub display_table { 'quotation_pkg'; }
-sub display_table_orderby { 'quotationpkgnum'; } # something else?
- # (for invoice display order)
+
+#forget it, just overriding cust_bill_pkg_display entirely
+#sub display_table_orderby { 'quotationpkgnum'; } # something else?
+# # (for invoice display order)
+
sub discount_table { 'quotation_pkg_discount'; }
=item insert
@@ -113,8 +117,9 @@ sub check {
my $error =
$self->ut_numbern('quotationpkgnum')
- || $self->ut_foreign_key('pkgpart', 'part_pkg', 'pkgpart' )
- || $self->ut_foreign_keyn('locationnum', 'cust_location', 'locationnum' )
+ || $self->ut_foreign_key( 'quotationnum', 'quotation', 'quotationnum' )
+ || $self->ut_foreign_key( 'pkgpart', 'part_pkg', 'pkgpart' )
+ || $self->ut_foreign_keyn( 'locationnum', 'cust_location', 'locationnum' )
|| $self->ut_numbern('start_date')
|| $self->ut_numbern('contract_end')
|| $self->ut_numbern('quantity')
@@ -137,7 +142,7 @@ sub desc {
sub setup {
my $self = shift;
- return '0.00' if $self->waive_setup eq 'Y';
+ return '0.00' if $self->waive_setup eq 'Y' || $self->{'_NO_SETUP_KLUDGE'};
my $part_pkg = $self->part_pkg;
#my $setup = $part_pkg->can('base_setup') ? $part_pkg->base_setup
# : $part_pkg->option('setup_fee');
@@ -150,6 +155,7 @@ sub setup {
sub recur {
my $self = shift;
+ return '0.00' if $self->{'_NO_RECUR_KLUDGE'};
my $part_pkg = $self->part_pkg;
my $recur = $part_pkg->can('base_recur') ? $part_pkg->base_recur
: $part_pkg->option('recur_fee');
@@ -158,6 +164,42 @@ sub recur {
sprintf('%.2f', $recur);
}
+=item cust_bill_pkg_display [ type => TYPE ]
+
+=cut
+
+sub cust_bill_pkg_display {
+ my ( $self, %opt ) = @_;
+
+ my $type = $opt{type} if exists $opt{type};
+ return () if $type eq 'U'; #quotations don't have usage
+
+ if ( $self->get('display') ) {
+ return ( grep { defined($type) ? ($type eq $_->type) : 1 }
+ @{ $self->get('display') }
+ );
+ } else {
+
+ #??
+ my $setup = $self->new($self->hashref);
+ $setup->{'_NO_RECUR_KLUDGE'} = 1;
+ $setup->{'type'} = 'S';
+ my $recur = $self->new($self->hashref);
+ $recur->{'_NO_SETUP_KLUDGE'} = 1;
+ $recur->{'type'} = 'R';
+
+ if ( $type eq 'S' ) {
+ return ($setup);
+ } elsif ( $type eq 'R' ) {
+ return ($recur);
+ } else {
+ return ($setup, $recur);
+ }
+
+ }
+
+}
+
=back
=head1 BUGS