Fix default value #19562

This commit is contained in:
Laurent Destailleur 2021-12-19 20:55:24 +01:00
parent f09e603bf4
commit 19efa37e4b
3 changed files with 16 additions and 13 deletions

View File

@ -399,8 +399,8 @@ if (empty($reshook)) {
$object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int');
$object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU', 2); // deprecated
$object->remise_percent = price2num(GETPOST('remise_percent'), '', 2);
$object->remise_absolue = price2num(GETPOST('remise_absolue'), 'MU', 2);
$object->socid = GETPOST('socid', 'int');
$object->contact_id = GETPOST('contactid', 'int');
$object->fk_project = GETPOST('projectid', 'int');
@ -1522,8 +1522,8 @@ if ($action == 'create') {
$cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); // TODO maybe add default value option
$mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
$remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); // deprecated
$remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0));
$remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0));
$warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0));
$dateinvoice = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $dateinvoice);
@ -1779,7 +1779,7 @@ if ($action == 'create') {
// TODO for compatibility
if ($origin == 'contrat') {
// Calcul contrat->price (HT), contrat->total (TTC), contrat->tva
$objectsrc->remise_absolue = $remise_absolue;
$objectsrc->remise_absolue = $remise_absolue; // deprecated
$objectsrc->remise_percent = $remise_percent;
$objectsrc->update_price(1, - 1, 1);
}

View File

@ -204,9 +204,16 @@ class Propal extends CommonObject
public $cond_reglement_code;
public $mode_reglement_code;
public $remise = 0;
public $remise_percent = 0;
public $remise_absolue = 0;
public $remise_percent;
/**
* @deprecated
*/
public $remise;
/**
* @deprecated
*/
public $remise_absolue;
/**
* @var int ID
@ -299,7 +306,7 @@ class Propal extends CommonObject
'fk_user_cloture' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk user cloture', 'enabled'=>1, 'visible'=>-1, 'position'=>95),
'price' =>array('type'=>'double', 'label'=>'Price', 'enabled'=>1, 'visible'=>-1, 'position'=>105),
'remise_percent' =>array('type'=>'double', 'label'=>'RelativeDiscount', 'enabled'=>1, 'visible'=>-1, 'position'=>110),
'remise_absolue' =>array('type'=>'double', 'label'=>'CustomerRelativeDiscount', 'enabled'=>1, 'visible'=>-1, 'position'=>115),
//'remise_absolue' =>array('type'=>'double', 'label'=>'CustomerRelativeDiscount', 'enabled'=>1, 'visible'=>-1, 'position'=>115),
//'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>120),
'total_ht' =>array('type'=>'double(24,8)', 'label'=>'TotalHT', 'enabled'=>1, 'visible'=>-1, 'position'=>125, 'isameasure'=>1),
'total_tva' =>array('type'=>'double(24,8)', 'label'=>'VAT', 'enabled'=>1, 'visible'=>-1, 'position'=>130, 'isameasure'=>1),
@ -1099,9 +1106,9 @@ class Propal extends CommonObject
$sql .= " VALUES (";
$sql .= $this->socid;
$sql .= ", 0";
$sql .= ", ".((float) $this->remise);
$sql .= ", ".((float) $this->remise); // deprecated
$sql .= ", ".($this->remise_percent ? ((float) $this->remise_percent) : 'NULL');
$sql .= ", ".($this->remise_absolue ? ((float) $this->remise_absolue) : 'NULL');
$sql .= ", ".($this->remise_absolue ? ((float) $this->remise_absolue) : 'NULL'); // deprecated
$sql .= ", 0";
$sql .= ", 0";
$sql .= ", '".$this->db->idate($this->date)."'";
@ -2420,7 +2427,6 @@ class Propal extends CommonObject
if (!$error) {
$this->oldcopy = clone $this;
$this->remise_absolue = $remise;
$this->update_price(1);
}

View File

@ -386,9 +386,6 @@ class Commande extends CommonOrder
public function __construct($db)
{
$this->db = $db;
$this->remise = 0;
$this->remise_percent = 0;
}
/**