summaryrefslogtreecommitdiff
path: root/FS/FS/part_pkg/currency_fixed.pm
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2013-06-10 23:15:03 -0700
committerIvan Kohler <ivan@freeside.biz>2013-06-10 23:15:03 -0700
commitb7a2175dd9b386441f4ab66869d73083e5e8beb1 (patch)
tree3d96ed11d9ec68a9becd2e5b38548974a7a98e0e /FS/FS/part_pkg/currency_fixed.pm
parente497261817ee2cf3acb5ee3dda3c5906f1c13a4f (diff)
multi-currency, RT#21565
Diffstat (limited to 'FS/FS/part_pkg/currency_fixed.pm')
-rw-r--r--FS/FS/part_pkg/currency_fixed.pm40
1 files changed, 33 insertions, 7 deletions
diff --git a/FS/FS/part_pkg/currency_fixed.pm b/FS/FS/part_pkg/currency_fixed.pm
index bee6c5b..ce71452 100644
--- a/FS/FS/part_pkg/currency_fixed.pm
+++ b/FS/FS/part_pkg/currency_fixed.pm
@@ -5,7 +5,8 @@ use base qw( FS::part_pkg::recur_Common );
use strict;
use vars qw( %info );
-#use FS::Record qw(qsearch qsearchs);
+use FS::Record qw(qsearchs); # qsearch qsearchs);
+use FS::currency_exchange;
%info = (
'name' => 'Per-currency pricing from package definitions',
@@ -26,7 +27,7 @@ use vars qw( %info );
},
'fieldorder' => [qw( recur_method cutoff_day ),
FS::part_pkg::prorate_Mixin::fieldorder,
- )],
+ ],
'weight' => '59',
);
@@ -37,19 +38,44 @@ sub price_info {
$str;
}
-#some false laziness w/recur_Common, could have been better about it.. pry when
-# we do discounting
+sub base_setup {
+ my($self, $cust_pkg, $sdate, $details, $param ) = @_;
+
+ $self->calc_currency_option('setup_fee', $cust_pkg, $sdate, $details, $param);
+}
+
sub calc_setup {
my($self, $cust_pkg, $sdate, $details, $param) = @_;
return 0 if $self->prorate_setup($cust_pkg, $sdate);
- sprintf('%.2f', $cust_pkg->part_pkg_currency_option('setup_fee') );
+ $self->base_setup($cust_pkg, $sdate, $details, $param);
+}
+
+use FS::Conf;
+sub calc_currency_option {
+ my($self, $optionname, $cust_pkg, $sdate, $details, $param) = @_;
+
+ my($currency, $amount) = $cust_pkg->part_pkg_currency_option($optionname);
+ return sprintf('%.2f', $amount ) unless $currency;
+
+ $param->{'billed_currency'} = $currency;
+ $param->{'billed_amount'} = $amount;
+
+ my $currency_exchange = qsearchs('currency_exchange', {
+ 'from_currency' => $currency,
+ 'to_currency' => ( FS::Conf->new->config('currency') || 'USD' ),
+ }) or die "No exchange rate from $currency\n";
+
+ #XXX do we want the rounding here to work differently?
+ #my $recognized_amount =
+ sprintf('%.2f', $amount * $currency_exchange->rate);
}
sub base_recur {
- my( $self, $cust_pkg ) = @_;
- sprintf('%.2f', $cust_pkg->part_pkg_currency_option('recur_fee') );
+ my( $self, $cust_pkg, $sdate, $details, $param ) = @_;
+ $param ||= {};
+ $self->calc_currency_option('recur_fee', $cust_pkg, $sdate, $details, $param);
}
sub can_discount { 0; } #can't discount yet (percentage would work, but amount?)