Merge pull request #32533 from hregis/fix_20_broken_feature_pa_ht_is_float

FIX same broken feature for propal and invoice
This commit is contained in:
Laurent Destailleur 2025-01-05 18:44:11 +01:00 committed by GitHub
commit a76535de5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 20 deletions

View file

@ -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
}
@ -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;
@ -4234,6 +4239,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 +4284,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 +4456,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 +4511,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) {

View file

@ -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 = '';
}

View file

@ -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'
}
@ -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;
@ -6256,6 +6261,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);
@ -6310,9 +6316,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;
}
@ -6496,6 +6499,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);
@ -6541,9 +6545,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;