diff --git a/ChangeLog b/ChangeLog index 720c4680f2c..cc38390b9fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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. diff --git a/htdocs/core/tpl/freeproductline_create.tpl.php b/htdocs/core/tpl/freeproductline_create.tpl.php index 41eccdddda9..a4c4b733fed 100644 --- a/htdocs/core/tpl/freeproductline_create.tpl.php +++ b/htdocs/core/tpl/freeproductline_create.tpl.php @@ -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('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 ''; + transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->transnoentitiesnoconv("SeparatorDecimal"); diff --git a/htdocs/core/tpl/predefinedproductline_create.tpl.php b/htdocs/core/tpl/predefinedproductline_create.tpl.php index acd06c807d3..68126cb1924 100644 --- a/htdocs/core/tpl/predefinedproductline_create.tpl.php +++ b/htdocs/core/tpl/predefinedproductline_create.tpl.php @@ -298,6 +298,8 @@ if (! empty($usemargins) && $user->rights->margins->creer) /* Function similar to price2num in PHP */ function price2numjs(num) { + if (num == '') return ''; + transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->transnoentitiesnoconv("SeparatorDecimal");