+sub unitsetup {
+ my $self = shift;
+ return '0.00' if $self->waive_setup eq 'Y' || $self->{'_NO_SETUP_KLUDGE'};
+ my $part_pkg = $self->part_pkg;
+ my $setup = $part_pkg->option('setup_fee');
+
+ #XXX discounts
+ sprintf('%.2f', $setup);
+}
+
+sub unitrecur {
+ 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');
+ #XXX discounts
+ 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<FS::part_pkg_currency>). Otherwise, if the customer or
+prospect has no currency, is the regular option value for the given name (see
+L<FS::part_pkg_option>).
+
+=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
+
+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);
+ return ($self);
+ }
+
+ }
+
+}
+
+=item cust_main
+
+Returns the customer (L<FS::cust_main> 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<FS::prospect_main> object).
+
+=cut
+
+sub prospect_main {
+ my $self = shift;
+ my $quotation = FS::quotation->by_key($self->quotationnum) or return '';
+ $quotation->prospect_main;
+}
+