Fix error management
This commit is contained in:
parent
8a55b4d82e
commit
646ccc1354
@ -191,11 +191,14 @@ class StockMovements extends DolibarrApi
|
||||
$type = 3;
|
||||
}
|
||||
|
||||
$eatBy = empty($dluo) ? '' : (new DateTime($dluo))->getTimestamp();
|
||||
$sellBy = empty($dlc) ? '' : (new DateTime($dlc))->getTimestamp();;
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
$eatBy = empty($dluo) ? '' : dol_stringtotime($dluo);
|
||||
$sellBy = empty($dlc) ? '' : dol_stringtotime($dlc);
|
||||
|
||||
if($this->stockmovement->_create(DolibarrApiAccess::$user, $product_id, $warehouse_id, $qty, $type, $price, $movementlabel, $movementcode, '', $eatBy, $sellBy, $lot) <= 0) {
|
||||
throw new RestException(503, 'Error when create stock movement : '.$this->stockmovement->error);
|
||||
$errormessage = $this->stockmovement->error;
|
||||
if (empty($errormessage)) $errormessage = join(',', $this->stockmovement->errors);
|
||||
throw new RestException(503, 'Error when create stock movement : '.$errormessage);
|
||||
}
|
||||
|
||||
return $this->stockmovement->id;
|
||||
|
||||
@ -172,7 +172,7 @@ class MouvementStock extends CommonObject
|
||||
{
|
||||
if (empty($batch))
|
||||
{
|
||||
$this->errors[]=$langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData", $product->ref);
|
||||
$this->errors[]=$langs->transnoentitiesnoconv("ErrorTryToMakeMoveOnProductRequiringBatchData", $product->ref);
|
||||
dol_syslog("Try to make a movement of a product with status_batch on without any batch data");
|
||||
|
||||
$this->db->rollback();
|
||||
@ -207,7 +207,8 @@ class MouvementStock extends CommonObject
|
||||
if ($this->db->jdate($obj->eatby) != $eatby && $this->db->jdate($obj->eatby) != $eatbywithouthour) // We test date without hours and with hours for backward compatibility
|
||||
{
|
||||
// If found and eatby/sellby defined into table and provided and differs, return error
|
||||
$this->errors[]=$langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->eatby), 'dayhour'), dol_print_date($eatby, 'dayhour'));
|
||||
$langs->load("stocks");
|
||||
$this->errors[] = $langs->transnoentitiesnoconv("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->eatby), 'dayhour'), dol_print_date($eatbywithouthour, 'dayhour'));
|
||||
dol_syslog("ThisSerialAlreadyExistWithDifferentDate batch=".$batch.", eatby found into product_lot = ".$obj->eatby." = ".dol_print_date($this->db->jdate($obj->eatby), 'dayhourrfc')." so eatbywithouthour = ".$eatbywithouthour." = ".dol_print_date($eatbywithouthour)." - eatby provided = ".$eatby." = ".dol_print_date($eatby, 'dayhourrfc'), LOG_ERR);
|
||||
$this->db->rollback();
|
||||
return -3;
|
||||
@ -244,7 +245,7 @@ class MouvementStock extends CommonObject
|
||||
if ($this->db->jdate($obj->sellby) != $sellby && $this->db->jdate($obj->sellby) != $sellbywithouthour) // We test date without hours and with hours for backward compatibility
|
||||
{
|
||||
// If found and eatby/sellby defined into table and provided and differs, return error
|
||||
$this->errors[]=$langs->trans("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby));
|
||||
$this->errors[]=$langs->transnoentitiesnoconv("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby));
|
||||
dol_syslog($langs->transnoentities("ThisSerialAlreadyExistWithDifferentDate", $batch, dol_print_date($this->db->jdate($obj->sellby)), dol_print_date($sellby)), LOG_ERR);
|
||||
$this->db->rollback();
|
||||
return -3;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user