[freeside-commits] branch master updated. 0692ff47a2eac65616bf24104a51e558506f1b8f
Ivan
ivan at 420.am
Tue Mar 25 12:59:46 PDT 2014
The branch, master has been updated
via 0692ff47a2eac65616bf24104a51e558506f1b8f (commit)
from 9979b45f11a865efaa04f6938207b1243d042831 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 0692ff47a2eac65616bf24104a51e558506f1b8f
Author: Ivan Kohler <ivan at freeside.biz>
Date: Tue Mar 25 12:59:42 2014 -0700
fix quotations vs. currency_fixed price plan, RT#26810, RT#21565
diff --git a/FS/FS/part_pkg/currency_fixed.pm b/FS/FS/part_pkg/currency_fixed.pm
index bbd95e8..41d7a65 100644
--- a/FS/FS/part_pkg/currency_fixed.pm
+++ b/FS/FS/part_pkg/currency_fixed.pm
@@ -54,9 +54,10 @@ sub calc_setup {
use FS::Conf;
sub calc_currency_option {
- my($self, $optionname, $cust_pkg, $sdate, $details, $param) = @_;
+ my($self, $optionname, $cust_or_quotation_pkg, $sdate, $details, $param) = @_;
- my($currency, $amount) = $cust_pkg->part_pkg_currency_option($optionname);
+ my($currency, $amount) =
+ $cust_or_quotation_pkg->part_pkg_currency_option($optionname);
return sprintf('%.2f', $amount ) unless $currency;
$param->{'billed_currency'} = $currency;
@@ -73,9 +74,10 @@ sub calc_currency_option {
}
sub base_recur {
- my( $self, $cust_pkg, $sdate, $details, $param ) = @_;
- $param ||= {};
- $self->calc_currency_option('recur_fee', $cust_pkg, $sdate, $details, $param);
+ my( $self, $cust_or_quotation_pkg, $sdate, $details, $param ) = @_;
+ $self->calc_currency_option(
+ 'recur_fee', $cust_or_quotation_pkg, $sdate, $details, $param || {}
+ );
}
sub can_discount { 0; } #can't discount yet (percentage would work, but amount?)
diff --git a/FS/FS/quotation_pkg.pm b/FS/FS/quotation_pkg.pm
index c98e0f9..79cce80 100644
--- a/FS/FS/quotation_pkg.pm
+++ b/FS/FS/quotation_pkg.pm
@@ -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<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
@@ -213,6 +237,18 @@ sub cust_main {
$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;
+}
+
=back
=head1 BUGS
-----------------------------------------------------------------------
Summary of changes:
FS/FS/part_pkg/currency_fixed.pm | 12 +++++++-----
FS/FS/quotation_pkg.pm | 38 +++++++++++++++++++++++++++++++++++++-
2 files changed, 44 insertions(+), 6 deletions(-)
More information about the freeside-commits
mailing list