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, $time, $details, $param ) = @_;
44 $self->calc_currency_option('setup_fee', $cust_pkg, $time, $details, $param);
48 my($self, $cust_pkg, $time, $details, $param) = @_;
50 return 0 if $self->prorate_setup($cust_pkg, $time);
52 $self->base_setup($cust_pkg, $time, $details, $param);
56 sub calc_currency_option {
57 my($self, $optionname, $cust_or_quotation_pkg, $time, $details, $param) = @_;
59 my($currency, $amount) =
60 $cust_or_quotation_pkg->part_pkg_currency_option($optionname);
61 return sprintf('%.2f', $amount ) unless $currency;
63 $param->{'billed_currency'} = $currency;
64 $param->{'billed_amount'} = $amount;
66 my $currency_exchange = qsearchs('currency_exchange', {
67 'from_currency' => $currency,
68 'to_currency' => ( FS::Conf->new->config('currency') || 'USD' ),
69 }) or die "No exchange rate from $currency\n";
71 #XXX do we want the rounding here to work differently?
72 #my $recognized_amount =
73 sprintf('%.2f', $amount * $currency_exchange->rate);
77 my( $self, $cust_or_quotation_pkg, $sdate, $details, $param ) = @_;
78 $self->calc_currency_option(
79 'recur_fee', $cust_or_quotation_pkg, $sdate, $details, $param || {}
83 sub can_discount { 0; } #can't discount yet (percentage would work, but amount?)
87 #my($cust_pkg, $sdate, $details, $param ) = @_;
90 ($cust_pkg->quantity || 1) * $self->calc_recur_Common(@_); #($cust_pkg,$sdate,$details,$param);
96 sub can_currency_exchange { 1; }
98 sub can_usageprice { 0; }