<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi all:<br>
<br>
I've opened Ticket #2436, relative to an error when you have a
percentage discount on product details in an invoice.<br>
<br>
When you have a percentage discount and change quantity or price the
discount does'nt update and when you save the total price is not good.<br>
<br>
To solve this i've proposed that:<br>
<br>
<p>The "easy" way to fix, i think, is add to template the behavior when
the inputs change. I propose:
</p>
<p>
on <strong>VTIGER_PATH/Smarty/templates/Inventory/ProductDetailsEditView.tpl</strong>,
add on lines 195 and 204: <i>onchange="setDiscount(this,{$row_no});"</i>
</p>
<p>
<strong>line 195:</strong> &lt;input id="{$qty}" name="{$qty}"
type="text" class="small " style="width:50px"
onfocus="this.className='detailedViewTextBoxOn'"
onBlur="FindDuplicate(); settotalnoofrows(); calcTotal();
loadTaxes_Ajax('{$row_no}');" onchange="setDiscount(this,{$row_no});"
value="{$data.$qty}"/&gt;
</p>
<p>
<strong>line 204:</strong> &lt;input id="{$listPrice}"
name="{$listPrice}" value="{$data.$listPrice}" type="text" class="small
" style="width:70px" onBlur=" calcTotal(); callTaxCalc('{$row_no}');"
onchange="setDiscount(this,{$row_no});"/&gt;&amp;nbsp;&lt;img
src="{$IMAGE_PATH}pricebook.gif"
onclick="priceBookPickList(this,'{$row_no}')"&gt;
</p>
<p>
On this way when intput blur it calculates the total price and if it
has changed it calculates the discout also.
</p>
<p>
Another way is to refactoring calculations functions on Inventory.js
because now it's no possible include <i>setDiscount()</i> on <i>calcTotal()</i>,
<i>setDiscount()</i> call to <i>calcTotal()</i> and it will perform a
"killer loop" ;-)
</p>
<br>
<pre class="moz-signature" cols="72">-- 
Kiko Jover
Linux User #354256
JPL TSolucio S.L.</pre>
</body>
</html>