From 672992a7912fbdfee3981dfb9d58b0c36309729b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 5 Jan 2025 17:30:54 +0100 Subject: [PATCH 1/3] FIX same broken feature for propal and invoice --- htdocs/comm/propal/class/propal.class.php | 12 ++++-------- htdocs/commande/class/commande.class.php | 6 ++---- htdocs/compta/facture/class/facture.class.php | 6 ++++-- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index c633ac44b74..6fa8a2bd379 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -612,7 +612,7 @@ class Propal extends CommonObject } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); - $pa_ht = price2num($pa_ht); + $pa_ht = price2num($pa_ht); // do not convert to float here, it breaks the functioning of $pa_ht_isemptystring if ($price_base_type == 'HT') { $pu = $pu_ht; } else { @@ -840,7 +840,7 @@ class Propal extends CommonObject } $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); - $pa_ht = price2num($pa_ht); + $pa_ht = price2num($pa_ht); // do not convert to float here, it breaks the functioning of $pa_ht_isemptystring if (empty($qty) && empty($special_code)) { $special_code = 3; // Set option tag } @@ -4234,6 +4234,7 @@ class PropaleLigne extends CommonObjectLine dol_syslog(get_class($this)."::insert rang=".$this->rang); $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 after check if empty value // Clean parameters if (empty($this->tva_tx)) { @@ -4278,9 +4279,6 @@ class PropaleLigne extends CommonObjectLine if (!is_numeric($this->qty)) { $this->qty = 0; } - if (empty($this->pa_ht)) { - $this->pa_ht = 0; - } if (empty($this->multicurrency_subprice)) { $this->multicurrency_subprice = 0; } @@ -4453,6 +4451,7 @@ class PropaleLigne extends CommonObjectLine $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 after check if empty value if (empty($this->id) && !empty($this->rowid)) { $this->id = $this->rowid; @@ -4507,9 +4506,6 @@ class PropaleLigne extends CommonObjectLine if (empty($this->subprice)) { $this->subprice = 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 && $pa_ht_isemptystring) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 26bb1125cbf..2ac0d52671a 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3130,7 +3130,7 @@ class Commande extends CommonOrder $remise_percent = (float) price2num($remise_percent); $qty = (float) price2num($qty); $pu = price2num($pu); - $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 $pu_ht_devise = price2num($pu_ht_devise); if (!preg_match('/\((.*)\)/', (string) $txtva)) { $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' @@ -4629,6 +4629,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 after check if empty value // Clean parameters if (empty($this->tva_tx)) { @@ -4679,9 +4680,6 @@ 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 = ''; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 700f6fac245..00caede5161 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3877,7 +3877,7 @@ class Facture extends CommonInvoice $pu_ht = price2num($pu_ht); $pu_ht_devise = price2num($pu_ht_devise); $pu_ttc = price2num($pu_ttc); - $pa_ht = 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.0(XXX)' or '5' } @@ -4137,7 +4137,7 @@ class Facture extends CommonInvoice $qty = price2num($qty); $pu = price2num($pu); $pu_ht_devise = price2num($pu_ht_devise); - $pa_ht = 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.0(XXX)' or '5' } @@ -6256,6 +6256,7 @@ class FactureLigne extends CommonInvoiceLine $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 after check if empty value dol_syslog(get_class($this)."::insert rang=".$this->rang, LOG_DEBUG); @@ -6496,6 +6497,7 @@ class FactureLigne extends CommonInvoiceLine $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 after check if empty value // Clean parameters $this->desc = trim($this->desc); From 350697832db7339e89343d4f5597fc47275b4d01 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 5 Jan 2025 17:35:32 +0100 Subject: [PATCH 2/3] FIX remove unused code --- htdocs/compta/facture/class/facture.class.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 00caede5161..0b7681257a7 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -6311,9 +6311,6 @@ class FactureLigne extends CommonInvoiceLine $this->situation_percent = 100; } - if (empty($this->pa_ht)) { - $this->pa_ht = 0; - } if (empty($this->multicurrency_subprice)) { $this->multicurrency_subprice = 0; } @@ -6543,9 +6540,6 @@ class FactureLigne extends CommonInvoiceLine if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') { $this->situation_percent = 100; } - if (empty($this->pa_ht)) { - $this->pa_ht = 0; - } if (empty($this->multicurrency_subprice)) { $this->multicurrency_subprice = 0; From b1c82f4dbbf0daafd61d3021c68edfd11554abae Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 5 Jan 2025 17:38:04 +0100 Subject: [PATCH 3/3] FIX phan --- htdocs/comm/propal/class/propal.class.php | 5 +++++ htdocs/compta/facture/class/facture.class.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 6fa8a2bd379..a27eca21f18 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -4025,6 +4025,11 @@ class PropaleLigne extends CommonObjectLine public $rang = 0; public $fk_fournprice; + + /** + * Buy price without taxes + * @var float|string|null + */ public $pa_ht; public $marge_tx; public $marque_tx; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 0b7681257a7..375a9eb087a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -6089,6 +6089,11 @@ class FactureLigne extends CommonInvoiceLine public $rang = 0; public $fk_fournprice; + + /** + * Buy price without taxes + * @var float|string|null + */ public $pa_ht; public $marge_tx; public $marque_tx;