Bug 9346 - acqui/neworderempty.pl ignores exchange rates and destroys user data on page load

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

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Elliott Davis <elliott@bywatersolions.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
This commit is contained in:
Dobrica Pavlinusic 2013-01-03 23:38:17 +01:00 committed by Jared Camins-Esakov
parent 1005ad9b5f
commit 5ee5693410
3 changed files with 9 additions and 7 deletions

View file

@ -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'},

View file

@ -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);

View file

@ -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 ) %]