Merge pull request #12912 from laudeco/hotfix/stock_movement_date_as_integer

FIX - API - DLC/DLUO date for stock movement
This commit is contained in:
Laurent Destailleur 2020-01-23 11:37:31 +01:00 committed by GitHub
commit 8a55b4d82e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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);
}