Bugzilla – Attachment 45694 Details for
Bug 15084
Move the currency related code to Koha::Acquisition::Currenc[y|ies]
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15084: Replace C4::Budgets::GetCurrencies with Koha::Acquisition::Currencies->search
Bug-15084-Replace-C4BudgetsGetCurrencies-with-Koha.patch (text/plain), 37.51 KB, created by
Jonathan Druart
on 2015-12-15 10:27:36 UTC
(
hide
)
Description:
Bug 15084: Replace C4::Budgets::GetCurrencies with Koha::Acquisition::Currencies->search
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2015-12-15 10:27:36 UTC
Size:
37.51 KB
patch
obsolete
>From 941c96092998a4bc97a78774a5074ffdf01d4f02 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 29 Oct 2015 12:21:52 +0000 >Subject: [PATCH] Bug 15084: Replace C4::Budgets::GetCurrencies with > Koha::Acquisition::Currencies->search > >Most part of the code here is unnecessary complex. We should selected >the currency if it is selected, that's all :) >--- > C4/Biblio.pm | 9 ++--- > C4/Budgets.pm | 42 ---------------------- > C4/Overdues.pm | 6 ++-- > Koha/Acquisition/Currencies.pm | 9 +++++ > Koha/Number/Price.pm | 6 ++-- > about.pl | 3 +- > acqui/addorder.pl | 5 +-- > acqui/addorderiso2709.pl | 39 ++++---------------- > acqui/basket.pl | 6 ++-- > acqui/invoice.pl | 3 +- > acqui/neworderempty.pl | 40 ++++----------------- > acqui/supplier.pl | 24 ++----------- > admin/aqbudgetperiods.pl | 7 ++-- > admin/aqbudgets.pl | 7 ++-- > admin/aqplan.pl | 7 ++-- > admin/preferences.pl | 6 ++-- > .../prog/en/modules/acqui/addorderiso2709.tt | 14 +++----- > .../prog/en/modules/acqui/neworderempty.tt | 17 +++++---- > .../prog/en/modules/acqui/supplier.tt | 26 ++++++++------ > .../prog/en/modules/admin/currency.tt | 2 ++ > .../prog/en/modules/suggestion/suggestion.tt | 29 +++++++++------ > misc/cronjobs/overdue_notices.pl | 2 +- > opac/sco/sco-main.pl | 5 +-- > suggestion/suggestion.pl | 25 +++---------- > t/Number/Price.t | 14 ++++---- > t/db_dependent/Biblio.t | 18 +++++++--- > t/db_dependent/MungeMarcPrice.t | 6 ++-- > 27 files changed, 143 insertions(+), 234 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 919051a..29b02fe 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -39,6 +39,7 @@ use C4::Linker; > use C4::OAI::Sets; > > use Koha::Cache; >+use Koha::Acquisition::Currencies; > > use vars qw($VERSION @ISA @EXPORT); > >@@ -1531,10 +1532,10 @@ sub MungeMarcPrice { > 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=~ / >diff --git a/C4/Budgets.pm b/C4/Budgets.pm >index 79012ba..5cd5860 100644 >--- a/C4/Budgets.pm >+++ b/C4/Budgets.pm >@@ -59,8 +59,6 @@ BEGIN { > > &ModBudgetPlan > >- &GetCurrency >- &GetCurrencies > &ConvertCurrency > > &GetBudgetsPlanCell >@@ -917,46 +915,6 @@ sub CanUserModifyBudget { > > # ------------------------------------------------------------------- > >-=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); >diff --git a/C4/Overdues.pm b/C4/Overdues.pm >index 72c0704..47446e0 100644 >--- a/C4/Overdues.pm >+++ b/C4/Overdues.pm >@@ -32,7 +32,6 @@ use C4::Context; > use C4::Accounts; > use C4::Log; # logaction > use C4::Debug; >-use C4::Budgets qw(GetCurrency); > use Koha::DateUtils; > > use vars qw($VERSION @ISA @EXPORT); >@@ -986,9 +985,10 @@ sub parse_overdues_letter { > $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'} ) { >diff --git a/Koha/Acquisition/Currencies.pm b/Koha/Acquisition/Currencies.pm >index 7f506a7..cdbbfed 100644 >--- a/Koha/Acquisition/Currencies.pm >+++ b/Koha/Acquisition/Currencies.pm >@@ -35,6 +35,15 @@ Koha::Acquisition::Currencies - Koha Acquisition Currency Object set class > > =cut > >+=head3 get_active >+ >+=cut >+ >+sub get_active { >+ my ( $self ) = @_; >+ return $self->SUPER::search( { active => 1 } )->next; >+} >+ > =head3 type > > =cut >diff --git a/Koha/Number/Price.pm b/Koha/Number/Price.pm >index 2d563f9..331e3c3 100644 >--- a/Koha/Number/Price.pm >+++ b/Koha/Number/Price.pm >@@ -21,7 +21,7 @@ use Modern::Perl; > > 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 )); >@@ -82,7 +82,7 @@ sub _format_params { > 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||; >@@ -94,7 +94,7 @@ sub _format_params { > > 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 => ',', >diff --git a/about.pl b/about.pl >index 01e941c..88b1284 100755 >--- a/about.pl >+++ b/about.pl >@@ -34,6 +34,7 @@ use C4::Context; > use C4::Installer; > > use Koha; >+use Koha::Acquisition::Currencies; > use Koha::Borrowers; > use Koha::Config::SysPrefs; > >@@ -95,7 +96,7 @@ my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode(); > > 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; >diff --git a/acqui/addorder.pl b/acqui/addorder.pl >index f58e58d..e5480ef 100755 >--- a/acqui/addorder.pl >+++ b/acqui/addorder.pl >@@ -129,6 +129,7 @@ use C4::Biblio; # AddBiblio TransformKohaToMarc > use C4::Budgets; > use C4::Items; > use C4::Output; >+use Koha::Acquisition::Currencies; > > ### "-------------------- addorder.pl ----------" > >@@ -188,11 +189,11 @@ unless($confirm_budget_exceeding) { > 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){ >diff --git a/acqui/addorderiso2709.pl b/acqui/addorderiso2709.pl >index 8ce2ce1..9fe08c0 100755 >--- a/acqui/addorderiso2709.pl >+++ b/acqui/addorderiso2709.pl >@@ -43,6 +43,7 @@ use C4::Branch; # GetBranches > use C4::Members; > > use Koha::Number::Price; >+use Koha::Acquisition::Currencies; > use Koha::Acquisition::Order; > use Koha::Acquisition::Bookseller; > >@@ -61,7 +62,6 @@ my $op = $cgiparams->{'op'} || ''; > 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, >@@ -90,39 +90,12 @@ if ($op eq ""){ > } 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'}); >@@ -167,7 +140,7 @@ if ($op eq ""){ > 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; >@@ -252,7 +225,7 @@ if ($op eq ""){ > $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 { >diff --git a/acqui/basket.pl b/acqui/basket.pl >index 5fa94f8..b25426e 100755 >--- a/acqui/basket.pl >+++ b/acqui/basket.pl >@@ -290,9 +290,7 @@ if ( $op eq 'delete_confirm' ) { > 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; >@@ -384,7 +382,7 @@ if ( $op eq 'delete_confirm' ) { > 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, >diff --git a/acqui/invoice.pl b/acqui/invoice.pl >index f56afcc..c7584f3 100755 >--- a/acqui/invoice.pl >+++ b/acqui/invoice.pl >@@ -36,6 +36,7 @@ use C4::Acquisition; > use C4::Budgets; > > use Koha::Acquisition::Bookseller; >+use Koha::Acquisition::Currencies; > use Koha::DateUtils; > use Koha::Misc::Files; > >@@ -178,7 +179,7 @@ $template->param( > 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, > ); > >diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl >index 4a37815..f09e1ce 100755 >--- a/acqui/neworderempty.pl >+++ b/acqui/neworderempty.pl >@@ -89,6 +89,7 @@ use C4::Search qw/FindDuplicate/; > use C4::ImportBatch qw/GetImportRecordMarc SetImportRecordStatus/; > > use Koha::Acquisition::Bookseller; >+use Koha::Acquisition::Currencies; > > our $input = new CGI; > my $booksellerid = $input->param('booksellerid'); # FIXME: else ERROR! >@@ -205,37 +206,8 @@ else { #modify order > 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 = >@@ -376,9 +348,9 @@ $template->param( > 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'}, >diff --git a/acqui/supplier.pl b/acqui/supplier.pl >index 2d1a223..493c8af 100755 >--- a/acqui/supplier.pl >+++ b/acqui/supplier.pl >@@ -53,6 +53,7 @@ use C4::Bookseller::Contact; > use C4::Budgets; > > use Koha::Acquisition::Bookseller; >+use Koha::Acquisition::Currencies; > > my $query = CGI->new; > my $op = $query->param('op') || 'display'; >@@ -76,7 +77,6 @@ if ($booksellerid) { > } > $template->{'VARS'}->{'contacts'} = C4::Bookseller::Contact->new() unless $template->{'VARS'}->{'contacts'}; > >-#build array for currencies > if ( $op eq 'display' ) { > my $contracts = GetContracts( { booksellerid => $booksellerid } ); > >@@ -98,25 +98,7 @@ if ( $op eq 'display' ) { > 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 { >@@ -128,7 +110,7 @@ if ( $op eq 'display' ) { > 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, > ); > } >diff --git a/admin/aqbudgetperiods.pl b/admin/aqbudgetperiods.pl >index f837b81..7cd32fc 100755 >--- a/admin/aqbudgetperiods.pl >+++ b/admin/aqbudgetperiods.pl >@@ -57,6 +57,7 @@ use C4::Output; > use C4::Acquisition; > use C4::Budgets; > use C4::Debug; >+use Koha::Acquisition::Currencies; > > my $dbh = C4::Context->dbh; > >@@ -91,9 +92,9 @@ my ($template, $borrowernumber, $cookie, $staff_flags ) = get_template_and_user( > > > # 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 >diff --git a/admin/aqbudgets.pl b/admin/aqbudgets.pl >index 2d85fdc..59091fd 100755 >--- a/admin/aqbudgets.pl >+++ b/admin/aqbudgets.pl >@@ -35,6 +35,7 @@ use C4::Context; > use C4::Output; > use C4::Koha; > use C4::Debug; >+use Koha::Acquisition::Currencies; > > my $input = new CGI; > my $dbh = C4::Context->dbh; >@@ -49,9 +50,9 @@ my ($template, $borrowernumber, $cookie, $staffflags ) = get_template_and_user( > } > ); > >-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'; >diff --git a/admin/aqplan.pl b/admin/aqplan.pl >index d0b11a2..ceaa61b 100755 >--- a/admin/aqplan.pl >+++ b/admin/aqplan.pl >@@ -35,6 +35,7 @@ use C4::Output; > use C4::Koha; > use C4::Auth; > use C4::Debug; >+use Koha::Acquisition::Currencies; > > my $input = new CGI; > #### $input >@@ -56,9 +57,9 @@ my $budget_period_id = $input->param('budget_period_id'); > # 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; > >diff --git a/admin/preferences.pl b/admin/preferences.pl >index d9683f1..24bffce 100755 >--- a/admin/preferences.pl >+++ b/admin/preferences.pl >@@ -28,7 +28,7 @@ use C4::ClassSource; > 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(); >@@ -45,10 +45,10 @@ sub GetTab { > > 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. >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt >index bf6c0b6..d2a7c9e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt >@@ -187,10 +187,6 @@ > <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> >@@ -334,11 +330,11 @@ > <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> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >index 7638f02..dbb2b02 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >@@ -302,8 +302,8 @@ $(document).ready(function() > <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> >@@ -522,10 +522,15 @@ $(document).ready(function() > <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> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt >index 334d644..be67df8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt >@@ -221,20 +221,26 @@ function delete_contact(ev) { > </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"> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt >index 8aefa41..0d31b7b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt >@@ -178,6 +178,7 @@ > <th>ISO code</th> > <th class="title-string">Last updated</th> > <th>Active</th> >+ <th>Archived</th> > <th>Actions</th> > </tr> > </thead> >@@ -190,6 +191,7 @@ > <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> > | >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >index 547265d..a562618 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >@@ -420,16 +420,25 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o > </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 %]"/> >diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl >index 98b0a25..becdc68 100755 >--- a/misc/cronjobs/overdue_notices.pl >+++ b/misc/cronjobs/overdue_notices.pl >@@ -41,11 +41,11 @@ use C4::Context; > use C4::Debug; > use C4::Letters; > use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes parse_overdues_letter); >-use C4::Budgets qw(GetCurrency); > use C4::Log; > use Koha::Borrower::Debarments qw(AddUniqueDebarment); > use Koha::DateUtils; > use Koha::Calendar; >+use Koha::Acquisition::Currencies; > > =head1 NAME > >diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl >index eff549d..b345c7c 100755 >--- a/opac/sco/sco-main.pl >+++ b/opac/sco/sco-main.pl >@@ -45,6 +45,7 @@ use C4::Output; > use C4::Members; > use C4::Biblio; > use C4::Items; >+use Koha::Acquisition::Currencies; > > my $query = new CGI; > >@@ -113,8 +114,8 @@ if (C4::Context->preference('SelfCheckoutByLogin') && !$patronid) { > 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}; >diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl >index e772a2a..08dd118 100755 >--- a/suggestion/suggestion.pl >+++ b/suggestion/suggestion.pl >@@ -32,6 +32,7 @@ use C4::Members; > use C4::Debug; > > use Koha::DateUtils qw( dt_from_string ); >+use Koha::Acquisition::Currencies; > > use URI::Escape; > >@@ -352,28 +353,10 @@ foreach my $budget ( @{$budgets} ) { > $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), > ); >diff --git a/t/Number/Price.t b/t/Number/Price.t >index 3191e4d..060b183 100644 >--- a/t/Number/Price.t >+++ b/t/Number/Price.t >@@ -5,10 +5,10 @@ use Test::More tests => 19; > 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 = { >@@ -16,12 +16,12 @@ 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' ); >@@ -45,12 +45,12 @@ is( Koha::Number::Price->new(1234567890)->unformat, > '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? >diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t >index 0413b90..0bc6310 100755 >--- a/t/db_dependent/Biblio.t >+++ b/t/db_dependent/Biblio.t >@@ -37,11 +37,19 @@ my $context = new Test::MockModule('C4::Context'); > > 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 { > >diff --git a/t/db_dependent/MungeMarcPrice.t b/t/db_dependent/MungeMarcPrice.t >index f661323..78a599f 100755 >--- a/t/db_dependent/MungeMarcPrice.t >+++ b/t/db_dependent/MungeMarcPrice.t >@@ -3,7 +3,7 @@ > use strict; > use warnings; > use C4::Biblio; >-use C4::Budgets; >+use Koha::Acquisition::Currencies; > use Test::More; > use utf8; > >@@ -39,10 +39,10 @@ my $ISOCODE = 'USD'; > 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'"); > } > >-- >2.1.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15084
:
44162
|
44163
|
44164
|
44165
|
44166
|
44167
|
44168
|
45690
|
45691
|
45692
|
45693
|
45694
|
45695
|
45696
|
45759
|
45761
|
45807
|
45808
|
45809
|
45810
|
45811
|
45812
|
45813
|
45814
|
47213
|
47214
|
47215
|
47216
|
47217
|
47218
|
47219
|
47220
|
47221
|
48594
|
48595
|
48596
|
48597
|
48598
|
48599
|
48600
|
48601
|
48602
|
48603
|
48703
|
48747
|
48772
|
48783
|
48858