2
0
forked from Wavyzz/dolibarr

clean code (#35343)

* clean code

* clean code

* clean code

* clean code

* clean code

* clean code

* clean code

* clean code
This commit is contained in:
Frédéric FRANCE
2025-09-15 16:16:32 +02:00
committed by GitHub
parent 21d50f1a58
commit f8d3713c1c
3 changed files with 31 additions and 160 deletions

View File

@@ -324,138 +324,12 @@ parameters:
count: 1
path: ../../../htdocs/accountancy/class/accountingjournal.class.php
-
message: '#^Negated boolean expression is always true\.$#'
identifier: booleanNot.alwaysTrue
count: 2
path: ../../../htdocs/accountancy/class/bookkeeping.class.php
-
message: '#^Parameter \#2 \$callback of function array_filter expects \(callable\(string\)\: bool\)\|null, ''strlen'' given\.$#'
identifier: argument.type
count: 3
path: ../../../htdocs/accountancy/class/bookkeeping.class.php
-
message: '#^Property BookKeeping\:\:\$amount \(float\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 1
path: ../../../htdocs/accountancy/class/bookkeeping.class.php
-
message: '#^Property BookKeeping\:\:\$code_journal \(string\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 4
path: ../../../htdocs/accountancy/class/bookkeeping.class.php
-
message: '#^Property BookKeeping\:\:\$credit \(float\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 3
path: ../../../htdocs/accountancy/class/bookkeeping.class.php
-
message: '#^Property BookKeeping\:\:\$debit \(float\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 3
path: ../../../htdocs/accountancy/class/bookkeeping.class.php
-
message: '#^Property BookKeeping\:\:\$doc_ref \(string\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 5
path: ../../../htdocs/accountancy/class/bookkeeping.class.php
-
message: '#^Property BookKeeping\:\:\$doc_type \(string\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 5
path: ../../../htdocs/accountancy/class/bookkeeping.class.php
-
message: '#^Property BookKeeping\:\:\$fk_doc \(int\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 4
path: ../../../htdocs/accountancy/class/bookkeeping.class.php
-
message: '#^Property BookKeeping\:\:\$fk_docdet \(int\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 4
path: ../../../htdocs/accountancy/class/bookkeeping.class.php
-
message: '#^Property BookKeeping\:\:\$fk_user_author \(int\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 1
path: ../../../htdocs/accountancy/class/bookkeeping.class.php
-
message: '#^Property BookKeeping\:\:\$import_key \(string\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 4
path: ../../../htdocs/accountancy/class/bookkeeping.class.php
-
message: '#^Property BookKeeping\:\:\$journal_label \(string\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 4
path: ../../../htdocs/accountancy/class/bookkeeping.class.php
-
message: '#^Property BookKeeping\:\:\$label_compte \(string\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 5
path: ../../../htdocs/accountancy/class/bookkeeping.class.php
-
message: '#^Property BookKeeping\:\:\$label_operation \(string\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 5
path: ../../../htdocs/accountancy/class/bookkeeping.class.php
-
message: '#^Property BookKeeping\:\:\$montant \(float\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 3
path: ../../../htdocs/accountancy/class/bookkeeping.class.php
-
message: '#^Property BookKeeping\:\:\$numero_compte \(string\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 5
path: ../../../htdocs/accountancy/class/bookkeeping.class.php
-
message: '#^Property BookKeeping\:\:\$piece_num \(int\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 4
path: ../../../htdocs/accountancy/class/bookkeeping.class.php
-
message: '#^Property BookKeeping\:\:\$sens \(string\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 5
path: ../../../htdocs/accountancy/class/bookkeeping.class.php
-
message: '#^Property BookKeeping\:\:\$thirdparty_code \(string\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 5
path: ../../../htdocs/accountancy/class/bookkeeping.class.php
-
message: '#^Ternary operator condition is always true\.$#'
identifier: ternary.alwaysTrue
count: 2
path: ../../../htdocs/accountancy/class/bookkeeping.class.php
-
message: '#^Variable \$sortfield in empty\(\) always exists and is not falsy\.$#'
identifier: empty.variable
count: 1
path: ../../../htdocs/accountancy/class/bookkeeping.class.php
-
message: '#^If condition is always false\.$#'
identifier: if.alwaysFalse

View File

@@ -70,27 +70,27 @@ class BookKeeping extends CommonObject
public $date_lim_reglement;
/**
* @var string Doc type
* @var ?string Doc type
*/
public $doc_type;
/**
* @var string Doc ref
* @var ?string Doc ref
*/
public $doc_ref;
/**
* @var int ID
* @var ?int ID
*/
public $fk_doc;
/**
* @var int ID
* @var ?int ID
*/
public $fk_docdet;
/**
* @var string Thirdparty code
* @var ?string Thirdparty code
*/
public $thirdparty_code;
@@ -105,69 +105,69 @@ class BookKeeping extends CommonObject
public $subledger_label;
/**
* @var string doc_type
* @var ?string doc_type
*/
public $numero_compte;
/**
* @var string label compte
* @var ?string label compte
*/
public $label_compte;
/**
* @var string label operation
* @var ?string label operation
*/
public $label_operation;
/**
* @var float FEC:Debit
* @var ?float FEC:Debit
*/
public $debit;
/**
* @var float FEC:Credit
* @var ?float FEC:Credit
*/
public $credit;
/**
* @var float FEC:Amount (Not necessary)
* @var ?float FEC:Amount (Not necessary)
* @deprecated No more used (we have info into debit/credit and sens)
*/
public $montant;
/**
* @var float FEC:Amount (Not necessary)
* @var ?float FEC:Amount (Not necessary)
* @deprecated No more used (we have info into debit/credit and sens)
*/
public $amount;
/**
* @var string FEC:Sens (Not necessary)
* @var ?string FEC:Sens (Not necessary)
*/
public $sens;
/**
* @var int ID
* @var ?int ID
*/
public $fk_user_author;
/**
* @var string key for import
* @var ?string key for import
*/
public $import_key;
/**
* @var string code journal
* @var ?string code journal
*/
public $code_journal;
/**
* @var string label journal
* @var ?string label journal
*/
public $journal_label;
/**
* @var int accounting transaction id
* @var ?int accounting transaction id
*/
public $piece_num;
@@ -1055,7 +1055,7 @@ class BookKeeping extends CommonObject
$sql .= " AND t.subledger_account IS NOT NULL";
$sql .= " AND t.subledger_account <> ''";
$sortfield = 't.subledger_account'.($sortfield ? ','.$sortfield : '');
$sortorder = 'ASC'.($sortfield ? ','.$sortfield : '');
$sortorder = 'ASC'.($sortorder ? ','.$sortorder : '');
} else {
$sortfield = 't.numero_compte'.($sortfield ? ','.$sortfield : '');
$sortorder = 'ASC'.($sortorder ? ','.$sortorder : '');
@@ -1416,16 +1416,15 @@ class BookKeeping extends CommonObject
$sql .= " AND t.subledger_account <> ''";
$sql .= " GROUP BY t.numero_compte, t.subledger_account, t.subledger_label";
$sortfield = 't.subledger_account'.($sortfield ? ','.$sortfield : '');
$sortorder = 'ASC'.($sortfield ? ','.$sortfield : '');
$sortorder = 'ASC'.($sortorder ? ','.$sortorder : '');
} else {
$sql .= ' GROUP BY t.numero_compte';
$sortfield = 't.numero_compte'.($sortfield ? ','.$sortfield : '');
$sortorder = 'ASC'.($sortorder ? ','.$sortorder : '');
}
if (!empty($sortfield)) {
$sql .= $this->db->order($sortfield, $sortorder);
}
if (!empty($limit)) {
$sql .= $this->db->plimit($limit + 1, $offset);
}
@@ -1823,7 +1822,7 @@ class BookKeeping extends CommonObject
$this->db->begin();
// Call triggers
if (! $error && ! $notrigger) {
if (!$notrigger) {
$result = $this->call_trigger('BOOKKEEPING_DELETE', $user);
if ($result < 0) {
$error++;
@@ -2296,7 +2295,6 @@ class BookKeeping extends CommonObject
}
}
} elseif ($direction == 1) {
if (!$error) {
$sql = 'DELETE FROM '.$this->db->prefix().$this->table_element.'_tmp WHERE piece_num = '.((int) $piece_num).' AND entity = ' .((int) $conf->entity);
$resql = $this->db->query($sql);
if (!$resql) {
@@ -2304,7 +2302,6 @@ class BookKeeping extends CommonObject
$this->errors[] = 'Error '.$this->db->lasterror();
dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
}
}
if (!$error) {
$sql = 'INSERT INTO '.$this->db->prefix().$this->table_element.'_tmp (doc_date, doc_type, ref,';

View File

@@ -7,7 +7,7 @@
* Copyright (C) 2015-2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2017 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -935,7 +935,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $
if (preg_match('/\{(jj+)\}/i', $mask, $regJournal)) {
$journalcode = 'JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ';
if (is_object($objbookkeeping)) {
$journalcode = $objbookkeeping->code_journal;
$journalcode = (string) $objbookkeeping->code_journal;
}
$maskjournal = $regJournal[1];