1 package FS::part_pkg::currency_fixed;
3 #use base qw( FS::part_pkg::discount_Mixin FS::part_pkg::recur_Common );
4 use base qw( FS::part_pkg::recur_Common );
8 use FS::Record qw(qsearchs); # qsearch qsearchs);
9 use FS::currency_exchange;
12 'name' => 'Per-currency pricing from package definitions',
13 'shortname' => 'Per-currency pricing',
14 'inherit_fields' => [ 'prorate_Mixin', 'global_Mixin' ],
16 'cutoff_day' => { 'name' => 'Billing Day (1 - 28) for prorating or '.
21 'recur_method' => { 'name' => 'Recurring fee method',
23 #'options' => \%recur_method,
25 'select_options' => \%FS::part_pkg::recur_Common::recur_method,
28 'fieldorder' => [qw( recur_method cutoff_day ),
29 FS::part_pkg::prorate_Mixin::fieldorder,
36 my $str = $self->SUPER::price_info;
37 $str .= " (or local currency pricing)" if $str;
42 my($self, $cust_pkg, $sdate, $details, $param ) = @_;
44 $self->calc_currency_option('setup_fee', $cust_pkg, $sdate, $details, $param);
48 my($self, $cust_pkg, $sdate, $details, $param) = @_;
50 return 0 if $self->prorate_setup($cust_pkg, $sdate);
52 $self->base_setup($cust_pkg, $sdate, $details, $param);
56 sub calc_currency_option {
57 my($self, $optionname, $cust_pkg, $sdate, $details, $param) = @_;
59 my($currency, $amount) = $cust_pkg->part_pkg_currency_option($optionname);
60 return sprintf('%.2f', $amount ) unless $currency;
62 $param->{'billed_currency'} = $currency;
63 $param->{'billed_amount'} = $amount;
65 my $currency_exchange = qsearchs('currency_exchange', {
66 'from_currency' => $currency,
67 'to_currency' => ( FS::Conf->new->config('currency') || 'USD' ),
68 }) or die "No exchange rate from $currency\n";
70 #XXX do we want the rounding here to work differently?
71 #my $recognized_amount =
72 sprintf('%.2f', $amount * $currency_exchange->rate);
76 my( $self, $cust_pkg, $sdate, $details, $param ) = @_;
78 $self->calc_currency_option('recur_fee', $cust_pkg, $sdate, $details, $param);
81 sub can_discount { 0; } #can't discount yet (percentage would work, but amount?)
85 #my($cust_pkg, $sdate, $details, $param ) = @_;
88 ($cust_pkg->quantity || 1) * $self->calc_recur_Common(@_); #($cust_pkg,$sdate,$details,$param);
94 sub can_currency_exchange { 1; }