Bug 4161: Preselect active currency for new vendors
authorKatrin Fischer <Katrin.Fischer.83@web.de>
Mon, 24 Oct 2011 15:48:29 +0000 (17:48 +0200)
committerPaul Poulain <paul.poulain@biblibre.com>
Wed, 16 Nov 2011 16:46:08 +0000 (17:46 +0100)
Currently when creating a new vendor in acquisitions the alphabetical first
currency will be preselected. For better usability and less mistakes the
active curency should be preselected.

To test:
Check your currency settings in administration.
Your active currency should not be the first in the list.

1) Create a new vendor
Verify the active currency is selected for list and invoice prices.

2) Check vendor summary page
Verify the correct currencies from the vendor record are shown here.

3) Edit vendor
Verify the correct currencies from the vendor record  are shown here.

Signed-off-by: Liz Rea <lrea@nekls.org>
Verified with tests 1, 2, and 3.

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
acqui/supplier.pl

index 2a4078a..44ff250 100755 (executable)
@@ -122,12 +122,22 @@ if ( $op eq 'display' ) {
 } 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 $supplier->{listprice} ),
-            invoiceprice => ( $_->{currency} eq $supplier->{invoiceprice} ),
-          };
+            { 
+            currency     => $_->{currency},
+            listprice    => ( $_->{currency} eq $active_listprice ),
+            invoiceprice => ( $_->{currency} eq $active_invoiceprice ),
+            };
     }
 
     my $default_gst_rate = (C4::Context->preference('gist') * 100) || '0.0';