2
0
forked from Wavyzz/dolibarr

Fix Must make a difference between a buying/cost price == '' (not

provided) and buying/cost price = '0'. We must use default value only if
value is '' and not if forced to '0'.
This commit is contained in:
Laurent Destailleur
2015-11-04 17:51:15 +01:00
parent 832afa139a
commit a7795f25fc
7 changed files with 36 additions and 29 deletions

View File

@@ -3507,6 +3507,8 @@ class OrderLine extends CommonOrderLine
$error=0;
$pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'.
dol_syslog(get_class($this)."::insert rang=".$this->rang);
// Clean parameters
@@ -3523,11 +3525,10 @@ class OrderLine extends CommonOrderLine
if (empty($this->info_bits)) $this->info_bits=0;
if (empty($this->special_code)) $this->special_code=0;
if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
if (empty($this->pa_ht)) $this->pa_ht=0;
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
if ($this->pa_ht == 0 && $pa_ht_isemptystring)
{
if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0)
{
@@ -3641,6 +3642,8 @@ class OrderLine extends CommonOrderLine
$error=0;
$pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'.
// Clean parameters
if (empty($this->tva_tx)) $this->tva_tx=0;
if (empty($this->localtax1_tx)) $this->localtax1_tx=0;
@@ -3661,7 +3664,7 @@ class OrderLine extends CommonOrderLine
if (empty($this->pa_ht)) $this->pa_ht=0;
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
if ($this->pa_ht == 0 && $pa_ht_isemptystring)
{
if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0)
{