X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fquotation_pkg.pm;h=79cce80fa959ed7112c7a60667722259aaa99f9e;hb=7ad62cea1758b8f2e4f0e0d4d8bab36a864b5938;hp=efff9683fe63885ac4790cbc018d789b87b852e4;hpb=3d0a1bb06b895c5be6e3f0517d355442a6b1e125;p=freeside.git diff --git a/FS/FS/quotation_pkg.pm b/FS/FS/quotation_pkg.pm index efff9683f..79cce80fa 100644 --- a/FS/FS/quotation_pkg.pm +++ b/FS/FS/quotation_pkg.pm @@ -1,11 +1,9 @@ package FS::quotation_pkg; +use base qw( FS::TemplateItem_Mixin FS::Record ); use strict; -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 @@ -130,6 +128,8 @@ sub check { $self->SUPER::check; } +#it looks redundant with a v4.x+ auto-generated method, but need to override +# FS::TemplateItem_Mixin's version sub part_pkg { my $self = shift; qsearchs('part_pkg', { 'pkgpart' => $self->pkgpart } ); @@ -157,13 +157,37 @@ 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 + my $recur = $part_pkg->can('base_recur') ? $part_pkg->base_recur($self) : $part_pkg->option('recur_fee'); #XXX discounts $recur *= $self->quantity if $self->quantity; sprintf('%.2f', $recur); } +=item part_pkg_currency_option OPTIONNAME + +Returns a two item list consisting of the currency of this quotation's customer +or prospect, if any, and a value for the provided option. If the customer or +prospect has a currency, the value is the option value the given name and the +currency (see L). Otherwise, if the customer or +prospect has no currency, is the regular option value for the given name (see +L). + +=cut + +#false laziness w/cust_pkg->part_pkg_currency_option +sub part_pkg_currency_option { + my( $self, $optionname ) = @_; + my $part_pkg = $self->part_pkg; + my $prospect_or_customer = $self->cust_main || $self->prospect_main; + if ( my $currency = $prospect_or_customer->currency ) { + ($currency, $part_pkg->part_pkg_currency_option($currency, $optionname) ); + } else { + ('', $part_pkg->option($optionname) ); + } +} + + =item cust_bill_pkg_display [ type => TYPE ] =cut @@ -201,6 +225,30 @@ sub cust_bill_pkg_display { } +=item cust_main + +Returns the customer (L object). + +=cut + +sub cust_main { + my $self = shift; + my $quotation = FS::quotation->by_key($self->quotationnum) or return ''; + $quotation->cust_main; +} + +=item prospect_main + +Returns the prospect (L object). + +=cut + +sub prospect_main { + my $self = shift; + my $quotation = FS::quotation->by_key($self->quotationnum) or return ''; + $quotation->prospect_main; +} + =back =head1 BUGS