Fix: [ bug #1372 ] Margin calculation does not work in proposals

This commit is contained in:
Laurent Destailleur 2014-05-10 19:52:24 +02:00
parent 3fd7e18c08
commit 7bb24969d8
3 changed files with 11 additions and 3 deletions

View File

@ -21,6 +21,7 @@ Fix: [ bug #1362 ] Note is not saved.
Fix: tr/td balance.
Fix: [ bug #1360 ] note indicator for member tab.
Fix: Nb of notes and doc not visible onto tasks.
Fix: [ bug #1372 ] Margin calculation does not work in proposals
***** ChangeLog for 3.5.2 compared to 3.5.1 *****
Fix: Can't add user for a task.

View File

@ -252,8 +252,10 @@ if (! empty($usemargins) && $user->rights->margins->creer)
var remise = $("input[name='remise_percent']:first");
var rate = $("input[name='"+npRate+"']:first");
if (rate.val() == '')
return true;
if (! $.isNumeric(rate.val().replace(',','.')))
{
alert('<?php echo dol_escape_js($langs->trans("rateMustBeNumeric")); ?>');
@ -274,12 +276,13 @@ if (! empty($usemargins) && $user->rights->margins->creer)
if (remisejs != 100)
{
if (remisejs == '') remisejs=0;
bpjs=price2numjs(buying_price.val());
ratejs=price2numjs(rate.val());
if (npRate == "marginRate")
if (npRate == "np_marginRate")
price = ((bpjs * (1 + ratejs / 100)) / (1 - remisejs / 100));
else if (npRate == "markRate")
else if (npRate == "np_markRate")
price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100));
}
$("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value
@ -291,6 +294,8 @@ if (! empty($usemargins) && $user->rights->margins->creer)
/* Function similar to price2num in PHP */
function price2numjs(num)
{
if (num == '') return '';
<?php
$dec=','; $thousand=' ';
if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->transnoentitiesnoconv("SeparatorDecimal");

View File

@ -298,6 +298,8 @@ if (! empty($usemargins) && $user->rights->margins->creer)
/* Function similar to price2num in PHP */
function price2numjs(num)
{
if (num == '') return '';
<?php
$dec=','; $thousand=' ';
if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->transnoentitiesnoconv("SeparatorDecimal");