[Koha-patches] [PATCH 2/2] [SIGNED-OFF] Bug 5466 On new orders get currency from vendor

Julian Maurice julian.maurice at biblibre.com
Fri Mar 18 17:11:02 CET 2011


From: Colin Campbell <colin.campbell at ptfs-europe.com>

Previous patch for this bug was ignoring vendor currency on
new orders. In most cases should be the default

Changed variable name from cur to active_currency
Clarity is a virtue!

Signed-off-by: Julian Maurice <julian.maurice at biblibre.com>
---
 acqui/neworderempty.pl |   37 ++++++++++++++++++++++++++-----------
 1 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl
index 1e90b92..0ba7180 100755
--- a/acqui/neworderempty.pl
+++ b/acqui/neworderempty.pl
@@ -173,7 +173,6 @@ if ( $ordernumber eq '' and defined $params->{'breedingid'}){
 }
 
 
-my $cur = GetCurrency();
 
 if ( $ordernumber eq '' ) {    # create order
     $new = 'yes';
@@ -201,18 +200,35 @@ else {    #modify order
 }
 
 # 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();
-my $count = scalar @rates;
 
 # ## @rates
 
 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 $data->{currency});
-    push @loop_currency, \%line;
+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,
+    }
 }
 
 # build branches list
@@ -341,9 +357,8 @@ $template->param(
     listincgst       => $bookseller->{'listincgst'},
     invoiceincgst    => $bookseller->{'invoiceincgst'},
     name             => $bookseller->{'name'},
-    cur_active_sym   => $cur->{'symbol'},
-    cur_active       => $cur->{'currency'},
-#    currency         => $bookseller->{'listprice'} || $cur->{'currency'}, # eg: 'EUR'
+    cur_active_sym   => $active_currency->{'symbol'},
+    cur_active       => $active_currency->{'currency'},
     loop_currencies  => \@loop_currency,
     orderexists      => ( $new eq 'yes' ) ? 0 : 1,
     title            => $data->{'title'},
-- 
1.7.4.1



More information about the Koha-patches mailing list