clean code (#36054)
* clean code * clean code * avoid obj to be false * clean code * clean code * clean code * clean code * clean code * clean code * clean code
This commit is contained in:
parent
073426d97e
commit
ff7a684a0a
6 changed files with 31 additions and 113 deletions
|
|
@ -11880,30 +11880,12 @@ parameters:
|
|||
count: 1
|
||||
path: ../../../htdocs/product/class/productbatch.class.php
|
||||
|
||||
-
|
||||
message: '#^Property Productbatch\:\:\$batch \(string\) in isset\(\) is not nullable\.$#'
|
||||
identifier: isset.property
|
||||
count: 3
|
||||
path: ../../../htdocs/product/class/productbatch.class.php
|
||||
|
||||
-
|
||||
message: '#^Property Productbatch\:\:\$eatby \(int\|string\) in isset\(\) is not nullable\.$#'
|
||||
identifier: isset.property
|
||||
count: 1
|
||||
path: ../../../htdocs/product/class/productbatch.class.php
|
||||
|
||||
-
|
||||
message: '#^Property Productbatch\:\:\$qty \(float\) in isset\(\) is not nullable\.$#'
|
||||
identifier: isset.property
|
||||
count: 3
|
||||
path: ../../../htdocs/product/class/productbatch.class.php
|
||||
|
||||
-
|
||||
message: '#^Property Productbatch\:\:\$sellby \(int\|string\) in isset\(\) is not nullable\.$#'
|
||||
identifier: isset.property
|
||||
count: 1
|
||||
path: ../../../htdocs/product/class/productbatch.class.php
|
||||
|
||||
-
|
||||
message: '#^Loose comparison using \=\= between '''' and 0 will always evaluate to false\.$#'
|
||||
identifier: equal.alwaysFalse
|
||||
|
|
@ -12492,66 +12474,12 @@ parameters:
|
|||
count: 1
|
||||
path: ../../../htdocs/product/stock/class/productlot.class.php
|
||||
|
||||
-
|
||||
message: '#^Property Productlot\:\:\$batch \(string\) in isset\(\) is not nullable\.$#'
|
||||
identifier: isset.property
|
||||
count: 4
|
||||
path: ../../../htdocs/product/stock/class/productlot.class.php
|
||||
|
||||
-
|
||||
message: '#^Property Productlot\:\:\$eatby \(int\|string\) in isset\(\) is not nullable\.$#'
|
||||
identifier: isset.property
|
||||
count: 2
|
||||
path: ../../../htdocs/product/stock/class/productlot.class.php
|
||||
|
||||
-
|
||||
message: '#^Property Productlot\:\:\$eol_date \(int\|string\) in isset\(\) is not nullable\.$#'
|
||||
identifier: isset.property
|
||||
count: 2
|
||||
path: ../../../htdocs/product/stock/class/productlot.class.php
|
||||
|
||||
-
|
||||
message: '#^Property Productlot\:\:\$fk_product \(int\) in isset\(\) is not nullable\.$#'
|
||||
identifier: isset.property
|
||||
count: 4
|
||||
path: ../../../htdocs/product/stock/class/productlot.class.php
|
||||
|
||||
-
|
||||
message: '#^Property Productlot\:\:\$fk_user_creat \(int\) in isset\(\) is not nullable\.$#'
|
||||
identifier: isset.property
|
||||
count: 4
|
||||
path: ../../../htdocs/product/stock/class/productlot.class.php
|
||||
|
||||
-
|
||||
message: '#^Property Productlot\:\:\$fk_user_modif \(int\) in isset\(\) is not nullable\.$#'
|
||||
identifier: isset.property
|
||||
count: 4
|
||||
path: ../../../htdocs/product/stock/class/productlot.class.php
|
||||
|
||||
-
|
||||
message: '#^Property Productlot\:\:\$import_key \(string\) in isset\(\) is not nullable\.$#'
|
||||
identifier: isset.property
|
||||
count: 4
|
||||
path: ../../../htdocs/product/stock/class/productlot.class.php
|
||||
|
||||
-
|
||||
message: '#^Property Productlot\:\:\$manufacturing_date \(int\|string\) in isset\(\) is not nullable\.$#'
|
||||
identifier: isset.property
|
||||
count: 2
|
||||
path: ../../../htdocs/product/stock/class/productlot.class.php
|
||||
|
||||
-
|
||||
message: '#^Property Productlot\:\:\$scrapping_date \(int\|string\) in isset\(\) is not nullable\.$#'
|
||||
identifier: isset.property
|
||||
count: 2
|
||||
path: ../../../htdocs/product/stock/class/productlot.class.php
|
||||
|
||||
-
|
||||
message: '#^Property Productlot\:\:\$sellby \(int\|string\) in isset\(\) is not nullable\.$#'
|
||||
identifier: isset.property
|
||||
count: 2
|
||||
path: ../../../htdocs/product/stock/class/productlot.class.php
|
||||
|
||||
-
|
||||
message: '#^Negated boolean expression is always true\.$#'
|
||||
identifier: booleanNot.alwaysTrue
|
||||
|
|
@ -12570,12 +12498,6 @@ parameters:
|
|||
count: 4
|
||||
path: ../../../htdocs/product/stock/class/productstockentrepot.class.php
|
||||
|
||||
-
|
||||
message: '#^Property ProductStockEntrepot\:\:\$import_key \(string\) in isset\(\) is not nullable\.$#'
|
||||
identifier: isset.property
|
||||
count: 4
|
||||
path: ../../../htdocs/product/stock/class/productstockentrepot.class.php
|
||||
|
||||
-
|
||||
message: '#^Variable \$action might not be defined\.$#'
|
||||
identifier: variable.undefined
|
||||
|
|
|
|||
|
|
@ -6218,9 +6218,9 @@ class Product extends CommonObject
|
|||
* @param int<0,1> $movement 0 = add, 1 = remove
|
||||
* @param string $label Label of stock movement
|
||||
* @param int|float $price Price to use for stock eval
|
||||
* @param int|string $dlc eat-by date
|
||||
* @param int|string $dluo sell-by date
|
||||
* @param string $lot Lot number
|
||||
* @param int|''|null $dlc eat-by date
|
||||
* @param int|''|null $dluo sell-by date
|
||||
* @param string|null $lot Lot number
|
||||
* @param string $inventorycode Inventory code
|
||||
* @param string $origin_element Origin element type
|
||||
* @param ?int $origin_id Origin id of element
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class Productbatch extends CommonObject
|
|||
public $fk_product_stock;
|
||||
|
||||
/**
|
||||
* @var string batch number
|
||||
* @var null|string batch number
|
||||
*/
|
||||
public $batch = '';
|
||||
|
||||
|
|
@ -81,12 +81,13 @@ class Productbatch extends CommonObject
|
|||
public $lotid;
|
||||
|
||||
/**
|
||||
* @var int|''
|
||||
* @var int|''|null
|
||||
* @deprecated
|
||||
*/
|
||||
public $sellby = ''; // dlc
|
||||
|
||||
/**
|
||||
* @var int|''
|
||||
* @var int|''|null
|
||||
* @deprecated
|
||||
*/
|
||||
public $eatby = ''; // dmd/dluo
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ class MouvementStock extends CommonObject
|
|||
* @param int|string $datem Force date of movement
|
||||
* @param int|'' $eatby eat-by date. Will be used if lot does not exists yet and will be created.
|
||||
* @param int|'' $sellby sell-by date. Will be used if lot does not exists yet and will be created.
|
||||
* @param string $batch batch number
|
||||
* @param string|null $batch batch number
|
||||
* @param bool $skip_batch If set to true, stock movement is done without impacting batch record
|
||||
* @param int $id_product_batch Id product_batch (when skip_batch is false and we already know which record of product_batch table to use)
|
||||
* @param int<0,1> $disablestockchangeforsubproduct Disable stock change for sub-products of kit (useful only if product is a kit)
|
||||
|
|
@ -362,8 +362,7 @@ class MouvementStock extends CommonObject
|
|||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num > 0) {
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
while ($i < $num && $obj = $this->db->fetch_object($resql)) {
|
||||
if ($obj->eatby) {
|
||||
if ($eatby) {
|
||||
$tmparray = dol_getdate((int) $eatby, true);
|
||||
|
|
@ -386,8 +385,7 @@ class MouvementStock extends CommonObject
|
|||
$productlot->eatby = $eatby;
|
||||
$result = $productlot->update($user);
|
||||
if ($result <= 0) {
|
||||
$this->error = $productlot->error;
|
||||
$this->errors = $productlot->errors;
|
||||
$this->setErrorsFromObject($productlot);
|
||||
$this->db->rollback();
|
||||
return -5;
|
||||
}
|
||||
|
|
@ -414,8 +412,7 @@ class MouvementStock extends CommonObject
|
|||
$productlot->sellby = $sellby;
|
||||
$result = $productlot->update($user);
|
||||
if ($result <= 0) {
|
||||
$this->error = $productlot->error;
|
||||
$this->errors = $productlot->errors;
|
||||
$this->setErrorsFromObject($productlot);
|
||||
$this->db->rollback();
|
||||
return -5;
|
||||
}
|
||||
|
|
@ -436,8 +433,7 @@ class MouvementStock extends CommonObject
|
|||
$productlot->sellby = $sellby;
|
||||
$result = $productlot->create($user);
|
||||
if ($result <= 0) {
|
||||
$this->error = $productlot->error;
|
||||
$this->errors = $productlot->errors;
|
||||
$this->setErrorsFromObject($productlot);
|
||||
$this->db->rollback();
|
||||
return -4;
|
||||
}
|
||||
|
|
@ -475,8 +471,8 @@ class MouvementStock extends CommonObject
|
|||
$tmpwarehouse = new Entrepot($this->db);
|
||||
$tmpwarehouse->fetch($entrepot_id);
|
||||
|
||||
$this->error = $langs->trans('qtyToTranferLotIsNotEnough', $product->ref, $batch, $qtyisnotenough, $tmpwarehouse->ref);
|
||||
$this->errors[] = $langs->trans('qtyToTranferLotIsNotEnough', $product->ref, $batch, $qtyisnotenough, $tmpwarehouse->ref);
|
||||
$this->error = $langs->trans('qtyToTranferLotIsNotEnough', $product->ref, (string) $batch, $qtyisnotenough, $tmpwarehouse->ref);
|
||||
$this->errors[] = $langs->trans('qtyToTranferLotIsNotEnough', $product->ref, (string) $batch, $qtyisnotenough, $tmpwarehouse->ref);
|
||||
$this->db->rollback();
|
||||
return -8;
|
||||
}
|
||||
|
|
@ -513,7 +509,7 @@ class MouvementStock extends CommonObject
|
|||
$sql .= " fk_entrepot, value, type_mouvement, fk_user_author, label, inventorycode, price, fk_origin, origintype, fk_projet";
|
||||
$sql .= ")";
|
||||
$sql .= " VALUES ('".$this->db->idate($this->datem)."', ".((int) $this->product_id).", ";
|
||||
$sql .= " ".($batch ? "'".$this->db->escape($batch)."'" : "null").", ";
|
||||
$sql .= " ".(isset($batch) ? "'".$this->db->escape($batch)."'" : "null").", ";
|
||||
$sql .= " ".($eatby ? "'".$this->db->idate($eatby)."'" : "null").", ";
|
||||
$sql .= " ".($sellby ? "'".$this->db->idate($sellby)."'" : "null").", ";
|
||||
$sql .= " ".((int) $this->entrepot_id).", ".((float) $this->qty).", ".((int) $this->type).",";
|
||||
|
|
@ -621,11 +617,11 @@ class MouvementStock extends CommonObject
|
|||
if ($id_product_batch > 0) {
|
||||
$result = $this->createBatch($id_product_batch, $qty);
|
||||
if ($result == -2 && $fk_product_stock > 0) { // The entry for this product batch does not exists anymore, bu we already have a llx_product_stock, so we recreate the batch entry in product_batch
|
||||
$param_batch = array('fk_product_stock' => $fk_product_stock, 'batchnumber' => $batch);
|
||||
$param_batch = array('fk_product_stock' => $fk_product_stock, 'batchnumber' => (string) $batch);
|
||||
$result = $this->createBatch($param_batch, $qty);
|
||||
}
|
||||
} else {
|
||||
$param_batch = array('fk_product_stock' => $fk_product_stock, 'batchnumber' => $batch);
|
||||
$param_batch = array('fk_product_stock' => $fk_product_stock, 'batchnumber' => (string) $batch);
|
||||
$result = $this->createBatch($param_batch, $qty);
|
||||
}
|
||||
if ($result < 0) {
|
||||
|
|
@ -678,9 +674,9 @@ class MouvementStock extends CommonObject
|
|||
// Check unicity for serial numbered equipment once all movement were done.
|
||||
if (!$error && isModEnabled('productbatch') && $product->hasbatch() && !$skip_batch) {
|
||||
if ($product->status_batch == 2 && $qty > 0) { // We check only if we increased qty
|
||||
if ($this->getBatchCount($fk_product, $batch) > 1) {
|
||||
if ($this->getBatchCount($fk_product, (string) $batch) > 1) {
|
||||
$error++;
|
||||
$this->errors[] = $langs->trans("TooManyQtyForSerialNumber", $product->ref, $batch);
|
||||
$this->errors[] = $langs->trans("TooManyQtyForSerialNumber", $product->ref, (string) $batch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -984,8 +980,7 @@ class MouvementStock extends CommonObject
|
|||
|
||||
$result = $pdluo->create($user, 1);
|
||||
if ($result < 0) {
|
||||
$this->error = $pdluo->error;
|
||||
$this->errors = $pdluo->errors;
|
||||
$this->setErrorsFromObject($pdluo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,32 +174,32 @@ class Productlot extends CommonObject
|
|||
public $fk_product;
|
||||
|
||||
/**
|
||||
* @var string batch ref
|
||||
* @var ?string batch ref
|
||||
*/
|
||||
public $batch;
|
||||
|
||||
/**
|
||||
* @var int|string eatby
|
||||
* @var int|''|null eatby
|
||||
*/
|
||||
public $eatby = '';
|
||||
|
||||
/**
|
||||
* @var int|string sellby
|
||||
* @var int|''|null sellby
|
||||
*/
|
||||
public $sellby = '';
|
||||
|
||||
/**
|
||||
* @var int|'' eol_date
|
||||
* @var int|''|null eol_date
|
||||
*/
|
||||
public $eol_date = '';
|
||||
|
||||
/**
|
||||
* @var int|'' manufacturing_date
|
||||
* @var int|''|null manufacturing_date
|
||||
*/
|
||||
public $manufacturing_date = '';
|
||||
|
||||
/**
|
||||
* @var int|'' scrapping_date
|
||||
* @var int|''|null scrapping_date
|
||||
*/
|
||||
public $scrapping_date = '';
|
||||
//public $commissionning_date = '';
|
||||
|
|
@ -217,17 +217,17 @@ class Productlot extends CommonObject
|
|||
public $datec = '';
|
||||
|
||||
/**
|
||||
* @var int user ID
|
||||
* @var int|null user ID
|
||||
*/
|
||||
public $fk_user_creat;
|
||||
|
||||
/**
|
||||
* @var int user ID
|
||||
* @var int|null user ID
|
||||
*/
|
||||
public $fk_user_modif;
|
||||
|
||||
/**
|
||||
* @var string import key
|
||||
* @var null|string import key
|
||||
*/
|
||||
public $import_key;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* Copyright (C) 2014-2016 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -68,7 +68,7 @@ class ProductStockEntrepot extends CommonObject
|
|||
*/
|
||||
public $desiredstock;
|
||||
/**
|
||||
* @var string
|
||||
* @var null|string
|
||||
*/
|
||||
public $import_key;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue