use Koha::Cache;
use Koha::Authority::Types;
+use Koha::Acquisition::Currencies;
use vars qw($VERSION @ISA @EXPORT);
my ( $price ) = @_;
return unless ( $price =~ m/\d/ ); ## No digits means no price.
# Look for the currency symbol and the normalized code of the active currency, if it's there,
- my $active_currency = C4::Budgets->GetCurrency();
- my $symbol = $active_currency->{'symbol'};
- my $isocode = $active_currency->{'isocode'};
- $isocode = $active_currency->{'currency'} unless defined $isocode;
+ my $active_currency = Koha::Acquisition::Currencies->get_active;
+ my $symbol = $active_currency->symbol;
+ my $isocode = $active_currency->isocode;
+ $isocode = $active_currency->currency unless defined $isocode;
my $localprice;
if ( $symbol ) {
my @matches =($price=~ /
&ModBudgetPlan
- &GetCurrency
- &GetCurrencies
&ConvertCurrency
&GetBudgetsPlanCell
# -------------------------------------------------------------------
-=head2 GetCurrencies
-
- @currencies = &GetCurrencies;
-
-Returns the list of all known currencies.
-
-C<$currencies> is a array; its elements are references-to-hash, whose
-keys are the fields from the currency table in the Koha database.
-
-=cut
-
-sub GetCurrencies {
- my $dbh = C4::Context->dbh;
- my $query = "
- SELECT *
- FROM currency
- ";
- my $sth = $dbh->prepare($query);
- $sth->execute;
- my @results = ();
- while ( my $data = $sth->fetchrow_hashref ) {
- push( @results, $data );
- }
- return @results;
-}
-
-# -------------------------------------------------------------------
-
-sub GetCurrency {
- my $dbh = C4::Context->dbh;
- my $query = "
- SELECT * FROM currency where active = '1' ";
- my $sth = $dbh->prepare($query);
- $sth->execute;
- my $r = $sth->fetchrow_hashref;
- return $r;
-}
-
-# -------------------------------------------------------------------
-
=head2 ConvertCurrency
$foreignprice = &ConvertCurrency($currency, $localprice);
use C4::Accounts;
use C4::Log; # logaction
use C4::Debug;
-use C4::Budgets qw(GetCurrency);
use Koha::DateUtils;
use Koha::Account::Line;
use Koha::Account::Lines;
$tables{'branches'} = $p;
}
- my $currencies = GetCurrency();
+ my $active_currency = Koha::Acquisition::Currencies->get_active;
+
my $currency_format;
- $currency_format = $currencies->{currency} if defined($currencies);
+ $currency_format = $active_currency->currency if defined($active_currency);
my @item_tables;
if ( my $i = $params->{'items'} ) {
=cut
+=head3 get_active
+
+=cut
+
+sub get_active {
+ my ( $self ) = @_;
+ return $self->SUPER::search( { active => 1 } )->next;
+}
+
=head3 type
=cut
use Number::Format qw( format_price );
use C4::Context;
-use C4::Budgets qw( GetCurrency );
+use Koha::Acquisition::Currencies;
use base qw( Class::Accessor );
__PACKAGE__->mk_accessors(qw( value ));
my $with_symbol = $params->{with_symbol} || 0;
my $p_cs_precedes = $params->{p_cs_precedes};
my $p_sep_by_space = $params->{p_sep_by_space};
- my $currency = GetCurrency();
+ my $currency = Koha::Acquisition::Currencies->get_active;
my $currency_format = C4::Context->preference("CurrencyFormat");
my $int_curr_symbol = q||;
if ( $currency_format eq 'FR' ) {
# FIXME This test should be done for all currencies
- $int_curr_symbol = $currency->{symbol} if $with_symbol;
+ $int_curr_symbol = $currency->symbol if $with_symbol;
%format_params = (
decimal_fill => '2',
decimal_point => ',',
use C4::Installer;
use Koha;
+use Koha::Acquisition::Currencies;
use Koha::Borrowers;
use Koha::Config::SysPrefs;
my $warnIsRootUser = (! $loggedinuser);
-my $warnNoActiveCurrency = (! defined C4::Budgets->GetCurrency());
+my $warnNoActiveCurrency = (! defined Koha::Acquisition::Currencies->get_active);
my @xml_config_warnings;
my $context = new C4::Context;
use C4::Budgets;
use C4::Items;
use C4::Output;
+use Koha::Acquisition::Currencies;
### "-------------------- addorder.pl ----------"
if( ($budget_expenditure+0) && ($budget_used + $total) > $budget_expenditure
&& $total <= $budget_remaining )
{
- my $currency = GetCurrency;
+ my $currency = Koha::Acquisition::Currencies->get_active;
$template->param(
expenditure_exceeded => 1,
expenditure => sprintf("%.2f", $budget_expenditure),
- currency => ($currency) ? $currency->{'symbol'} : '',
+ currency => ($currency) ? $currency->symbol : '',
);
}
if($total > $budget_remaining){
use C4::Members;
use Koha::Number::Price;
+use Koha::Acquisition::Currencies;
use Koha::Acquisition::Order;
use Koha::Acquisition::Bookseller;
my $booksellerid = $input->param('booksellerid');
my $allmatch = $input->param('allmatch');
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
-my $data;
$template->param(scriptname => "/cgi-bin/koha/acqui/addorderiso2709.pl",
booksellerid => $booksellerid,
} elsif ($op eq "batch_details"){
#display lines inside the selected batch
# get currencies (for change rates calcs if needed)
- my $active_currency = GetCurrency();
- my $default_currency;
- if (! $data->{currency} ) { # New order no currency set
- if ( $bookseller->{listprice} ) {
- $default_currency = $bookseller->{listprice};
- }
- else {
- $default_currency = $active_currency->{currency};
- }
- }
- my @rates = GetCurrencies();
-
- # ## @rates
-
- my @loop_currency = ();
- for my $curr ( @rates ) {
- my $selected;
- if ($data->{currency} ) {
- $selected = $curr->{currency} eq $data->{currency};
- }
- else {
- $selected = $curr->{currency} eq $default_currency;
- }
- push @loop_currency, {
- currcode => $curr->{currency},
- rate => $curr->{rate},
- selected => $selected,
- }
- }
+ my @currencies = Koha::Acquisition::Currencies->search;
$template->param("batch_details" => 1,
"basketno" => $cgiparams->{'basketno'},
- loop_currencies => \@loop_currency,
+ currencies => \@currencies,
+ bookseller => $bookseller,
"allmatch" => $allmatch,
);
import_biblios_list($template, $cgiparams->{'import_batch_id'});
my @discount = $input->param('discount');
my @sort1 = $input->param('sort1');
my @sort2 = $input->param('sort2');
- my $cur = GetCurrency();
+ my $active_currency = Koha::Acquisition::Currencies->get_active;
for my $biblio (@$biblios){
# Check if this import_record_id was selected
next if not grep { $_ eq $$biblio{import_record_id} } @import_record_id_selected;
$orderinfo{ecost} = $orderinfo{rrp} * ( 1 - $c );
}
}
- $orderinfo{listprice} = $orderinfo{rrp} / $cur->{rate};
+ $orderinfo{listprice} = $orderinfo{rrp} / $active_currency->rate;
$orderinfo{unitprice} = $orderinfo{ecost};
$orderinfo{total} = $orderinfo{ecost} * $c_quantity;
} else {
push @basketusers, $basketuser if $basketuser;
}
- #to get active currency
- my $cur = GetCurrency();
-
+ my $active_currency = Koha::Acquisition::Currencies->get_active;
my @orders = GetOrders( $basketno );
my @books_loop;
total_gste => sprintf( "%.2f", $total_gste ),
total_gsti => sprintf( "%.2f", $total_gsti ),
total_gstvalue => sprintf( "%.2f", $total_gstvalue ),
- currency => $cur->{'currency'},
+ currency => $active_currency->currency,
listincgst => $bookseller->{listincgst},
basketgroups => $basketgroups,
basketgroup => $basketgroup,
use C4::Budgets;
use Koha::Acquisition::Bookseller;
+use Koha::Acquisition::Currencies;
use Koha::DateUtils;
use Koha::Misc::Files;
total_gste_shipment => sprintf( $format, $total_gste + $details->{shipmentcost}),
total_gsti_shipment => sprintf( $format, $total_gsti + $details->{shipmentcost}),
invoiceincgst => $bookseller->{invoiceincgst},
- currency => GetCurrency()->{currency},
+ currency => Koha::Acquisition::Currency->get_active->currency,
budgets_loop => \@budgets_loop,
);
use C4::ImportBatch qw/GetImportRecordMarc SetImportRecordStatus/;
use Koha::Acquisition::Bookseller;
+use Koha::Acquisition::Currencies;
use Koha::ItemTypes;
our $input = new CGI;
my $suggestion;
$suggestion = GetSuggestionInfo($suggestionid) if $suggestionid;
-# get currencies (for change rates calcs if needed)
-my $active_currency = GetCurrency();
-my $default_currency;
-if (! $data->{currency} ) { # New order no currency set
- if ( $bookseller->{listprice} ) {
- $default_currency = $bookseller->{listprice};
- }
- else {
- $default_currency = $active_currency->{currency};
- }
-}
-
-my @rates = GetCurrencies();
-
-# ## @rates
-
-my @loop_currency = ();
-for my $curr ( @rates ) {
- my $selected;
- if ($data->{currency} ) {
- $selected = $curr->{currency} eq $data->{currency};
- }
- else {
- $selected = $curr->{currency} eq $default_currency;
- }
- push @loop_currency, {
- currcode => $curr->{currency},
- rate => $curr->{rate},
- selected => $selected,
- }
-}
+my @currencies = Koha::Acquisition::Currencies->search;
+my $active_currency = Koha::Acquisition::Currencies->get_active;
# build branches list
my $onlymine =
listincgst => $bookseller->{'listincgst'},
invoiceincgst => $bookseller->{'invoiceincgst'},
name => $bookseller->{'name'},
- cur_active_sym => $active_currency->{'symbol'},
- cur_active => $active_currency->{'currency'},
- loop_currencies => \@loop_currency,
+ cur_active_sym => $active_currency->symbol,
+ cur_active => $active_currency->currency,
+ currencies => \@currencies,
orderexists => ( $new eq 'yes' ) ? 0 : 1,
title => $data->{'title'},
author => $data->{'author'},
use C4::Budgets;
use Koha::Acquisition::Bookseller;
+use Koha::Acquisition::Currencies;
my $query = CGI->new;
my $op = $query->param('op') || 'display';
}
$template->{'VARS'}->{'contacts'} = C4::Bookseller::Contact->new() unless $template->{'VARS'}->{'contacts'};
-#build array for currencies
if ( $op eq 'display' ) {
my $contracts = GetContracts( { booksellerid => $booksellerid } );
print $query->redirect('/cgi-bin/koha/acqui/acqui-home.pl');
exit;
} else {
- my @currencies = GetCurrencies();
- my $loop_currency;
- my $active_currency = GetCurrency();
- my $active_listprice = $supplier->{'listprice'};
- my $active_invoiceprice = $supplier->{'invoiceprice'};
- if (!$supplier->{listprice}) {
- $active_listprice = $active_currency->{currency};
- }
- if (!$supplier->{invoiceprice}) {
- $active_invoiceprice = $active_currency->{currency};
- }
- for (@currencies) {
- push @{$loop_currency},
- {
- currency => $_->{currency},
- listprice => ( $_->{currency} eq $active_listprice ),
- invoiceprice => ( $_->{currency} eq $active_invoiceprice ),
- };
- }
+ my @currencies = Koha::Acquisition::Currencies->search;
# get option values from gist syspref
my @gst_values = map {
active => $booksellerid ? $supplier->{'active'} : 1,
gstrate => $supplier->{gstrate} ? $supplier->{'gstrate'}+0.0 : 0,
gst_values => \@gst_values,
- loop_currency => $loop_currency,
+ currencies => \@currencies,
enter => 1,
);
}
use C4::Acquisition;
use C4::Budgets;
use C4::Debug;
+use Koha::Acquisition::Currencies;
my $dbh = C4::Context->dbh;
# This is used in incbudgets-active-currency.inc
-my $cur = GetCurrency();
-$template->param( symbol => $cur->{symbol},
- currency => $cur->{currency}
+my $active_currency = Koha::Acquisition::Currencies->get_active;
+$template->param( symbol => $active_currency->symbol,
+ currency => $active_currency->currency
);
# ADD OR MODIFY A BUDGET PERIOD - BUILD SCREEN
use C4::Output;
use C4::Koha;
use C4::Debug;
+use Koha::Acquisition::Currencies;
my $input = new CGI;
my $dbh = C4::Context->dbh;
}
);
-my $cur = GetCurrency();
-$template->param( symbol => $cur->{symbol},
- currency => $cur->{currency}
+my $active_currency = Koha::Acquisition::Currencies->get_active;
+$template->param( symbol => $active_currency->symbol,
+ currency => $active_currency->currency
);
my $op = $input->param('op') || 'list';
use C4::Koha;
use C4::Auth;
use C4::Debug;
+use Koha::Acquisition::Currencies;
my $input = new CGI;
#### $input
# IF PERIOD_ID IS DEFINED, GET THE PERIOD - ELSE GET THE ACTIVE PERIOD BY DEFAULT
my $period = GetBudgetPeriod($budget_period_id);
my $count = GetPeriodsCount();
-my $cur = GetCurrency;
-$template->param( symbol => $cur->{symbol},
- currency => $cur->{currency}
+my $active_currency = Koha::Acquisition::Currencies->get_active;
+$template->param( symbol => $active_currency->symbol,
+ currency => $active_currency->currency,
);
$template->param( period_button_only => 1 ) if $count == 0;
use C4::Log;
use C4::Output;
use C4::Templates;
-use C4::Budgets qw(GetCurrency);
+use Koha::Acquisition::Currencies;
use File::Spec;
use IO::File;
use YAML::Syck qw();
my $tab_template = C4::Templates::gettemplate( 'admin/preferences/' . $tab . '.pref', 'intranet', $input );
- my $active_currency = GetCurrency();
+ my $active_currency = Koha::Acquisition::Currencies->get_active;
my $local_currency;
if ($active_currency) {
- $local_currency = $active_currency->{currency};
+ $local_currency = $active_currency->currency;
}
$tab_template->param(
local_currency => $local_currency, # currency code is used, because we do not know how a given currency is formatted.
<input type="hidden" name="import_batch_id" value="[%import_batch_id %]" />
<input type="hidden" name="ordernumber" value="[% ordernumber %]" />
- [% FOREACH cur IN loop_currencies %]
- <input type="hidden" name="[% cur.currency %]" value="[% cur.rate %]" />
- [% END %]
-
[% FOREACH biblio IN biblio_list %]
<fieldset class="biblio unselected rows" style="float:none;">
<legend>
<li>
<label for="all_currency">Currency:</label>
<select name="all_currency" id="all_currency">
- [% FOREACH loop_currencie IN loop_currencies %]
- [% IF ( loop_currencie.selected ) %]
- <option value="[% loop_currencie.currcode %]" selected="selected">[% loop_currencie.currcode %]</option>
- [% ELSE %]
- <option value="[% loop_currencie.currcode %]">[% loop_currencie.currcode %]</option>
+ [% FOREACH currency IN currencies %]
+ [% IF currency.currency == bookseller.listprice %]
+ <option value="[% currency.currency %]" selected="selected">[% currency.currency %]</option>
+ [% ELSIF not currency.archived %]
+ <option value="[% currency.currency %]">[% currency.currency %]</option>
[% END %]
[% END %]
</select>
<input type="hidden" name="suggestionid" value="[% suggestionid %]" />
<input type="hidden" name="import_batch_id" value="[% import_batch_id %]" />
- [% FOREACH loop_currencie IN loop_currencies %]
- <input type="hidden" id="currency_rate_[% loop_currencie.currcode %]" name="[% loop_currencie.currcode %]" value="[% loop_currencie.rate %]" />
+ [% FOREACH currency IN currencies %]
+ <input type="hidden" id="currency_rate_[% currency.currency %]" name="[% currency.currency %]" value="[% currency.rate %]" />
[% END %]
<ol><li>
<input type="hidden" name="currency" id="currency" value="[% currency %]" />[% currency %]
[% ELSE %]
<label for="currency">Currency:</label>
- <select name="currency" id="currency" onchange="updateCosts();">
- [% FOREACH loop_currencie IN loop_currencies %]
- [% IF ( loop_currencie.selected ) %]<option value="[% loop_currencie.currcode %]" selected="selected">[% loop_currencie.currcode %]</option>[% ELSE %]<option value="[% loop_currencie.currcode %]">[% loop_currencie.currcode %]</option>[% END %][% END %]
- </select>
+ <select name="currency" id="currency" onchange="updateCosts();">
+ [% FOREACH currency IN currencies %]
+ [% IF ordernumber and currency.currency == listprice or not ordernumber and currency.active %]
+ <option value="[% currency.currency %]" selected="selected">[% currency.currency %]</option>
+ [% ELSIF not currency.archived %]
+ <option value="[% currency.currency %]">[% currency.currency %]</option>
+ [% END %]
+ [% END %]
+ </select>
[% END %]
</li>
<li>
</ol>
<ol>
<li><label for="list_currency">List prices are: </label>
- <select name="list_currency" id="list_currency">
- [% FOREACH loop_currenc IN loop_currency %]
- [% IF ( loop_currenc.listprice ) %]<option value="[% loop_currenc.currency %]" selected="selected">[% loop_currenc.currency %]</option>
- [% ELSE %]<option value="[% loop_currenc.currency %]">[% loop_currenc.currency %]</option>[% END %]
+ <select name="list_currency" id="list_currency">
+ [% FOREACH currency IN currencies %]
+ [% IF booksellerid and currency.currency == listprice or not booksellerid and currency.active %]
+ <option value="[% currency.currency %]" selected="selected">[% currency.currency %]</option>
+ [% ELSIF not currency.archived %]
+ <option value="[% currency.currency %]" selected="selected">[% currency.currency %]</option>
+ [% END %]
[% END %]
- </select>
+ </select>
</li>
<li><label for="invoice_currency">Invoice prices are: </label>
- <select name="invoice_currency" id="invoice_currency">
- [% FOREACH loop_currenc IN loop_currency %]
- [% IF ( loop_currenc.invoiceprice ) %]<option value="[% loop_currenc.currency %]" selected="selected">[% loop_currenc.currency %]</option>
- [% ELSE %]<option value="[% loop_currenc.currency %]">[% loop_currenc.currency %]</option>[% END %]
+ <select name="invoice_currency" id="invoice_currency">
+ [% FOREACH currency IN currencies %]
+ [% IF booksellerid and currency.currency == invoiceprice or not booksellerid and currency.active %]
+ <option value="[% currency.currency %]" selected="selected">[% currency.currency %]</option>
+ [% ELSIF not currency.archived %]
+ <option value="[% currency.currency %]" selected="selected">[% currency.currency %]</option>
+ [% END %]
[% END %]
- </select>
+ </select>
</li>
</ol>
<ol class="radio">
<th>ISO code</th>
<th class="title-string">Last updated</th>
<th>Active</th>
+ <th>Archived</th>
<th>Actions</th>
</tr>
</thead>
<td>[% currency.isocode |html %]</td>
<td><span title="[% currency.timestamp %]">[% currency.timestamp | $KohaDates %]</span></td>
<td style="color:green;">[% IF currency.active %]✓[% END %]</td>
+ <td>[% IF currency.archived %]Yes[% END %]</td>
<td>
<a href="/cgi-bin/koha/admin/currency.pl?op=add_form&currency_code=[% currency.currency %]">Edit</a>
|
</select>
</li><li><label for="quantity">Copies:</label>
<input type="text" size="10" id="quantity" name="quantity" value="[% quantity %]" onchange="calcNewsuggTotal();" />
- </li><li><label for="currency">Currency:</label>
- [% FOREACH loop_currenc IN loop_currency %]
- <input type="hidden" value="[% loop_currenc.rate %]" id="currency_rate_[% loop_currenc.currcode %]" name="currency_rate_[% loop_currenc.currcode %]" />
- <input type="hidden" id="[% loop_currenc.currcode %]" name="[% loop_currenc.currcode %]" value="[% loop_currenc.rate %]" />
- [% END %]
- <select name="currency" id="currency" onchange="calcNewsuggTotal();">
- [% FOREACH loop_currenc IN loop_currency %]
- [% IF ( loop_currenc.selected ) %]<option value="[% loop_currenc.currcode %]" selected="selected">[% loop_currenc.currcode %]</option>[% ELSE %]<option value="[% loop_currenc.currcode %]">[% loop_currenc.currcode %]</option>[% END %][% END %]
- </select>
- </li><li><label for="price">Price:</label>
+ </li>
+ <li>
+ <label for="currency">Currency:</label>
+ [% FOREACH c IN currencies %]
+ <input type="hidden" value="[% c.rate %]" id="currency_rate_[% c.currency %]" name="currency_rate_[% c.currency %]" />
+ <input type="hidden" id="[% c.currency %]" name="[% c.currency %]" value="[% c.rate %]" />
+ [% END %]
+
+ <select name="currency" id="currency" onchange="calcNewsuggTotal();">
+ [% FOREACH c IN currencies %]
+ [% IF suggestionid and suggestion.currency == c.currency or not suggestionid and c.active %]
+ <option value="[% c.currency %]" selected="selected">[% c.currency %]</option>
+ [% ELSIF not c.archived %]
+ <option value="[% c.currency %]">[% c.currency %]</option>
+ [% END %]
+ [% END %]
+ </select>
+ </li>
+ <li><label for="price">Price:</label>
<input type="text" size="20" name="price" id="price" value="[% price %]" onchange="calcNewsuggTotal();" />
</li><li><label for="total">Total: </label>
<input type="text" readonly="readonly" id="total" name="total" size="10" value="[% total %]"/>
use Koha::DateUtils;
use Koha::Calendar;
use Koha::Libraries;
+use Koha::Acquisition::Currencies;
=head1 NAME
use C4::Members;
use C4::Biblio;
use C4::Items;
+use Koha::Acquisition::Currencies;
my $query = new CGI;
my $borrower = GetMemberDetails(undef,$patronid);
my $currencySymbol = "";
-if ( defined C4::Budgets->GetCurrency() ) {
- $currencySymbol = C4::Budgets->GetCurrency()->{symbol};
+if ( my $active_currency = Koha::Acquisition::Currencies->get_active ) {
+ $currencySymbol = $active_currency->symbol;
}
my $branch = $issuer->{branchcode};
use C4::Debug;
use Koha::DateUtils qw( dt_from_string );
+use Koha::Acquisition::Currencies;
use URI::Escape;
$template->param( budgetsloop => \@budgets_loop);
$template->param( "statusselected_$$suggestion_ref{'STATUS'}" =>1) if ($$suggestion_ref{'STATUS'});
-# get currencies and rates
-my @rates = GetCurrencies();
-my $count = scalar @rates;
-my $active_currency = GetCurrency();
-my $selected_currency;
-if ($$suggestion_ref{'currency'}) {
- $selected_currency = $$suggestion_ref{'currency'};
-}
-else {
- $selected_currency = $active_currency->{currency};
-}
-
-my @loop_currency = ();
-for ( my $i = 0 ; $i < $count ; $i++ ) {
- my %line;
- $line{currcode} = $rates[$i]->{'currency'};
- $line{rate} = $rates[$i]->{'rate'};
- $line{selected} = 1 if ($line{'currcode'} eq $selected_currency);
- push @loop_currency, \%line;
-}
+my @currencies = Koha::Acquisition::Currencies->search;
$template->param(
- loop_currency => \@loop_currency,
+ currencies => \@currencies,
+ suggestion => $suggestion_ref,
price => sprintf("%.2f", $$suggestion_ref{'price'}||0),
total => sprintf("%.2f", $$suggestion_ref{'total'}||0),
);
use Test::MockModule;
use t::lib::Mocks;
-use C4::Budgets;
-my $budget_module = Test::MockModule->new('C4::Budgets');
+use Koha::Acquisition::Currencies;
+my $budget_module = Test::MockModule->new('Koha::Acquisition::Currencies');
my $currency;
-$budget_module->mock( 'GetCurrency', sub { return $currency; } );
+$budget_module->mock( 'get_active', sub { return $currency; } );
use_ok('Koha::Number::Price');
my $format = {
p_sep_by_space => 0, # Force to not add a space between the symbol and the number
};
t::lib::Mocks::mock_preference( 'CurrencyFormat', 'US' );
-$currency = {
+$currency = Koha::Acquisition::Currency->new({
currency => 'USD',
symbol => '$',
rate => 1,
active => 1,
-};
+});
is( Koha::Number::Price->new->format( $format ), '0.00', 'US: format 0' );
is( Koha::Number::Price->new(3)->format( $format ), '3.00', 'US: format 3' );
'1234567890', 'US: unformat 1234567890' );
t::lib::Mocks::mock_preference( 'CurrencyFormat', 'FR' );
-$currency = {
+$currency = Koha::Acquisition::Currency->new({
currency => 'EUR',
symbol => '€',
rate => 1,
active => 1,
-};
+});
# Actually,the price formating for France is 3,00€
# How put the symbol at the end with Number::Format?
mock_marcfromkohafield();
-my $currency = new Test::MockModule('C4::Budgets');
-$currency->mock( 'GetCurrency', sub {
- return { symbol => '$', isocode => 'USD',
- currency => 'USD', active => 1 };
-});
+my $currency = new Test::MockModule('Koha::Acquisition::Currencies');
+$currency->mock(
+ 'get_active',
+ sub {
+ return Koha::Acquisition::Currency->new(
+ { symbol => '$',
+ isocode => 'USD',
+ currency => 'USD',
+ active => 1,
+ }
+ );
+ }
+);
sub run_tests {
use strict;
use warnings;
use C4::Biblio;
-use C4::Budgets;
+use Koha::Acquisition::Currencies;
use Test::More;
use utf8;
my $RATE= 1;
# disables existing active currency if necessary.
-my $active_currency = C4::Budgets->GetCurrency();
+my $active_currency = Koha::Acquisition::Currencies->get_active;
my $curr;
if ($active_currency) {
- $curr = $active_currency->{'currency'};
+ $curr = $active_currency->currency;
$dbh->do("UPDATE currency set active = 0 where currency = '$curr'");
}