From c3fb14855be5c49172dedc451dddc4bcfded8a4e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 20 Aug 2015 03:38:21 +0200 Subject: [PATCH] Try a better fix to replace PR #3297 --- htdocs/core/tpl/objectline_edit.tpl.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index f7bcf4ed091..bb75b007524 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -278,7 +278,7 @@ if (! empty($conf->margin->enabled)) var remise = $("input[name='remise_percent']:first"); var rate = $("input[name='"+npRate+"']:first"); - if (rate.val() == '') return true; + if (rate.val() == '' || (typeof rate.val()) == 'undefined' ) return true; if (! $.isNumeric(rate.val().replace(',','.'))) { @@ -287,7 +287,7 @@ if (! empty($conf->margin->enabled)) setTimeout(function () { rate.focus() }, 50); return false; } - if (npRate == "markRate" && rate.val() >= 100) + if (npRate == "np_markRate" && rate.val() >= 100) { alert('trans("markRateShouldBeLesserThan100"); ?>'); e.stopPropagation(); @@ -303,9 +303,11 @@ if (! empty($conf->margin->enabled)) bpjs=price2numjs(buying_price.val()); ratejs=price2numjs(rate.val()); - if (npRate == "marginRate") + /* console.log(npRate+" - "+bpjs+" - "+ratejs); */ + + 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