[Koha-patches] [PATCH] Bug 9346 - acqui/neworderempty.pl ignores exchange rates and destroys user data on page load

Dobrica Pavlinusic dpavlin at rot13.org
Fri Jan 4 00:41:47 CET 2013


This restores behaviour of new order form before Bug 5335 merge

Test scenario:

1. load Receipt summary for existing customer
2. take note of Unit cost and Order cost
3. open existing order line and verify that Replacement cost,
   Budgeted cost and Total are not re-calculated on page load
4. change currency and verify that costs are updated
   (change currency to system default and all values should become
   same as vendor price)
5. change Quantity, get alert "You can't add a new item, please create a new order line"
   and verify that Total still reflects correct value
---
 acqui/neworderempty.pl                             |    3 ---
 koha-tmpl/intranet-tmpl/prog/en/js/acq.js          |    5 +++--
 .../prog/en/modules/acqui/neworderempty.tt         |    8 ++++++--
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl
index 90b4732..807a82b 100755
--- a/acqui/neworderempty.pl
+++ b/acqui/neworderempty.pl
@@ -336,8 +336,6 @@ my @gst_values = map {
     option => $_
 }, split( '\|', C4::Context->preference("gist") );
 
-my $cur = GetCurrency();
-
 $template->param(
     existing         => $biblionumber,
     ordernumber           => $ordernumber,
@@ -371,7 +369,6 @@ $template->param(
     cur_active_sym   => $active_currency->{'symbol'},
     cur_active       => $active_currency->{'currency'},
     loop_currencies  => \@loop_currency,
-    currency_rate    => $cur->{rate},
     orderexists      => ( $new eq 'yes' ) ? 0 : 1,
     title            => $data->{'title'},
     author           => $data->{'author'},
diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js b/koha-tmpl/intranet-tmpl/prog/en/js/acq.js
index d67b05b..0c3ce91 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js
+++ b/koha-tmpl/intranet-tmpl/prog/en/js/acq.js
@@ -644,7 +644,8 @@ function updateCosts(){
     var discount = new Number($("#discount").val());
     var applygst = new Number ($("#applygst").val());
     var listprice   =  new Number($("#listprice").val());
-    var exchangerate =  new Number($("#currency_rate").val());
+    var currcode = new String($("#currency").val());
+    var exchangerate =  new Number($("#currency_rate_"+currcode).val());
     var gst_on=false;
 
     var rrp   = new Number(listprice*exchangerate);
@@ -669,7 +670,7 @@ function calcNewsuggTotal(){
 //    var currency = f.currency.value;
     var currcode = new String(document.getElementById('currency').value);
     var price   =  new Number(document.getElementById('price').value);
-    var exchangerate =  new Number(document.getElementById(currcode).value);
+    var exchangerate =  new Number(document.getElementById('currency_rate_'+currcode).value);
 
     var total =  new Number(quantity*price*exchangerate);
 
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 2631e3c..398a568 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt
@@ -125,6 +125,7 @@ $(document).ready(function()
                 alert(_("You can't add a new item, please create a new order line"));
                 // and we replace the original value
                 $(this).val([% quantityrec %])
+                updateCosts(); // blur is invoked after change which updated values
                 return false;
             }
         });
@@ -146,7 +147,7 @@ $(document).ready(function()
 //]]>
 </script>
 </head>
-<body id="acq_neworderempty" class="acq" onload="updateCosts()">
+<body id="acq_neworderempty" class="acq">
 
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'acquisitions-search.inc' %]
@@ -230,7 +231,10 @@ $(document).ready(function()
         <input type="hidden" name="invoiceincgst" id="invoiceincgst" value="[% invoiceincgst %]" />
         <input type="hidden" name="suggestionid" value="[% suggestionid %]" />
         <input type="hidden" name="import_batch_id" value="[% import_batch_id %]" />
-        <input type="hidden" name="currency_rate" id="currency_rate" value="[% currency_rate %]" />
+
+        [% FOREACH loop_currencie IN loop_currencies %]
+            <input type="hidden" id="currency_rate_[% loop_currencie.currcode %]"  name="[% loop_currencie.currcode %]" value="[% loop_currencie.rate %]" />
+        [% END %]
 
         <ol><li>
             [% IF ( biblionumber ) %]
-- 
1.7.2.5



More information about the Koha-patches mailing list