Clean deprecated field

This commit is contained in:
Laurent Destailleur 2022-04-07 14:18:24 +02:00
parent 01f11ff5f4
commit 27acaa45f5
2 changed files with 17 additions and 42 deletions

View File

@ -79,13 +79,19 @@ class FactureFournisseurRec extends CommonInvoice
public $suspended;
public $libelle;
public $label;
/**
* @deprecated
* @var double $amount
* @deprecated
*/
public $amount;
/**
* @var double $remise
* @deprecated
*/
public $remise;
public $vat_src_code;
public $localtax1;
public $localtax2;
@ -173,8 +179,6 @@ class FactureFournisseurRec extends CommonInvoice
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>40),
'suspended' =>array('type'=>'integer', 'label'=>'Suspended', 'enabled'=>1, 'visible'=>-1, 'position'=>225),
'libelle' =>array('type'=>'varchar(100)', 'label'=>'Libelle', 'enabled'=>1, 'showoncombobox' => 0, 'visible'=>-1, 'position'=>15),
'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35),
'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>40),
'localtax1' =>array('type'=>'double(24,8)', 'label'=>'Localtax1', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'isameasure'=>1),
'localtax2' =>array('type'=>'double(24,8)', 'label'=>'Localtax2', 'enabled'=>1, 'visible'=>-1, 'position'=>65, 'isameasure'=>1),
@ -278,8 +282,7 @@ class FactureFournisseurRec extends CommonInvoice
$sql .= ', datec';
$sql .= ', suspended';
$sql .= ', libelle';
$sql .= ', amount';
$sql .= ', remise';
$sql .= ', total_ttc';
$sql .= ', fk_user_author';
$sql .= ', fk_projet';
$sql .= ', fk_account';
@ -310,7 +313,6 @@ class FactureFournisseurRec extends CommonInvoice
$sql .= ", ".((int) $this->suspended);
$sql .= ", '".$this->db->escape($this->libelle)."'";
$sql .= ", " .(!empty($facfourn_src->total_ttc) ? (float) $facfourn_src->total_ttc : '0'); // amount
$sql .= ", " .(!empty($facfourn_src->remise) ? (float) $facfourn_src->remise : '0');
$sql .= ", " .((int) $user->id);
$sql .= ", " .(!empty($this->fk_project) ? ((int) $this->fk_project) : 'NULL');
$sql .= ", " .(!empty($facfourn_src->fk_account) ? ((int) $facfourn_src->fk_account) : 'NULL');
@ -480,8 +482,6 @@ class FactureFournisseurRec extends CommonInvoice
if ($this->fk_soc > 0) $sql .= " fk_soc = ". (int) $this->fk_soc. ',';
$sql .= " suspended = ". (!empty($this->suspended) ? ((int) $this->suspended) : 0) . ',';
$sql .= " libelle = ". (!empty($this->libelle) ? "'".$this->db->escape($this->libelle)."'" : 'NULL') . ",";
$sql .= " amount = ". (!empty($this->amount) ? ((float) $this->amount) : 0.00) . ',';
$sql .= " remise = ". (!empty($this->remise) ? ((float) $this->remise) : 'NULL') . ',';
$sql .= " vat_src_code = ". (!empty($this->vat_src_code) ? "'".$this->db->escape($this->vat_src_code)."'" : 'NULL') . ',';
$sql .= " localtax1 = ". (!empty($this->localtax1) ? ((float) $this->localtax1) : 0.00) . ',';
$sql .= " localtax2 = ". (!empty($this->localtax2) ? ((float) $this->localtax2) : 0.00) . ',';
@ -553,7 +553,7 @@ class FactureFournisseurRec extends CommonInvoice
{
$sql = 'SELECT f.rowid, f.titre, f.ref_supplier, f.entity, f.fk_soc';
$sql .= ', f.datec, f.tms, f.suspended';
$sql .= ', f.libelle, f.amount, f.remise';
$sql .= ', f.libelle as label';
$sql .= ', f.vat_src_code, f.localtax1, f.localtax2';
$sql .= ', f.total_tva, f.total_ht, f.total_ttc';
$sql .= ', f.fk_user_author, f.fk_user_modif';
@ -593,9 +593,8 @@ class FactureFournisseurRec extends CommonInvoice
$this->date_creation = $obj->datec;
$this->date_modification = $obj->tms;
$this->suspended = $obj->suspended;
$this->libelle = $obj->libelle;
$this->amount = $obj->amount;
$this->remise = $obj->remise;
$this->libelle = $obj->label;
$this->label = $obj->label;
$this->vat_src_code = $obj->vat_src_code;
$this->total_localtax1 = $obj->localtax1;
$this->total_localtax2 = $obj->localtax2;

View File

@ -182,10 +182,14 @@ class FactureFournisseur extends CommonInvoice
public $date_echeance;
/**
* @deprecated
* @var double $amount
* @deprecated
*/
public $amount = 0;
/**
* @var double $remise
* @deprecated
*/
public $remise = 0;
/**
@ -404,11 +408,6 @@ class FactureFournisseur extends CommonInvoice
$this->date = $now;
}
$socid = $this->socid;
$ref_supplier = $this->ref_supplier;
$amount = $this->amount;
$remise = $this->remise;
// Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate)
if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) {
list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $this->date);
@ -456,7 +455,6 @@ class FactureFournisseur extends CommonInvoice
$this->total_ttc = $_facrec->total_ttc;
// Fields always coming from template
$this->remise = $_facrec->remise;
$this->fk_incoterms = $_facrec->fk_incoterms;
$this->location_incoterms = $_facrec->location_incoterms;
@ -475,7 +473,6 @@ class FactureFournisseur extends CommonInvoice
$this->array_options = $_facrec->array_options;
//if (! $this->remise) $this->remise = 0;
if (! $this->mode_reglement_id) {
$this->mode_reglement_id = 0;
}
@ -545,10 +542,6 @@ class FactureFournisseur extends CommonInvoice
$this->date_echeance = $forceduedate;
}
if (!$remise) {
$remise = 0;
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_fourn (";
$sql .= "ref";
$sql .= ", ref_supplier";
@ -882,8 +875,6 @@ class FactureFournisseur extends CommonInvoice
$sql .= " t.tms,";
$sql .= " t.libelle as label,";
$sql .= " t.paye,";
$sql .= " t.amount,";
$sql .= " t.remise,";
$sql .= " t.close_code,";
$sql .= " t.close_note,";
$sql .= " t.tva,";
@ -948,11 +939,8 @@ class FactureFournisseur extends CommonInvoice
$this->label = $obj->label;
$this->paye = $obj->paye;
$this->paid = $obj->paye;
$this->amount = $obj->amount;
$this->remise = $obj->remise;
$this->close_code = $obj->close_code;
$this->close_note = $obj->close_note;
//$this->tva = $obj->tva;
$this->total_localtax1 = $obj->localtax1;
$this->total_localtax2 = $obj->localtax2;
$this->total_ht = $obj->total_ht;
@ -1177,22 +1165,12 @@ class FactureFournisseur extends CommonInvoice
if (isset($this->paye)) {
$this->paye = trim($this->paye);
}
if (isset($this->amount)) {
if (empty($this->amount)) $this->amount = 0;
else $this->amount = doubleval($this->amount);
}
if (isset($this->remise)) {
$this->remise = trim($this->remise);
}
if (isset($this->close_code)) {
$this->close_code = trim($this->close_code);
}
if (isset($this->close_note)) {
$this->close_note = trim($this->close_note);
}
/*if (isset($this->tva)) {
$this->tva = trim($this->tva);
}*/
if (isset($this->localtax1)) {
$this->localtax1 = trim($this->localtax1);
}
@ -1264,8 +1242,6 @@ class FactureFournisseur extends CommonInvoice
}
$sql .= " libelle=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").",";
$sql .= " paye=".(isset($this->paye) ? $this->paye : "null").",";
$sql .= " amount=".(isset($this->amount) ? $this->amount : "null").",";
$sql .= " remise=".(isset($this->remise) ? $this->remise : "null").",";
$sql .= " close_code=".(isset($this->close_code) ? "'".$this->db->escape($this->close_code)."'" : "null").",";
$sql .= " close_note=".(isset($this->close_note) ? "'".$this->db->escape($this->close_note)."'" : "null").",";
//$sql .= " tva=".(isset($this->tva) ? $this->tva : "null").",";
@ -2452,7 +2428,7 @@ class FactureFournisseur extends CommonInvoice
$this->db->begin();
// Libere remise liee a ligne de facture
// Free the discount linked to a line of invoice
$sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except';
$sql .= ' SET fk_invoice_supplier_line = NULL';
$sql .= ' WHERE fk_invoice_supplier_line = '.((int) $rowid);