View | Details | Raw Unified | Return to bug 15084
Collapse All | Expand All

(-)a/C4/Biblio.pm (-4 / +5 lines)
Lines 39-44 use C4::Linker; Link Here
39
use C4::OAI::Sets;
39
use C4::OAI::Sets;
40
40
41
use Koha::Cache;
41
use Koha::Cache;
42
use Koha::Acquisition::Currencies;
42
43
43
use vars qw($VERSION @ISA @EXPORT);
44
use vars qw($VERSION @ISA @EXPORT);
44
45
Lines 1531-1540 sub MungeMarcPrice { Link Here
1531
    my ( $price ) = @_;
1532
    my ( $price ) = @_;
1532
    return unless ( $price =~ m/\d/ ); ## No digits means no price.
1533
    return unless ( $price =~ m/\d/ ); ## No digits means no price.
1533
    # Look for the currency symbol and the normalized code of the active currency, if it's there,
1534
    # Look for the currency symbol and the normalized code of the active currency, if it's there,
1534
    my $active_currency = C4::Budgets->GetCurrency();
1535
    my $active_currency = Koha::Acquisition::Currencies->get_active;
1535
    my $symbol = $active_currency->{'symbol'};
1536
    my $symbol = $active_currency->symbol;
1536
    my $isocode = $active_currency->{'isocode'};
1537
    my $isocode = $active_currency->isocode;
1537
    $isocode = $active_currency->{'currency'} unless defined $isocode;
1538
    $isocode = $active_currency->currency unless defined $isocode;
1538
    my $localprice;
1539
    my $localprice;
1539
    if ( $symbol ) {
1540
    if ( $symbol ) {
1540
        my @matches =($price=~ /
1541
        my @matches =($price=~ /
(-)a/C4/Budgets.pm (-42 lines)
Lines 59-66 BEGIN { Link Here
59
59
60
        &ModBudgetPlan
60
        &ModBudgetPlan
61
61
62
        &GetCurrency
63
        &GetCurrencies
64
        &ConvertCurrency
62
        &ConvertCurrency
65
        
63
        
66
		&GetBudgetsPlanCell
64
		&GetBudgetsPlanCell
Lines 917-962 sub CanUserModifyBudget { Link Here
917
915
918
# -------------------------------------------------------------------
916
# -------------------------------------------------------------------
919
917
920
=head2 GetCurrencies
921
922
  @currencies = &GetCurrencies;
923
924
Returns the list of all known currencies.
925
926
C<$currencies> is a array; its elements are references-to-hash, whose
927
keys are the fields from the currency table in the Koha database.
928
929
=cut
930
931
sub GetCurrencies {
932
    my $dbh   = C4::Context->dbh;
933
    my $query = "
934
        SELECT *
935
        FROM   currency
936
    ";
937
    my $sth = $dbh->prepare($query);
938
    $sth->execute;
939
    my @results = ();
940
    while ( my $data = $sth->fetchrow_hashref ) {
941
        push( @results, $data );
942
    }
943
    return @results;
944
}
945
946
# -------------------------------------------------------------------
947
948
sub GetCurrency {
949
    my $dbh   = C4::Context->dbh;
950
    my $query = "
951
        SELECT * FROM currency where active = '1'    ";
952
    my $sth = $dbh->prepare($query);
953
    $sth->execute;
954
    my $r = $sth->fetchrow_hashref;
955
    return $r;
956
}
957
958
# -------------------------------------------------------------------
959
960
=head2 ConvertCurrency
918
=head2 ConvertCurrency
961
919
962
  $foreignprice = &ConvertCurrency($currency, $localprice);
920
  $foreignprice = &ConvertCurrency($currency, $localprice);
(-)a/Koha/Acquisition/Currencies.pm (+9 lines)
Lines 35-40 Koha::Acquisition::Currencies - Koha Acquisition Currency Object set class Link Here
35
35
36
=cut
36
=cut
37
37
38
=head3 get_active
39
40
=cut
41
42
sub get_active {
43
    my ( $self ) = @_;
44
    return $self->SUPER::search( { active => 1 } )->next;
45
}
46
38
=head3 type
47
=head3 type
39
48
40
=cut
49
=cut
(-)a/Koha/Number/Price.pm (-3 / +3 lines)
Lines 21-27 use Modern::Perl; Link Here
21
21
22
use Number::Format qw( format_price );
22
use Number::Format qw( format_price );
23
use C4::Context;
23
use C4::Context;
24
use C4::Budgets qw( GetCurrency );
24
use Koha::Acquisition::Currencies;
25
25
26
use base qw( Class::Accessor );
26
use base qw( Class::Accessor );
27
__PACKAGE__->mk_accessors(qw( value ));
27
__PACKAGE__->mk_accessors(qw( value ));
Lines 82-88 sub _format_params { Link Here
82
    my $with_symbol = $params->{with_symbol} || 0;
82
    my $with_symbol = $params->{with_symbol} || 0;
83
    my $p_cs_precedes = $params->{p_cs_precedes};
83
    my $p_cs_precedes = $params->{p_cs_precedes};
84
    my $p_sep_by_space = $params->{p_sep_by_space};
84
    my $p_sep_by_space = $params->{p_sep_by_space};
85
    my $currency        = GetCurrency();
85
    my $currency        = Koha::Acquisition::Currencies->get_active;
86
    my $currency_format = C4::Context->preference("CurrencyFormat");
86
    my $currency_format = C4::Context->preference("CurrencyFormat");
87
87
88
    my $int_curr_symbol = q||;
88
    my $int_curr_symbol = q||;
Lines 94-100 sub _format_params { Link Here
94
94
95
    if ( $currency_format eq 'FR' ) {
95
    if ( $currency_format eq 'FR' ) {
96
        # FIXME This test should be done for all currencies
96
        # FIXME This test should be done for all currencies
97
        $int_curr_symbol = $currency->{symbol} if $with_symbol;
97
        $int_curr_symbol = $currency->symbol if $with_symbol;
98
        %format_params = (
98
        %format_params = (
99
            decimal_fill      => '2',
99
            decimal_fill      => '2',
100
            decimal_point     => ',',
100
            decimal_point     => ',',
(-)a/about.pl (-1 / +2 lines)
Lines 34-39 use C4::Context; Link Here
34
use C4::Installer;
34
use C4::Installer;
35
35
36
use Koha;
36
use Koha;
37
use Koha::Acquisition::Currencies;
37
use Koha::Borrowers;
38
use Koha::Borrowers;
38
use Koha::Config::SysPrefs;
39
use Koha::Config::SysPrefs;
39
40
Lines 85-91 my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode(); Link Here
85
86
86
my $warnIsRootUser   = (! $loggedinuser);
87
my $warnIsRootUser   = (! $loggedinuser);
87
88
88
my $warnNoActiveCurrency = (! defined C4::Budgets->GetCurrency());
89
my $warnNoActiveCurrency = (! defined Koha::Acquisition::Currencies->get_active);
89
my @xml_config_warnings;
90
my @xml_config_warnings;
90
91
91
my $context = new C4::Context;
92
my $context = new C4::Context;
(-)a/acqui/addorder.pl (-2 / +3 lines)
Lines 129-134 use C4::Biblio; # AddBiblio TransformKohaToMarc Link Here
129
use C4::Budgets;
129
use C4::Budgets;
130
use C4::Items;
130
use C4::Items;
131
use C4::Output;
131
use C4::Output;
132
use Koha::Acquisition::Currencies;
132
133
133
### "-------------------- addorder.pl ----------"
134
### "-------------------- addorder.pl ----------"
134
135
Lines 188-198 unless($confirm_budget_exceeding) { Link Here
188
        if( ($budget_expenditure+0) && ($budget_used + $total) > $budget_expenditure
189
        if( ($budget_expenditure+0) && ($budget_used + $total) > $budget_expenditure
189
          && $total <= $budget_remaining )
190
          && $total <= $budget_remaining )
190
        {
191
        {
191
            my $currency = GetCurrency;
192
            my $currency = Koha::Acquisition::Currencies->get_active;
192
            $template->param(
193
            $template->param(
193
                expenditure_exceeded => 1,
194
                expenditure_exceeded => 1,
194
                expenditure => sprintf("%.2f", $budget_expenditure),
195
                expenditure => sprintf("%.2f", $budget_expenditure),
195
                currency => ($currency) ? $currency->{'symbol'} : '',
196
                currency => ($currency) ? $currency->symbol : '',
196
            );
197
            );
197
        }
198
        }
198
        if($total > $budget_remaining){
199
        if($total > $budget_remaining){
(-)a/acqui/addorderiso2709.pl (-33 / +6 lines)
Lines 43-48 use C4::Branch; # GetBranches Link Here
43
use C4::Members;
43
use C4::Members;
44
44
45
use Koha::Number::Price;
45
use Koha::Number::Price;
46
use Koha::Acquisition::Currencies;
46
use Koha::Acquisition::Order;
47
use Koha::Acquisition::Order;
47
use Koha::Acquisition::Bookseller;
48
use Koha::Acquisition::Bookseller;
48
49
Lines 61-67 my $op = $cgiparams->{'op'} || ''; Link Here
61
my $booksellerid  = $input->param('booksellerid');
62
my $booksellerid  = $input->param('booksellerid');
62
my $allmatch = $input->param('allmatch');
63
my $allmatch = $input->param('allmatch');
63
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
64
my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
64
my $data;
65
65
66
$template->param(scriptname => "/cgi-bin/koha/acqui/addorderiso2709.pl",
66
$template->param(scriptname => "/cgi-bin/koha/acqui/addorderiso2709.pl",
67
                booksellerid => $booksellerid,
67
                booksellerid => $booksellerid,
Lines 90-128 if ($op eq ""){ Link Here
90
} elsif ($op eq "batch_details"){
90
} elsif ($op eq "batch_details"){
91
#display lines inside the selected batch
91
#display lines inside the selected batch
92
    # get currencies (for change rates calcs if needed)
92
    # get currencies (for change rates calcs if needed)
93
    my $active_currency = GetCurrency();
93
    my @currencies = Koha::Acquisition::Currencies->search;
94
    my $default_currency;
95
    if (! $data->{currency} ) { # New order no currency set
96
        if ( $bookseller->{listprice} ) {
97
            $default_currency = $bookseller->{listprice};
98
        }
99
        else {
100
            $default_currency = $active_currency->{currency};
101
        }
102
    }
103
    my @rates = GetCurrencies();
104
105
    # ## @rates
106
107
    my @loop_currency = ();
108
    for my $curr ( @rates ) {
109
        my $selected;
110
        if ($data->{currency} ) {
111
            $selected = $curr->{currency} eq $data->{currency};
112
        }
113
        else {
114
            $selected = $curr->{currency} eq $default_currency;
115
        }
116
        push @loop_currency, {
117
            currcode => $curr->{currency},
118
            rate     => $curr->{rate},
119
            selected => $selected,
120
        }
121
    }
122
94
123
    $template->param("batch_details" => 1,
95
    $template->param("batch_details" => 1,
124
                     "basketno"      => $cgiparams->{'basketno'},
96
                     "basketno"      => $cgiparams->{'basketno'},
125
                     loop_currencies  => \@loop_currency,
97
                     currencies => \@currencies,
98
                     bookseller => $bookseller,
126
                     "allmatch" => $allmatch,
99
                     "allmatch" => $allmatch,
127
                     );
100
                     );
128
    import_biblios_list($template, $cgiparams->{'import_batch_id'});
101
    import_biblios_list($template, $cgiparams->{'import_batch_id'});
Lines 167-173 if ($op eq ""){ Link Here
167
    my @discount = $input->param('discount');
140
    my @discount = $input->param('discount');
168
    my @sort1 = $input->param('sort1');
141
    my @sort1 = $input->param('sort1');
169
    my @sort2 = $input->param('sort2');
142
    my @sort2 = $input->param('sort2');
170
    my $cur = GetCurrency();
143
    my $active_currency = Koha::Acquisition::Currencies->get_active;
171
    for my $biblio (@$biblios){
144
    for my $biblio (@$biblios){
172
        # Check if this import_record_id was selected
145
        # Check if this import_record_id was selected
173
        next if not grep { $_ eq $$biblio{import_record_id} } @import_record_id_selected;
146
        next if not grep { $_ eq $$biblio{import_record_id} } @import_record_id_selected;
Lines 252-258 if ($op eq ""){ Link Here
252
                    $orderinfo{ecost} = $orderinfo{rrp} * ( 1 - $c );
225
                    $orderinfo{ecost} = $orderinfo{rrp} * ( 1 - $c );
253
                }
226
                }
254
            }
227
            }
255
            $orderinfo{listprice} = $orderinfo{rrp} / $cur->{rate};
228
            $orderinfo{listprice} = $orderinfo{rrp} / $active_currency->rate;
256
            $orderinfo{unitprice} = $orderinfo{ecost};
229
            $orderinfo{unitprice} = $orderinfo{ecost};
257
            $orderinfo{total} = $orderinfo{ecost} * $c_quantity;
230
            $orderinfo{total} = $orderinfo{ecost} * $c_quantity;
258
        } else {
231
        } else {
(-)a/acqui/basket.pl (-4 / +2 lines)
Lines 290-298 if ( $op eq 'delete_confirm' ) { Link Here
290
        push @basketusers, $basketuser if $basketuser;
290
        push @basketusers, $basketuser if $basketuser;
291
    }
291
    }
292
292
293
    #to get active currency
293
    my $active_currency = Koha::Acquisition::Currencies->get_active;
294
    my $cur = GetCurrency();
295
296
294
297
    my @orders = GetOrders( $basketno );
295
    my @orders = GetOrders( $basketno );
298
    my @books_loop;
296
    my @books_loop;
Lines 384-390 if ( $op eq 'delete_confirm' ) { Link Here
384
        total_gste           => sprintf( "%.2f", $total_gste ),
382
        total_gste           => sprintf( "%.2f", $total_gste ),
385
        total_gsti           => sprintf( "%.2f", $total_gsti ),
383
        total_gsti           => sprintf( "%.2f", $total_gsti ),
386
        total_gstvalue       => sprintf( "%.2f", $total_gstvalue ),
384
        total_gstvalue       => sprintf( "%.2f", $total_gstvalue ),
387
        currency             => $cur->{'currency'},
385
        currency             => $active_currency->currency,
388
        listincgst           => $bookseller->{listincgst},
386
        listincgst           => $bookseller->{listincgst},
389
        basketgroups         => $basketgroups,
387
        basketgroups         => $basketgroups,
390
        basketgroup          => $basketgroup,
388
        basketgroup          => $basketgroup,
(-)a/acqui/invoice.pl (-1 / +2 lines)
Lines 36-41 use C4::Acquisition; Link Here
36
use C4::Budgets;
36
use C4::Budgets;
37
37
38
use Koha::Acquisition::Bookseller;
38
use Koha::Acquisition::Bookseller;
39
use Koha::Acquisition::Currencies;
39
use Koha::Misc::Files;
40
use Koha::Misc::Files;
40
41
41
my $input = new CGI;
42
my $input = new CGI;
Lines 179-185 $template->param( Link Here
179
    total_gste_shipment => sprintf( $format, $total_gste + $details->{shipmentcost}),
180
    total_gste_shipment => sprintf( $format, $total_gste + $details->{shipmentcost}),
180
    total_gsti_shipment => sprintf( $format, $total_gsti + $details->{shipmentcost}),
181
    total_gsti_shipment => sprintf( $format, $total_gsti + $details->{shipmentcost}),
181
    invoiceincgst    => $bookseller->{invoiceincgst},
182
    invoiceincgst    => $bookseller->{invoiceincgst},
182
    currency         => GetCurrency()->{currency},
183
    currency         => Koha::Acquisition::Currency->get_active->currency,
183
    budgets_loop     => \@budgets_loop,
184
    budgets_loop     => \@budgets_loop,
184
);
185
);
185
186
(-)a/acqui/neworderempty.pl (-34 / +6 lines)
Lines 89-94 use C4::Search qw/FindDuplicate/; Link Here
89
use C4::ImportBatch qw/GetImportRecordMarc SetImportRecordStatus/;
89
use C4::ImportBatch qw/GetImportRecordMarc SetImportRecordStatus/;
90
90
91
use Koha::Acquisition::Bookseller;
91
use Koha::Acquisition::Bookseller;
92
use Koha::Acquisition::Currencies;
92
93
93
our $input           = new CGI;
94
our $input           = new CGI;
94
my $booksellerid    = $input->param('booksellerid');	# FIXME: else ERROR!
95
my $booksellerid    = $input->param('booksellerid');	# FIXME: else ERROR!
Lines 205-241 else { #modify order Link Here
205
my $suggestion;
206
my $suggestion;
206
$suggestion = GetSuggestionInfo($suggestionid) if $suggestionid;
207
$suggestion = GetSuggestionInfo($suggestionid) if $suggestionid;
207
208
208
# get currencies (for change rates calcs if needed)
209
my @currencies = Koha::Acquisition::Currencies->search;
209
my $active_currency = GetCurrency();
210
my $active_currency = Koha::Acquisition::Currencies->get_active;
210
my $default_currency;
211
if (! $data->{currency} ) { # New order no currency set
212
    if ( $bookseller->{listprice} ) {
213
        $default_currency = $bookseller->{listprice};
214
    }
215
    else {
216
        $default_currency = $active_currency->{currency};
217
    }
218
}
219
220
my @rates = GetCurrencies();
221
222
# ## @rates
223
224
my @loop_currency = ();
225
for my $curr ( @rates ) {
226
    my $selected;
227
    if ($data->{currency} ) {
228
        $selected = $curr->{currency} eq $data->{currency};
229
    }
230
    else {
231
        $selected = $curr->{currency} eq $default_currency;
232
    }
233
    push @loop_currency, {
234
        currcode => $curr->{currency},
235
        rate     => $curr->{rate},
236
        selected => $selected,
237
    }
238
}
239
211
240
# build branches list
212
# build branches list
241
my $onlymine =
213
my $onlymine =
Lines 376-384 $template->param( Link Here
376
    listincgst       => $bookseller->{'listincgst'},
348
    listincgst       => $bookseller->{'listincgst'},
377
    invoiceincgst    => $bookseller->{'invoiceincgst'},
349
    invoiceincgst    => $bookseller->{'invoiceincgst'},
378
    name             => $bookseller->{'name'},
350
    name             => $bookseller->{'name'},
379
    cur_active_sym   => $active_currency->{'symbol'},
351
    cur_active_sym   => $active_currency->symbol,
380
    cur_active       => $active_currency->{'currency'},
352
    cur_active       => $active_currency->currency,
381
    loop_currencies  => \@loop_currency,
353
    currencies       => \@currencies,
382
    orderexists      => ( $new eq 'yes' ) ? 0 : 1,
354
    orderexists      => ( $new eq 'yes' ) ? 0 : 1,
383
    title            => $data->{'title'},
355
    title            => $data->{'title'},
384
    author           => $data->{'author'},
356
    author           => $data->{'author'},
(-)a/acqui/supplier.pl (-21 / +3 lines)
Lines 53-58 use C4::Bookseller::Contact; Link Here
53
use C4::Budgets;
53
use C4::Budgets;
54
54
55
use Koha::Acquisition::Bookseller;
55
use Koha::Acquisition::Bookseller;
56
use Koha::Acquisition::Currencies;
56
57
57
my $query    = CGI->new;
58
my $query    = CGI->new;
58
my $op = $query->param('op') || 'display';
59
my $op = $query->param('op') || 'display';
Lines 76-82 if ($booksellerid) { Link Here
76
}
77
}
77
$template->{'VARS'}->{'contacts'} = C4::Bookseller::Contact->new() unless $template->{'VARS'}->{'contacts'};
78
$template->{'VARS'}->{'contacts'} = C4::Bookseller::Contact->new() unless $template->{'VARS'}->{'contacts'};
78
79
79
#build array for currencies
80
if ( $op eq 'display' ) {
80
if ( $op eq 'display' ) {
81
    my $contracts = GetContracts( { booksellerid => $booksellerid } );
81
    my $contracts = GetContracts( { booksellerid => $booksellerid } );
82
82
Lines 98-122 if ( $op eq 'display' ) { Link Here
98
    print $query->redirect('/cgi-bin/koha/acqui/acqui-home.pl');
98
    print $query->redirect('/cgi-bin/koha/acqui/acqui-home.pl');
99
    exit;
99
    exit;
100
} else {
100
} else {
101
    my @currencies = GetCurrencies();
101
    my @currencies = Koha::Acquisition::Currencies->search;
102
    my $loop_currency;
103
    my $active_currency = GetCurrency();
104
    my $active_listprice = $supplier->{'listprice'};
105
    my $active_invoiceprice = $supplier->{'invoiceprice'};
106
    if (!$supplier->{listprice}) {
107
        $active_listprice =  $active_currency->{currency};
108
    }
109
    if (!$supplier->{invoiceprice}) {
110
        $active_invoiceprice =  $active_currency->{currency};
111
    }
112
    for (@currencies) {
113
        push @{$loop_currency},
114
            { 
115
            currency     => $_->{currency},
116
            listprice    => ( $_->{currency} eq $active_listprice ),
117
            invoiceprice => ( $_->{currency} eq $active_invoiceprice ),
118
            };
119
    }
120
102
121
    # get option values from gist syspref
103
    # get option values from gist syspref
122
    my @gst_values = map {
104
    my @gst_values = map {
Lines 128-134 if ( $op eq 'display' ) { Link Here
128
        active       => $booksellerid ? $supplier->{'active'} : 1,
110
        active       => $booksellerid ? $supplier->{'active'} : 1,
129
        gstrate       => $supplier->{gstrate} ? $supplier->{'gstrate'}+0.0 : 0,
111
        gstrate       => $supplier->{gstrate} ? $supplier->{'gstrate'}+0.0 : 0,
130
        gst_values    => \@gst_values,
112
        gst_values    => \@gst_values,
131
        loop_currency => $loop_currency,
113
        currencies    => \@currencies,
132
        enter         => 1,
114
        enter         => 1,
133
    );
115
    );
134
}
116
}
(-)a/admin/aqbudgetperiods.pl (-3 / +4 lines)
Lines 57-62 use C4::Output; Link Here
57
use C4::Acquisition;
57
use C4::Acquisition;
58
use C4::Budgets;
58
use C4::Budgets;
59
use C4::Debug;
59
use C4::Debug;
60
use Koha::Acquisition::Currencies;
60
61
61
my $dbh = C4::Context->dbh;
62
my $dbh = C4::Context->dbh;
62
63
Lines 91-99 my ($template, $borrowernumber, $cookie, $staff_flags ) = get_template_and_user( Link Here
91
92
92
93
93
# This is used in incbudgets-active-currency.inc
94
# This is used in incbudgets-active-currency.inc
94
my $cur = GetCurrency();
95
my $active_currency = Koha::Acquisition::Currencies->get_active;
95
$template->param( symbol => $cur->{symbol},
96
$template->param( symbol => $active_currency->symbol,
96
                  currency => $cur->{currency}
97
                  currency => $active_currency->currency
97
               );
98
               );
98
99
99
# ADD OR MODIFY A BUDGET PERIOD - BUILD SCREEN
100
# ADD OR MODIFY A BUDGET PERIOD - BUILD SCREEN
(-)a/admin/aqbudgets.pl (-3 / +4 lines)
Lines 36-41 use C4::Context; Link Here
36
use C4::Output;
36
use C4::Output;
37
use C4::Koha;
37
use C4::Koha;
38
use C4::Debug;
38
use C4::Debug;
39
use Koha::Acquisition::Currencies;
39
40
40
my $input = new CGI;
41
my $input = new CGI;
41
my $dbh     = C4::Context->dbh;
42
my $dbh     = C4::Context->dbh;
Lines 50-58 my ($template, $borrowernumber, $cookie, $staffflags ) = get_template_and_user( Link Here
50
    }
51
    }
51
);
52
);
52
53
53
my $cur = GetCurrency();
54
my $active_currency = Koha::Acquisition::Currencies->get_active;
54
$template->param( symbol => $cur->{symbol},
55
$template->param( symbol => $active_currency->symbol,
55
                  currency => $cur->{currency}
56
                  currency => $active_currency->currency
56
               );
57
               );
57
58
58
my $op = $input->param('op') || 'list';
59
my $op = $input->param('op') || 'list';
(-)a/admin/aqplan.pl (-3 / +4 lines)
Lines 36-41 use C4::Output; Link Here
36
use C4::Koha;
36
use C4::Koha;
37
use C4::Auth;
37
use C4::Auth;
38
use C4::Debug;
38
use C4::Debug;
39
use Koha::Acquisition::Currencies;
39
40
40
my $input = new CGI;
41
my $input = new CGI;
41
####  $input
42
####  $input
Lines 57-65 my $budget_period_id = $input->param('budget_period_id'); Link Here
57
# IF PERIOD_ID IS DEFINED,  GET THE PERIOD - ELSE GET THE ACTIVE PERIOD BY DEFAULT
58
# IF PERIOD_ID IS DEFINED,  GET THE PERIOD - ELSE GET THE ACTIVE PERIOD BY DEFAULT
58
my $period = GetBudgetPeriod($budget_period_id);
59
my $period = GetBudgetPeriod($budget_period_id);
59
my $count  = GetPeriodsCount();
60
my $count  = GetPeriodsCount();
60
my $cur    = GetCurrency;
61
my $active_currency = Koha::Acquisition::Currencies->get_active;
61
$template->param( symbol => $cur->{symbol},
62
$template->param( symbol => $active_currency->symbol,
62
                  currency => $cur->{currency}
63
                  currency => $active_currency->currency,
63
               );
64
               );
64
$template->param( period_button_only => 1 ) if $count == 0;
65
$template->param( period_button_only => 1 ) if $count == 0;
65
66
(-)a/admin/preferences.pl (-3 / +3 lines)
Lines 28-34 use C4::ClassSource; Link Here
28
use C4::Log;
28
use C4::Log;
29
use C4::Output;
29
use C4::Output;
30
use C4::Templates;
30
use C4::Templates;
31
use C4::Budgets qw(GetCurrency);
31
use Koha::Acquisition::Currencies;
32
use File::Spec;
32
use File::Spec;
33
use IO::File;
33
use IO::File;
34
use YAML::Syck qw();
34
use YAML::Syck qw();
Lines 45-54 sub GetTab { Link Here
45
45
46
    my $tab_template = C4::Templates::gettemplate( 'admin/preferences/' . $tab . '.pref', 'intranet', $input );
46
    my $tab_template = C4::Templates::gettemplate( 'admin/preferences/' . $tab . '.pref', 'intranet', $input );
47
47
48
    my $active_currency = GetCurrency();
48
    my $active_currency = Koha::Acquisition::Currencies->get_active;
49
    my $local_currency;
49
    my $local_currency;
50
    if ($active_currency) {
50
    if ($active_currency) {
51
        $local_currency = $active_currency->{currency};
51
        $local_currency = $active_currency->currency;
52
    }
52
    }
53
    $tab_template->param(
53
    $tab_template->param(
54
        local_currency => $local_currency, # currency code is used, because we do not know how a given currency is formatted.
54
        local_currency => $local_currency, # currency code is used, because we do not know how a given currency is formatted.
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt (-9 / +5 lines)
Lines 187-196 Link Here
187
                        <input type="hidden" name="import_batch_id" value="[%import_batch_id %]" />
187
                        <input type="hidden" name="import_batch_id" value="[%import_batch_id %]" />
188
                        <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
188
                        <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
189
189
190
                        [% FOREACH cur IN loop_currencies %]
191
                            <input type="hidden" name="[% cur.currency %]" value="[% cur.rate %]" />
192
                        [% END %]
193
194
                        [% FOREACH biblio IN biblio_list %]
190
                        [% FOREACH biblio IN biblio_list %]
195
                        <fieldset class="biblio unselected rows" style="float:none;">
191
                        <fieldset class="biblio unselected rows" style="float:none;">
196
                          <legend>
192
                          <legend>
Lines 334-344 Link Here
334
                                        <li>
330
                                        <li>
335
                                            <label for="all_currency">Currency:</label>
331
                                            <label for="all_currency">Currency:</label>
336
                                            <select name="all_currency" id="all_currency">
332
                                            <select name="all_currency" id="all_currency">
337
                                            [% FOREACH loop_currencie IN loop_currencies %]
333
                                            [% FOREACH currency IN currencies %]
338
                                                [% IF ( loop_currencie.selected ) %]
334
                                                [% IF currency.currency == bookseller.listprice %]
339
                                                    <option value="[% loop_currencie.currcode %]" selected="selected">[% loop_currencie.currcode %]</option>
335
                                                    <option value="[% currency.currency %]" selected="selected">[% currency.currency %]</option>
340
                                                [% ELSE %]
336
                                                [% ELSIF not currency.archived %]
341
                                                    <option value="[% loop_currencie.currcode %]">[% loop_currencie.currcode %]</option>
337
                                                    <option value="[% currency.currency %]">[% currency.currency %]</option>
342
                                                [% END %]
338
                                                [% END %]
343
                                            [% END %]
339
                                            [% END %]
344
                                            </select>
340
                                            </select>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt (-6 / +11 lines)
Lines 303-310 $(document).ready(function() Link Here
303
        <input type="hidden" name="suggestionid" value="[% suggestionid %]" />
303
        <input type="hidden" name="suggestionid" value="[% suggestionid %]" />
304
        <input type="hidden" name="import_batch_id" value="[% import_batch_id %]" />
304
        <input type="hidden" name="import_batch_id" value="[% import_batch_id %]" />
305
305
306
        [% FOREACH loop_currencie IN loop_currencies %]
306
        [% FOREACH currency IN currencies %]
307
            <input type="hidden" id="currency_rate_[% loop_currencie.currcode %]"  name="[% loop_currencie.currcode %]" value="[% loop_currencie.rate %]" />
307
            <input type="hidden" id="currency_rate_[% currency.currency %]"  name="[% currency.currency %]" value="[% currency.rate %]" />
308
        [% END %]
308
        [% END %]
309
309
310
        <ol><li>
310
        <ol><li>
Lines 523-532 $(document).ready(function() Link Here
523
            <input type="hidden" name="currency" id="currency" value="[% currency %]" />[% currency %]
523
            <input type="hidden" name="currency" id="currency" value="[% currency %]" />[% currency %]
524
                [% ELSE %]
524
                [% ELSE %]
525
			<label for="currency">Currency:</label>
525
			<label for="currency">Currency:</label>
526
			<select name="currency" id="currency" onchange="updateCosts();">
526
            <select name="currency" id="currency" onchange="updateCosts();">
527
			[% FOREACH loop_currencie IN loop_currencies %]
527
                [% FOREACH currency IN currencies %]
528
	                [% 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 %]
528
                    [% IF ordernumber and currency.currency == listprice or not ordernumber and currency.active %]
529
			</select>
529
                        <option value="[% currency.currency %]" selected="selected">[% currency.currency %]</option>
530
                    [% ELSIF not currency.archived %]
531
                        <option value="[% currency.currency %]">[% currency.currency %]</option>
532
                    [% END %]
533
                [% END %]
534
            </select>
530
		[% END %]
535
		[% END %]
531
                </li>
536
                </li>
532
            <li>
537
            <li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt (-10 / +16 lines)
Lines 221-240 function delete_contact(ev) { Link Here
221
            </ol>
221
            </ol>
222
            <ol>
222
            <ol>
223
            <li><label for="list_currency">List prices are: </label>
223
            <li><label for="list_currency">List prices are: </label>
224
                    <select name="list_currency" id="list_currency">
224
                <select name="list_currency" id="list_currency">
225
                    [% FOREACH loop_currenc IN loop_currency %]
225
                    [% FOREACH currency IN currencies %]
226
                        [% IF ( loop_currenc.listprice ) %]<option value="[% loop_currenc.currency %]" selected="selected">[% loop_currenc.currency %]</option>
226
                        [% IF booksellerid and currency.currency == listprice or not booksellerid and currency.active %]
227
                        [% ELSE %]<option value="[% loop_currenc.currency %]">[% loop_currenc.currency %]</option>[% END %]
227
                            <option value="[% currency.currency %]" selected="selected">[% currency.currency %]</option>
228
                        [% ELSIF not currency.archived %]
229
                            <option value="[% currency.currency %]" selected="selected">[% currency.currency %]</option>
230
                        [% END %]
228
                    [% END %]
231
                    [% END %]
229
                    </select>
232
                </select>
230
            </li>
233
            </li>
231
            <li><label for="invoice_currency">Invoice prices are: </label>
234
            <li><label for="invoice_currency">Invoice prices are: </label>
232
                    <select name="invoice_currency" id="invoice_currency">
235
                <select name="invoice_currency" id="invoice_currency">
233
                    [% FOREACH loop_currenc IN loop_currency %]
236
                    [% FOREACH currency IN currencies %]
234
                        [% IF ( loop_currenc.invoiceprice ) %]<option value="[% loop_currenc.currency %]" selected="selected">[% loop_currenc.currency %]</option>
237
                        [% IF booksellerid and currency.currency == invoiceprice or not booksellerid and currency.active %]
235
                        [% ELSE %]<option value="[% loop_currenc.currency %]">[% loop_currenc.currency %]</option>[% END %]
238
                            <option value="[% currency.currency %]" selected="selected">[% currency.currency %]</option>
239
                        [% ELSIF not currency.archived %]
240
                            <option value="[% currency.currency %]" selected="selected">[% currency.currency %]</option>
241
                        [% END %]
236
                    [% END %]
242
                    [% END %]
237
                    </select>
243
                </select>
238
            </li>
244
            </li>
239
            </ol>
245
            </ol>
240
            <ol class="radio">
246
            <ol class="radio">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt (+2 lines)
Lines 178-183 Link Here
178
            <th>ISO code</th>
178
            <th>ISO code</th>
179
            <th class="title-string">Last updated</th>
179
            <th class="title-string">Last updated</th>
180
            <th>Active</th>
180
            <th>Active</th>
181
            <th>Archived</th>
181
            <th>Actions</th>
182
            <th>Actions</th>
182
        </tr>
183
        </tr>
183
      </thead>
184
      </thead>
Lines 190-195 Link Here
190
            <td>[% currency.isocode |html %]</td>
191
            <td>[% currency.isocode |html %]</td>
191
            <td><span title="[% currency.timestamp %]">[% currency.timestamp | $KohaDates %]</span></td>
192
            <td><span title="[% currency.timestamp %]">[% currency.timestamp | $KohaDates %]</span></td>
192
            <td style="color:green;">[% IF currency.active %]✓[% END %]</td>
193
            <td style="color:green;">[% IF currency.active %]✓[% END %]</td>
194
            <td>[% IF currency.archived %]Yes[% END %]</td>
193
            <td>
195
            <td>
194
              <a href="/cgi-bin/koha/admin/currency.pl?op=add_form&amp;currency_code=[% currency.currency %]">Edit</a>
196
              <a href="/cgi-bin/koha/admin/currency.pl?op=add_form&amp;currency_code=[% currency.currency %]">Edit</a>
195
              |
197
              |
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt (-10 / +19 lines)
Lines 427-442 h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o Link Here
427
            </select>
427
            </select>
428
		</li><li><label for="quantity">Copies:</label>
428
		</li><li><label for="quantity">Copies:</label>
429
			<input type="text" size="10" id="quantity" name="quantity" value="[% quantity %]" onchange="calcNewsuggTotal();" />
429
			<input type="text" size="10" id="quantity" name="quantity" value="[% quantity %]" onchange="calcNewsuggTotal();" />
430
                </li><li><label for="currency">Currency:</label>
430
                </li>
431
		        [% FOREACH loop_currenc IN loop_currency %]
431
                <li>
432
                    <input type="hidden" value="[% loop_currenc.rate %]" id="currency_rate_[% loop_currenc.currcode %]" name="currency_rate_[% loop_currenc.currcode %]" />
432
                    <label for="currency">Currency:</label>
433
		            <input type="hidden" id="[% loop_currenc.currcode %]" name="[% loop_currenc.currcode %]" value="[% loop_currenc.rate %]" />
433
                    [% FOREACH c IN currencies %]
434
		        [% END %]
434
                        <input type="hidden" value="[% c.rate %]" id="currency_rate_[% c.currency %]" name="currency_rate_[% c.currency %]" />
435
            <select name="currency" id="currency" onchange="calcNewsuggTotal();">
435
                        <input type="hidden" id="[% c.currency %]" name="[% c.currency %]" value="[% c.rate %]" />
436
                [% FOREACH loop_currenc IN loop_currency %]
436
                    [% END %]
437
                [% 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 %]
437
438
            </select>
438
                    <select name="currency" id="currency" onchange="calcNewsuggTotal();">
439
                </li><li><label for="price">Price:</label>
439
                        [% FOREACH c IN currencies %]
440
                            [% IF suggestionid and suggestion.currency == c.currency or not suggestionid and c.active %]
441
                                <option value="[% c.currency %]" selected="selected">[% c.currency %]</option>
442
                            [% ELSIF not c.archived %]
443
                                <option value="[% c.currency %]">[% c.currency %]</option>
444
                            [% END %]
445
                        [% END %]
446
                    </select>
447
                </li>
448
                <li><label for="price">Price:</label>
440
			<input type="text" size="20" name="price" id="price" value="[% price %]" onchange="calcNewsuggTotal();" />
449
			<input type="text" size="20" name="price" id="price" value="[% price %]" onchange="calcNewsuggTotal();" />
441
                </li><li><label for="total">Total: </label>
450
                </li><li><label for="total">Total: </label>
442
			<input type="text" readonly="readonly" id="total" name="total" size="10" value="[% total %]"/>
451
			<input type="text" readonly="readonly" id="total" name="total" size="10" value="[% total %]"/>
(-)a/misc/cronjobs/overdue_notices.pl (-3 / +3 lines)
Lines 42-51 use C4::Dates qw/format_date/; Link Here
42
use C4::Debug;
42
use C4::Debug;
43
use C4::Letters;
43
use C4::Letters;
44
use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes);
44
use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes);
45
use C4::Budgets qw(GetCurrency);
46
use Koha::Borrower::Debarments qw(AddUniqueDebarment);
45
use Koha::Borrower::Debarments qw(AddUniqueDebarment);
47
use Koha::DateUtils;
46
use Koha::DateUtils;
48
use Koha::Calendar;
47
use Koha::Calendar;
48
use Koha::Acquisition::Currencies;
49
use C4::Log;
49
use C4::Log;
50
50
51
=head1 NAME
51
=head1 NAME
Lines 860-868 sub parse_letter { Link Here
860
        $tables{'branches'} = $p;
860
        $tables{'branches'} = $p;
861
    }
861
    }
862
862
863
    my $currencies = GetCurrency();
863
    my $active_currency = Koha::Acquisition::Currencies->get_active;
864
    my $currency_format;
864
    my $currency_format;
865
    $currency_format = $currencies->{currency} if defined($currencies);
865
    $currency_format = $active_currency->currency if defined($active_currency);
866
866
867
    my @item_tables;
867
    my @item_tables;
868
    if ( my $i = $params->{'items'} ) {
868
    if ( my $i = $params->{'items'} ) {
(-)a/opac/sco/sco-main.pl (-2 / +3 lines)
Lines 45-50 use C4::Output; Link Here
45
use C4::Members;
45
use C4::Members;
46
use C4::Biblio;
46
use C4::Biblio;
47
use C4::Items;
47
use C4::Items;
48
use Koha::Acquisition::Currencies;
48
49
49
my $query = new CGI;
50
my $query = new CGI;
50
51
Lines 113-120 if (C4::Context->preference('SelfCheckoutByLogin') && !$patronid) { Link Here
113
my $borrower = GetMemberDetails(undef,$patronid);
114
my $borrower = GetMemberDetails(undef,$patronid);
114
115
115
my $currencySymbol = "";
116
my $currencySymbol = "";
116
if ( defined C4::Budgets->GetCurrency() ) {
117
if ( my $active_currency = Koha::Acquisition::Currencies->get_active ) {
117
    $currencySymbol = C4::Budgets->GetCurrency()->{symbol};
118
    $currencySymbol = $active_currency->symbol;
118
}
119
}
119
120
120
my $branch = $issuer->{branchcode};
121
my $branch = $issuer->{branchcode};
(-)a/suggestion/suggestion.pl (-21 / +4 lines)
Lines 32-37 use C4::Members; Link Here
32
use C4::Debug;
32
use C4::Debug;
33
33
34
use Koha::DateUtils qw( dt_from_string );
34
use Koha::DateUtils qw( dt_from_string );
35
use Koha::Acquisition::Currencies;
35
36
36
use URI::Escape;
37
use URI::Escape;
37
38
Lines 367-394 foreach my $budget ( @{$budgets} ) { Link Here
367
$template->param( budgetsloop => \@budgets_loop);
368
$template->param( budgetsloop => \@budgets_loop);
368
$template->param( "statusselected_$$suggestion_ref{'STATUS'}" =>1) if ($$suggestion_ref{'STATUS'});
369
$template->param( "statusselected_$$suggestion_ref{'STATUS'}" =>1) if ($$suggestion_ref{'STATUS'});
369
370
370
# get currencies and rates
371
my @currencies = Koha::Acquisition::Currencies->search;
371
my @rates = GetCurrencies();
372
my $count = scalar @rates;
373
my $active_currency = GetCurrency();
374
my $selected_currency;
375
if ($$suggestion_ref{'currency'}) {
376
    $selected_currency = $$suggestion_ref{'currency'};
377
}
378
else {
379
    $selected_currency = $active_currency->{currency};
380
}
381
382
my @loop_currency = ();
383
for ( my $i = 0 ; $i < $count ; $i++ ) {
384
    my %line;
385
    $line{currcode} = $rates[$i]->{'currency'};
386
    $line{rate}     = $rates[$i]->{'rate'};
387
    $line{selected} = 1 if ($line{'currcode'} eq $selected_currency);
388
    push @loop_currency, \%line;
389
}
390
$template->param(
372
$template->param(
391
    loop_currency => \@loop_currency,
373
    currencies   => \@currencies,
374
    suggestion   => $suggestion_ref,
392
    price        => sprintf("%.2f", $$suggestion_ref{'price'}||0),
375
    price        => sprintf("%.2f", $$suggestion_ref{'price'}||0),
393
    total            => sprintf("%.2f", $$suggestion_ref{'total'}||0),
376
    total            => sprintf("%.2f", $$suggestion_ref{'total'}||0),
394
);
377
);
(-)a/t/Number/Price.t (-7 / +7 lines)
Lines 5-14 use Test::More tests => 19; Link Here
5
use Test::MockModule;
5
use Test::MockModule;
6
use t::lib::Mocks;
6
use t::lib::Mocks;
7
7
8
use C4::Budgets;
8
use Koha::Acquisition::Currencies;
9
my $budget_module = Test::MockModule->new('C4::Budgets');
9
my $budget_module = Test::MockModule->new('Koha::Acquisition::Currencies');
10
my $currency;
10
my $currency;
11
$budget_module->mock( 'GetCurrency', sub { return $currency; } );
11
$budget_module->mock( 'get_active', sub { return $currency; } );
12
use_ok('Koha::Number::Price');
12
use_ok('Koha::Number::Price');
13
13
14
my $format = {
14
my $format = {
Lines 16-27 my $format = { Link Here
16
    p_sep_by_space => 0, # Force to not add a space between the symbol and the number
16
    p_sep_by_space => 0, # Force to not add a space between the symbol and the number
17
};
17
};
18
t::lib::Mocks::mock_preference( 'CurrencyFormat', 'US' );
18
t::lib::Mocks::mock_preference( 'CurrencyFormat', 'US' );
19
$currency = {
19
$currency = Koha::Acquisition::Currency->new({
20
    currency => 'USD',
20
    currency => 'USD',
21
    symbol   => '$',
21
    symbol   => '$',
22
    rate     => 1,
22
    rate     => 1,
23
    active   => 1,
23
    active   => 1,
24
};
24
});
25
25
26
is( Koha::Number::Price->new->format( $format ),    '0.00', 'US: format 0' );
26
is( Koha::Number::Price->new->format( $format ),    '0.00', 'US: format 0' );
27
is( Koha::Number::Price->new(3)->format( $format ), '3.00', 'US: format 3' );
27
is( Koha::Number::Price->new(3)->format( $format ), '3.00', 'US: format 3' );
Lines 45-56 is( Koha::Number::Price->new(1234567890)->unformat, Link Here
45
    '1234567890', 'US: unformat 1234567890' );
45
    '1234567890', 'US: unformat 1234567890' );
46
46
47
t::lib::Mocks::mock_preference( 'CurrencyFormat', 'FR' );
47
t::lib::Mocks::mock_preference( 'CurrencyFormat', 'FR' );
48
$currency = {
48
$currency = Koha::Acquisition::Currency->new({
49
    currency => 'EUR',
49
    currency => 'EUR',
50
    symbol   => '€',
50
    symbol   => '€',
51
    rate     => 1,
51
    rate     => 1,
52
    active   => 1,
52
    active   => 1,
53
};
53
});
54
54
55
# Actually,the price formating for France is 3,00€
55
# Actually,the price formating for France is 3,00€
56
# How put the symbol at the end with Number::Format?
56
# How put the symbol at the end with Number::Format?
(-)a/t/db_dependent/Biblio.t (-5 / +13 lines)
Lines 37-47 my $context = new Test::MockModule('C4::Context'); Link Here
37
37
38
mock_marcfromkohafield();
38
mock_marcfromkohafield();
39
39
40
my $currency = new Test::MockModule('C4::Budgets');
40
my $currency = new Test::MockModule('Koha::Acquisition::Currencies');
41
$currency->mock( 'GetCurrency', sub {
41
$currency->mock(
42
    return { symbol   => '$',   isocode  => 'USD',
42
    'get_active',
43
             currency => 'USD', active => 1 };
43
    sub {
44
});
44
        return Koha::Acquisition::Currency->new(
45
            {   symbol   => '$',
46
                isocode  => 'USD',
47
                currency => 'USD',
48
                active   => 1,
49
            }
50
        );
51
    }
52
);
45
53
46
sub run_tests {
54
sub run_tests {
47
55
(-)a/t/db_dependent/MungeMarcPrice.t (-4 / +3 lines)
Lines 3-9 Link Here
3
use strict;
3
use strict;
4
use warnings;
4
use warnings;
5
use C4::Biblio;
5
use C4::Biblio;
6
use C4::Budgets;
6
use Koha::Acquisition::Currencies;
7
use Test::More;
7
use Test::More;
8
use utf8;
8
use utf8;
9
9
Lines 39-48 my $ISOCODE = 'USD'; Link Here
39
my $RATE= 1;
39
my $RATE= 1;
40
40
41
# disables existing active currency if necessary.
41
# disables existing active currency if necessary.
42
my $active_currency = C4::Budgets->GetCurrency();
42
my $active_currency = Koha::Acquisition::Currencies->get_active;
43
my $curr;
43
my $curr;
44
if ($active_currency) {
44
if ($active_currency) {
45
    $curr = $active_currency->{'currency'};
45
    $curr = $active_currency->currency;
46
    $dbh->do("UPDATE currency set active = 0 where currency = '$curr'");
46
    $dbh->do("UPDATE currency set active = 0 where currency = '$curr'");
47
}
47
}
48
48
49
- 

Return to bug 15084