clean trigger and normalize code

This commit is contained in:
florian HENRY 2016-07-08 21:28:21 +02:00
parent 2d9876d127
commit 10b0e5dd57
3 changed files with 222 additions and 157 deletions

View File

@ -59,24 +59,24 @@ class Propal extends CommonObject
* ID of the client * ID of the client
* @var int * @var int
*/ */
var $socid; public $socid;
var $contactid; public $contactid;
var $author; public $author;
var $ref_client; public $ref_client;
/** /**
* Status of the quote * Status of the quote
* @var int * @var int
* @see Propal::STATUS_DRAFT, Propal::STATUS_VALIDATED, Propal::STATUS_SIGNED, Propal::STATUS_NOTSIGNED, Propal::STATUS_BILLED * @see Propal::STATUS_DRAFT, Propal::STATUS_VALIDATED, Propal::STATUS_SIGNED, Propal::STATUS_NOTSIGNED, Propal::STATUS_BILLED
*/ */
var $statut; public $statut;
/** /**
* @deprecated * @deprecated
* @see date_creation * @see date_creation
*/ */
var $datec; public $datec;
/** /**
* Creation date * Creation date
@ -88,7 +88,7 @@ class Propal extends CommonObject
* @deprecated * @deprecated
* @see date_validation * @see date_validation
*/ */
var $datev; public $datev;
/** /**
* Validation date * Validation date
@ -100,70 +100,72 @@ class Propal extends CommonObject
* Date of the quote * Date of the quote
* @var * @var
*/ */
var $date; public $date;
/** /**
* @deprecated * @deprecated
* @see date * @see date
*/ */
var $datep; public $datep;
var $date_livraison; public $date_livraison;
var $fin_validite; public $fin_validite;
var $user_author_id; public $user_author_id;
var $user_valid_id; public $user_valid_id;
var $user_close_id; public $user_close_id;
/** /**
* @deprecated * @deprecated
* @see total_ht * @see total_ht
*/ */
var $price; public $price;
/** /**
* @deprecated * @deprecated
* @see total_tva * @see total_tva
*/ */
var $tva; public $tva;
/** /**
* @deprecated * @deprecated
* @see total_ttc * @see total_ttc
*/ */
var $total; public $total;
var $cond_reglement_code; public $cond_reglement_code;
var $mode_reglement_code; public $mode_reglement_code;
var $remise; public $remise;
var $remise_percent; public $remise_percent;
var $remise_absolue; public $remise_absolue;
var $fk_address; public $fk_address;
var $address_type; public $address_type;
var $address; public $address;
var $availability_id; public $availability_id;
var $availability_code; public $availability_code;
var $demand_reason_id; public $demand_reason_id;
var $demand_reason_code; public $demand_reason_code;
var $products=array(); public $products=array();
var $extraparams=array(); public $extraparams=array();
/** /**
* @var PropaleLigne[] * @var PropaleLigne[]
*/ */
var $lines = array(); public $lines = array();
var $line; public $line;
var $labelstatut=array(); public $labelstatut=array();
var $labelstatut_short=array(); public $labelstatut_short=array();
var $specimen; public $specimen;
// Multicurrency // Multicurrency
var $fk_multicurrency; public $fk_multicurrency;
var $multicurrency_code; public $multicurrency_code;
var $multicurrency_tx; public $multicurrency_tx;
var $multicurrency_total_ht; public $multicurrency_total_ht;
var $multicurrency_total_tva; public $multicurrency_total_tva;
var $multicurrency_total_ttc; public $multicurrency_total_ttc;
public $oldcopy;
/** /**
* Draft status * Draft status
@ -1641,6 +1643,13 @@ class Propal extends CommonObject
$error++; $error++;
} }
if (! $error)
{
$this->oldcopy= clone $this;
$this->date = $date;
$this->datep = $date; // deprecated
}
if (! $notrigger && empty($error)) if (! $notrigger && empty($error))
{ {
// Call trigger // Call trigger
@ -1651,9 +1660,6 @@ class Propal extends CommonObject
if (! $error) if (! $error)
{ {
$this->date = $date;
$this->datep = $date; // deprecated
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
@ -1697,6 +1703,13 @@ class Propal extends CommonObject
$error++; $error++;
} }
if (! $error)
{
$this->oldcopy= clone $this;
$this->fin_validite = $date_fin_validite;
}
if (! $notrigger && empty($error)) if (! $notrigger && empty($error))
{ {
// Call trigger // Call trigger
@ -1707,8 +1720,6 @@ class Propal extends CommonObject
if (! $error) if (! $error)
{ {
$this->fin_validite = $date_fin_validite;
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
@ -1753,6 +1764,12 @@ class Propal extends CommonObject
$error++; $error++;
} }
if (! $error)
{
$this->oldcopy= clone $this;
$this->date_livraison = $date_livraison;
}
if (! $notrigger && empty($error)) if (! $notrigger && empty($error))
{ {
// Call trigger // Call trigger
@ -1763,8 +1780,6 @@ class Propal extends CommonObject
if (! $error) if (! $error)
{ {
$this->date_livraison = $date_livraison;
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
@ -1809,6 +1824,12 @@ class Propal extends CommonObject
$error++; $error++;
} }
if (! $error)
{
$this->oldcopy= clone $this;
$this->fk_availability = $id;
}
if (! $notrigger && empty($error)) if (! $notrigger && empty($error))
{ {
// Call trigger // Call trigger
@ -1819,8 +1840,6 @@ class Propal extends CommonObject
if (! $error) if (! $error)
{ {
$this->fk_availability = $id;
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
@ -1865,6 +1884,14 @@ class Propal extends CommonObject
$error++; $error++;
} }
if (! $error)
{
$this->oldcopy= clone $this;
$this->fk_input_reason = $id;
}
if (! $notrigger && empty($error)) if (! $notrigger && empty($error))
{ {
// Call trigger // Call trigger
@ -1875,8 +1902,6 @@ class Propal extends CommonObject
if (! $error) if (! $error)
{ {
$this->fk_input_reason = $id;
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
@ -1920,6 +1945,12 @@ class Propal extends CommonObject
$error++; $error++;
} }
if (! $error)
{
$this->oldcopy= clone $this;
$this->ref_client = $ref_client;
}
if (! $notrigger && empty($error)) if (! $notrigger && empty($error))
{ {
// Call trigger // Call trigger
@ -1930,8 +1961,6 @@ class Propal extends CommonObject
if (! $error) if (! $error)
{ {
$this->ref_client = $ref_client;
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
@ -1983,6 +2012,13 @@ class Propal extends CommonObject
$error++; $error++;
} }
if (! $error)
{
$this->oldcopy= clone $this;
$this->remise_percent = $remise;
$this->update_price(1);
}
if (! $notrigger && empty($error)) if (! $notrigger && empty($error))
{ {
// Call trigger // Call trigger
@ -1993,9 +2029,6 @@ class Propal extends CommonObject
if (! $error) if (! $error)
{ {
$this->remise_percent = $remise;
$this->update_price(1);
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
@ -2045,6 +2078,13 @@ class Propal extends CommonObject
$error++; $error++;
} }
if (! $error)
{
$this->oldcopy= clone $this;
$this->remise_absolue = $remise;
$this->update_price(1);
}
if (! $notrigger && empty($error)) if (! $notrigger && empty($error))
{ {
// Call trigger // Call trigger
@ -2055,9 +2095,6 @@ class Propal extends CommonObject
if (! $error) if (! $error)
{ {
$this->remise_absolue = $remise;
$this->update_price(1);
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
@ -2201,6 +2238,14 @@ class Propal extends CommonObject
$this->generateDocument($modelpdf, $outputlangs); $this->generateDocument($modelpdf, $outputlangs);
} }
if (! $error)
{
$this->oldcopy= clone $this;
$this->statut = $statut;
$this->date_cloture = $now;
$this->note_private = $note;
}
if (! $notrigger && empty($error)) if (! $notrigger && empty($error))
{ {
// Call trigger // Call trigger
@ -2211,8 +2256,6 @@ class Propal extends CommonObject
if ( ! $error ) if ( ! $error )
{ {
$this->statut = $statut;
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
@ -2254,6 +2297,12 @@ class Propal extends CommonObject
$error++; $error++;
} }
if (! $error)
{
$this->oldcopy= clone $this;
$this->statut=self::STATUS_BILLED;
}
if (! $notrigger && empty($error)) if (! $notrigger && empty($error))
{ {
// Call trigger // Call trigger
@ -2264,8 +2313,6 @@ class Propal extends CommonObject
if (! $error) if (! $error)
{ {
$this->statut=self::STATUS_BILLED;
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
@ -2320,6 +2367,13 @@ class Propal extends CommonObject
$error++; $error++;
} }
if (! $error)
{
$this->oldcopy= clone $this;
$this->statut = self::STATUS_DRAFT;
$this->brouillon = 1;
}
if (! $notrigger && empty($error)) if (! $notrigger && empty($error))
{ {
// Call trigger // Call trigger
@ -2330,9 +2384,6 @@ class Propal extends CommonObject
if (! $error) if (! $error)
{ {
$this->statut = self::STATUS_DRAFT;
$this->brouillon = 1;
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
@ -2670,6 +2721,12 @@ class Propal extends CommonObject
$error++; $error++;
} }
if (! $error)
{
$this->oldcopy= clone $this;
$this->availability_id = $availability_id;
}
if (! $notrigger && empty($error)) if (! $notrigger && empty($error))
{ {
// Call trigger // Call trigger
@ -2680,8 +2737,6 @@ class Propal extends CommonObject
if (! $error) if (! $error)
{ {
$this->availability_id = $availability_id;
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
@ -2733,6 +2788,12 @@ class Propal extends CommonObject
$error++; $error++;
} }
if (! $error)
{
$this->oldcopy= clone $this;
$this->demand_reason_id = $demand_reason_id;
}
if (! $notrigger && empty($error)) if (! $notrigger && empty($error))
{ {
// Call trigger // Call trigger
@ -2743,8 +2804,6 @@ class Propal extends CommonObject
if (! $error) if (! $error)
{ {
$this->demand_reason_id = $demand_reason_id;
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }

View File

@ -57,99 +57,99 @@ class Commande extends CommonOrder
* Client ID * Client ID
* @var int * @var int
*/ */
var $socid; public $socid;
var $ref_client; public $ref_client;
var $ref_int; public $ref_int;
var $contactid; public $contactid;
/** /**
* Status of the order. Check the following constants: * Status of the order. Check the following constants:
* @var int * @var int
* @see Commande::STATUS_CANCELED, Commande::STATUS_DRAFT, Commande::STATUS_ACCEPTED, Commande::STATUS_CLOSED * @see Commande::STATUS_CANCELED, Commande::STATUS_DRAFT, Commande::STATUS_ACCEPTED, Commande::STATUS_CLOSED
*/ */
var $statut; public $statut;
/** /**
* @deprecated * @deprecated
* @see billed * @see billed
*/ */
var $facturee; public $facturee;
var $billed; // billed or not public $billed; // billed or not
var $brouillon; public $brouillon;
var $cond_reglement_code; public $cond_reglement_code;
var $fk_account; public $fk_account;
/** /**
* It holds the label of the payment mode. Use it in case translation cannot be found. * It holds the label of the payment mode. Use it in case translation cannot be found.
* @var string * @var string
*/ */
var $mode_reglement; public $mode_reglement;
/** /**
* Payment mode id * Payment mode id
* @var int * @var int
*/ */
var $mode_reglement_id; public $mode_reglement_id;
/** /**
* Payment mode code * Payment mode code
* @var string * @var string
*/ */
var $mode_reglement_code; public $mode_reglement_code;
/** /**
* Availability delivery time id * Availability delivery time id
* @var int * @var int
*/ */
var $availability_id; public $availability_id;
/** /**
* Availability delivery time code * Availability delivery time code
* @var string * @var string
*/ */
var $availability_code; public $availability_code;
/** /**
* Label of availability delivery time. Use it in case translation cannot be found. * Label of availability delivery time. Use it in case translation cannot be found.
* @var string * @var string
*/ */
var $availability; public $availability;
var $demand_reason_id; public $demand_reason_id;
var $demand_reason_code; public $demand_reason_code;
var $address; public $address;
var $date; // Date commande public $date; // Date commande
/** /**
* @deprecated * @deprecated
* @see date * @see date
*/ */
var $date_commande; public $date_commande;
var $date_livraison; // Date livraison souhaitee public $date_livraison; // Date livraison souhaitee
var $fk_remise_except; public $fk_remise_except;
var $remise_percent; public $remise_percent;
var $remise_absolue; public $remise_absolue;
var $info_bits; public $info_bits;
var $rang; public $rang;
var $special_code; public $special_code;
var $source; // Origin of order public $source; // Origin of order
var $extraparams=array(); public $extraparams=array();
var $linked_objects=array(); public $linked_objects=array();
var $user_author_id; public $user_author_id;
/** /**
* @var OrderLine[] * @var OrderLine[]
*/ */
var $lines = array(); public $lines = array();
// Multicurrency // Multicurrency
var $fk_multicurrency; public $fk_multicurrency;
var $multicurrency_code; public $multicurrency_code;
var $multicurrency_tx; public $multicurrency_tx;
var $multicurrency_total_ht; public $multicurrency_total_ht;
var $multicurrency_total_tva; public $multicurrency_total_tva;
var $multicurrency_total_ttc; public $multicurrency_total_ttc;
var $oldcopy; public $oldcopy;
/** /**
* ERR Not enough stock * ERR Not enough stock

View File

@ -59,63 +59,63 @@ class Facture extends CommonInvoice
*/ */
protected $table_ref_field = 'facnumber'; protected $table_ref_field = 'facnumber';
var $socid; public $socid;
var $author; public $author;
var $fk_user_author; public $fk_user_author;
var $fk_user_valid; public $fk_user_valid;
var $date; // Date invoice public $date; // Date invoice
var $date_creation; // Creation date public $date_creation; // Creation date
var $date_validation; // Validation date public $date_validation; // Validation date
var $datem; public $datem;
var $ref_client; public $ref_client;
var $ref_int; public $ref_int;
//Check constants for types //Check constants for types
var $type = self::TYPE_STANDARD; public $type = self::TYPE_STANDARD;
//var $amount; //var $amount;
var $remise_absolue; public $remise_absolue;
var $remise_percent; public $remise_percent;
var $total_ht=0; public $total_ht=0;
var $total_tva=0; public $total_tva=0;
var $total_ttc=0; public $total_ttc=0;
var $revenuestamp; public $revenuestamp;
//! Fermeture apres paiement partiel: discount_vat, badcustomer, abandon //! Fermeture apres paiement partiel: discount_vat, badcustomer, abandon
//! Fermeture alors que aucun paiement: replaced (si remplace), abandon //! Fermeture alors que aucun paiement: replaced (si remplace), abandon
var $close_code; public $close_code;
//! Commentaire si mis a paye sans paiement complet //! Commentaire si mis a paye sans paiement complet
var $close_note; public $close_note;
//! 1 if invoice paid COMPLETELY, 0 otherwise (do not use it anymore, use statut and close_code) //! 1 if invoice paid COMPLETELY, 0 otherwise (do not use it anymore, use statut and close_code)
var $paye; public $paye;
//! id of source invoice if replacement invoice or credit note //! id of source invoice if replacement invoice or credit note
var $fk_facture_source; public $fk_facture_source;
var $linked_objects=array(); public $linked_objects=array();
var $date_lim_reglement; public $date_lim_reglement;
var $cond_reglement_code; // Code in llx_c_paiement public $cond_reglement_code; // Code in llx_c_paiement
var $mode_reglement_code; // Code in llx_c_paiement public $mode_reglement_code; // Code in llx_c_paiement
var $fk_bank; // Field to store bank id to use when payment mode is withdraw public $fk_bank; // Field to store bank id to use when payment mode is withdraw
/** /**
* @deprecated * @deprecated
*/ */
var $products=array(); public $products=array();
/** /**
* @var FactureLigne[] * @var FactureLigne[]
*/ */
var $lines=array(); public $lines=array();
var $line; public $line;
var $extraparams=array(); public $extraparams=array();
var $specimen; public $specimen;
var $fac_rec; public $fac_rec;
// Multicurrency // Multicurrency
var $fk_multicurrency; public $fk_multicurrency;
var $multicurrency_code; public $multicurrency_code;
var $multicurrency_tx; public $multicurrency_tx;
var $multicurrency_total_ht; public $multicurrency_total_ht;
var $multicurrency_total_tva; public $multicurrency_total_tva;
var $multicurrency_total_ttc; public $multicurrency_total_ttc;
/** /**
* @var int Situation cycle reference number * @var int Situation cycle reference number
@ -142,6 +142,8 @@ class Facture extends CommonInvoice
*/ */
public $tab_next_situation_invoice=array(); public $tab_next_situation_invoice=array();
public $oldcopy;
/** /**
* Standard invoice * Standard invoice
*/ */
@ -1512,8 +1514,8 @@ class Facture extends CommonInvoice
if (! $error) if (! $error)
{ {
$this->ref_client = $ref_client; $this->ref_client = $ref_client;
}
if (! $notrigger && empty($error)) if (! $notrigger && empty($error))
{ {
@ -2887,6 +2889,13 @@ class Facture extends CommonInvoice
$error++; $error++;
} }
if (! $error)
{
$this->oldcopy= clone $this;
$this->remise_absolue = $remise;
$this->update_price(1);
}
if (! $notrigger && empty($error)) if (! $notrigger && empty($error))
{ {
// Call trigger // Call trigger
@ -2897,9 +2906,6 @@ class Facture extends CommonInvoice
if (! $error) if (! $error)
{ {
$this->remise_absolue = $remise;
$this->update_price(1);
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }