diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5f75f64fc16..b74143a4512 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -160,6 +160,8 @@ repos: ] pass_filenames: false # Run on all files - id: php-lint + exclude: + (?x)^(htdocs/includes/symfony/.*)$ - id: php-stan stages: [manual] files: \.(php)$ diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 74f7c62ce1e..e3b381a518a 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1582,7 +1582,7 @@ class Commande extends CommonOrder $pu_ht = price2num($pu_ht); $pu_ht_devise = price2num($pu_ht_devise); $pu_ttc = price2num($pu_ttc); - $pa_ht = (float) price2num($pa_ht); + $pa_ht = price2num($pa_ht); // do not convert to float here, it breaks the functioning of $pa_ht_isemptystring if (!preg_match('/\((.*)\)/', (string) $txtva)) { $txtva = price2num($txtva); // $txtva can have format '5,1' or '5.1' or '5.1(XXX)', we must clean only if '5,1' } @@ -1717,7 +1717,7 @@ class Commande extends CommonOrder $this->line->date_end = $date_end; $this->line->fk_fournprice = $fk_fournprice; - $this->line->pa_ht = $pa_ht; + $this->line->pa_ht = $pa_ht; // Can be '' when not defined or 0 if defined to 0 or a price value // Multicurrency $this->line->fk_multicurrency = $this->fk_multicurrency; @@ -1727,7 +1727,7 @@ class Commande extends CommonOrder $this->line->multicurrency_total_tva = (float) $multicurrency_total_tva; $this->line->multicurrency_total_ttc = (float) $multicurrency_total_ttc; - // TODO Ne plus utiliser + // TODO Do not use anymore $this->line->price = $price; if (is_array($array_options) && count($array_options) > 0) { diff --git a/htdocs/commande/class/orderline.class.php b/htdocs/commande/class/orderline.class.php index a311ef25233..d4ee988d3ea 100644 --- a/htdocs/commande/class/orderline.class.php +++ b/htdocs/commande/class/orderline.class.php @@ -345,6 +345,7 @@ 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'. + $this->pa_ht = (float) $this->pa_ht; // convert to float but after checking if value is empty dol_syslog(get_class($this)."::insert rang=".$this->rang); @@ -385,14 +386,11 @@ class OrderLine extends CommonOrderLine if (empty($this->fk_parent_line)) { $this->fk_parent_line = 0; } - if (empty($this->pa_ht)) { - $this->pa_ht = 0; - } if (empty($this->ref_ext)) { $this->ref_ext = ''; } - // if buy price not defined, define buyprice as configured in margin admin + // if buy price not defined (if = ''), we set the buyprice as configured in margin admin setup if ($this->pa_ht == 0 && $pa_ht_isemptystring) { $result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product); if ($result < 0) {