Clean code for php8
This commit is contained in:
parent
1affaa8c87
commit
a1d97274fb
@ -116,6 +116,12 @@ class FactureRec extends CommonInvoice
|
||||
public $auto_validate; // 0 to create in draft, 1 to create and validate the new invoice
|
||||
public $generate_pdf; // 1 to generate PDF on invoice generation (default)
|
||||
|
||||
/**
|
||||
* @var int 1 if status is draft
|
||||
* @deprecated
|
||||
*/
|
||||
public $brouillon;
|
||||
|
||||
|
||||
/**
|
||||
* 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
|
||||
@ -837,6 +843,7 @@ class FactureRec extends CommonInvoice
|
||||
$localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
|
||||
|
||||
// Clean vat code
|
||||
$reg = array();
|
||||
$vat_src_code = '';
|
||||
if (preg_match('/\((.*)\)/', $txtva, $reg)) {
|
||||
$vat_src_code = $reg[1];
|
||||
@ -1277,6 +1284,8 @@ class FactureRec extends CommonInvoice
|
||||
|
||||
$facture->type = self::TYPE_STANDARD;
|
||||
$facture->brouillon = 1;
|
||||
$facture->statut = self::STATUS_DRAFT;
|
||||
$facture->status = self::STATUS_DRAFT;
|
||||
$facture->date = (empty($facturerec->date_when) ? $now : $facturerec->date_when); // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later.
|
||||
$facture->socid = $facturerec->socid;
|
||||
|
||||
@ -1602,6 +1611,7 @@ class FactureRec extends CommonInvoice
|
||||
// Initialize parameters
|
||||
$this->id = 0;
|
||||
$this->ref = 'SPECIMEN';
|
||||
$this->title = 'SPECIMEN';
|
||||
$this->specimen = 1;
|
||||
$this->socid = 1;
|
||||
$this->date = $nownotime;
|
||||
|
||||
@ -99,6 +99,12 @@ class Facture extends CommonInvoice
|
||||
*/
|
||||
protected $table_ref_field = 'ref';
|
||||
|
||||
/**
|
||||
* @var int 1 if status is draft
|
||||
* @deprecated
|
||||
*/
|
||||
public $brouillon;
|
||||
|
||||
/**
|
||||
* @var int thirdparty ID
|
||||
*/
|
||||
@ -446,6 +452,8 @@ class Facture extends CommonInvoice
|
||||
$this->mode_reglement_id = 0;
|
||||
}
|
||||
$this->brouillon = 1;
|
||||
$this->status = self::STATUS_DRAFT;
|
||||
$this->statut = self::STATUS_DRAFT;
|
||||
|
||||
// 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)) {
|
||||
@ -537,6 +545,8 @@ class Facture extends CommonInvoice
|
||||
$this->mode_reglement_id = 0;
|
||||
}
|
||||
$this->brouillon = 1;
|
||||
$this->status = self::STATUS_DRAFT;
|
||||
$this->statut = self::STATUS_DRAFT;
|
||||
|
||||
$this->linked_objects = $_facrec->linkedObjectsIds;
|
||||
// We do not add link to template invoice or next invoice will be linked to all generated invoices
|
||||
@ -1683,7 +1693,7 @@ class Facture extends CommonInvoice
|
||||
$this->fetchPreviousNextSituationInvoice();
|
||||
}
|
||||
|
||||
if ($this->statut == self::STATUS_DRAFT) {
|
||||
if ($this->status == self::STATUS_DRAFT) {
|
||||
$this->brouillon = 1;
|
||||
}
|
||||
|
||||
@ -2584,8 +2594,8 @@ class Facture extends CommonInvoice
|
||||
$this->fetch_lines();
|
||||
|
||||
// Check parameters
|
||||
if (!$this->brouillon) {
|
||||
dol_syslog(get_class($this)."::validate no draft status", LOG_WARNING);
|
||||
if ($this->statut != self::STATUS_DRAFT) {
|
||||
dol_syslog(get_class($this)."::validate status is not draft. operation canceled.", LOG_WARNING);
|
||||
return 0;
|
||||
}
|
||||
if (count($this->lines) <= 0) {
|
||||
@ -2849,6 +2859,7 @@ class Facture extends CommonInvoice
|
||||
$this->ref = $num;
|
||||
$this->ref = $num;
|
||||
$this->statut = self::STATUS_VALIDATED;
|
||||
$this->status = self::STATUS_VALIDATED;
|
||||
$this->brouillon = 0;
|
||||
$this->date_validation = $now;
|
||||
$i = 0;
|
||||
@ -2887,7 +2898,7 @@ class Facture extends CommonInvoice
|
||||
* Update price of next invoice
|
||||
*
|
||||
* @param Translate $langs Translate object
|
||||
* @return bool false if KO, true if OK
|
||||
* @return bool false if KO, true if OK
|
||||
*/
|
||||
public function updatePriceNextInvoice(&$langs)
|
||||
{
|
||||
@ -2900,6 +2911,7 @@ class Facture extends CommonInvoice
|
||||
}
|
||||
|
||||
$next_invoice->brouillon = 1;
|
||||
|
||||
foreach ($next_invoice->lines as $line) {
|
||||
$result = $next_invoice->updateline(
|
||||
$line->id,
|
||||
@ -2995,12 +3007,14 @@ class Facture extends CommonInvoice
|
||||
$old_statut = $this->statut;
|
||||
$this->brouillon = 1;
|
||||
$this->statut = self::STATUS_DRAFT;
|
||||
$this->status = self::STATUS_DRAFT;
|
||||
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('BILL_UNVALIDATE', $user);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
$this->statut = $old_statut;
|
||||
$this->status = $old_statut;
|
||||
$this->brouillon = 0;
|
||||
}
|
||||
// End call triggers
|
||||
@ -3362,7 +3376,7 @@ class Facture extends CommonInvoice
|
||||
|
||||
dol_syslog(get_class($this)."::updateline rowid=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, date_start=$date_start, date_end=$date_end, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, type=$type, fk_parent_line=$fk_parent_line pa_ht=$pa_ht, special_code=$special_code, fk_unit=$fk_unit, pu_ht_devise=$pu_ht_devise", LOG_DEBUG);
|
||||
|
||||
if ($this->brouillon) {
|
||||
if ($this->statut == self::STATUS_DRAFT) {
|
||||
if (!$this->is_last_in_cycle() && empty($this->error)) {
|
||||
if (!$this->checkProgressLine($rowid, $situation_percent)) {
|
||||
if (!$this->error) {
|
||||
@ -3631,7 +3645,7 @@ class Facture extends CommonInvoice
|
||||
|
||||
dol_syslog(get_class($this)."::deleteline rowid=".$rowid, LOG_DEBUG);
|
||||
|
||||
if (!$this->brouillon) {
|
||||
if ($this->statut != self::STATUS_DRAFT) {
|
||||
$this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
|
||||
return -1;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user