FIX - API - DLC/DLUO date for stock movement

Instead of giving a string to the creation of a stock movement, we have
to give an integer.

This PR fixes that.

[see: X]
This commit is contained in:
Laurent De Coninck 2020-01-23 09:41:22 +01:00
parent 553107258e
commit 7ec17f17d5
No known key found for this signature in database
GPG Key ID: 2BA964D76BB3A499

View File

@ -186,10 +186,15 @@ class StockMovements extends DolibarrApi
}
// Type increase or decrease
if ($qty >= 0) $type = 3;
else $type = 2;
$type = 2;
if ($qty >= 0){
$type = 3;
}
if($this->stockmovement->_create(DolibarrApiAccess::$user, $product_id, $warehouse_id, $qty, $type, $price, $movementlabel, $movementcode, '', $dlc, $dluo, $lot) <= 0) {
$eatBy = empty($dluo) ? '' : (new DateTime($dluo))->getTimestamp();
$sellBy = empty($dlc) ? '' : (new DateTime($dlc))->getTimestamp();;
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);
}