mirror of
https://github.com/grocy/grocy.git
synced 2026-04-05 20:36:15 +02:00
Simplify
This commit is contained in:
parent
ea2b7996d1
commit
cf0162cb54
|
|
@ -278,11 +278,7 @@ class StockApiController extends BaseApiController
|
||||||
}
|
}
|
||||||
|
|
||||||
$specificStockEntryId = 'default';
|
$specificStockEntryId = 'default';
|
||||||
if (array_key_exists('stock_id', $args) && !empty($args['stock_id']))
|
if (array_key_exists('stock_entry_id', $requestBody) && !empty($requestBody['stock_entry_id']))
|
||||||
{
|
|
||||||
$specificStockEntryId = $args['stock_id'];
|
|
||||||
}
|
|
||||||
elseif (array_key_exists('stock_entry_id', $requestBody) && !empty($requestBody['stock_entry_id']))
|
|
||||||
{
|
{
|
||||||
$specificStockEntryId = $requestBody['stock_entry_id'];
|
$specificStockEntryId = $requestBody['stock_entry_id'];
|
||||||
}
|
}
|
||||||
|
|
@ -326,24 +322,19 @@ class StockApiController extends BaseApiController
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$barcode = $args['barcode'];
|
$args['productId'] = $this->getStockService()->GetProductIdFromBarcode($args['barcode']);
|
||||||
if (Grocycode::Validate($barcode))
|
|
||||||
|
if (Grocycode::Validate($args['barcode']))
|
||||||
{
|
{
|
||||||
$gc = new Grocycode($barcode);
|
$gc = new Grocycode($args['barcode']);
|
||||||
if ($gc->GetType() != Grocycode::PRODUCT)
|
|
||||||
{
|
|
||||||
throw new \Exception('Invalid grocycode type');
|
|
||||||
}
|
|
||||||
$args['productId'] = $gc->GetId();
|
|
||||||
if ($gc->GetExtraData())
|
if ($gc->GetExtraData())
|
||||||
{
|
{
|
||||||
$args['stock_id'] = $gc->GetExtraData()[0];
|
$requestBody = $request->getParsedBody();
|
||||||
|
$requestBody['stock_entry_id'] = $gc->GetExtraData()[0];
|
||||||
|
$request = $request->withParsedBody($requestBody);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$args['productId'] = $this->getStockService()->GetProductIdFromBarcode($args['barcode']);
|
|
||||||
}
|
|
||||||
return $this->ConsumeProduct($request, $response, $args);
|
return $this->ConsumeProduct($request, $response, $args);
|
||||||
}
|
}
|
||||||
catch (\Exception $ex)
|
catch (\Exception $ex)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user