mirror of
https://github.com/grocy/grocy.git
synced 2026-04-05 20:36:15 +02:00
Stock updates
This commit is contained in:
parent
36a6c56f5c
commit
94e35ef9fd
|
|
@ -580,6 +580,11 @@ class StockApiController extends BaseApiController
|
|||
return $this->ApiResponse($this->StockService->GetProductStockLocations($args['productId']));
|
||||
}
|
||||
|
||||
public function StockEntry(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
return $this->ApiResponse($this->StockService->GetStockEntry($args['entryId']));
|
||||
}
|
||||
|
||||
public function StockBooking(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
try
|
||||
|
|
|
|||
|
|
@ -1124,6 +1124,47 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/stock/{entryId}/entry": {
|
||||
"get": {
|
||||
"summary": "Returns details of the given stock",
|
||||
"tags": [
|
||||
"Stock"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"in": "path",
|
||||
"name": "entryId",
|
||||
"required": true,
|
||||
"description": "A valid stock row id",
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A StockEntry Response object",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/StockEntry"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "The operation was not successful (possible errors are: Not existing product)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/GenericErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/stock/volatile": {
|
||||
"get": {
|
||||
"summary": "Returns all products which are expiring soon, are already expired or currently missing",
|
||||
|
|
@ -3203,7 +3244,6 @@
|
|||
"quantity_unit_conversions",
|
||||
"shopping_list",
|
||||
"shopping_lists",
|
||||
"stock",
|
||||
"recipes",
|
||||
"recipes_pos",
|
||||
"recipes_nestings",
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ $(document).on("click", ".product-add-to-shopping-list-button", function(e)
|
|||
|
||||
function RefreshStockDetailRow(stockRowId)
|
||||
{
|
||||
Grocy.Api.Get("objects/stock/" + stockRowId,
|
||||
Grocy.Api.Get("stock/" + stockRowId + "/entry",
|
||||
function(result)
|
||||
{
|
||||
var stockRow = $('#stock-' + stockRowId + '-row');
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
$(document).ready(function() {
|
||||
var stockRowId = GetUriParam('stockRowId');
|
||||
Grocy.Api.Get("objects/stock/" + stockRowId,
|
||||
Grocy.Api.Get("stock/" + stockRowId + "/entry",
|
||||
function(stockEntry)
|
||||
{
|
||||
Grocy.Components.LocationPicker.SetId(stockEntry.location_id);
|
||||
|
|
|
|||
|
|
@ -161,6 +161,7 @@ $app->group('/api', function()
|
|||
if (GROCY_FEATURE_FLAG_STOCK)
|
||||
{
|
||||
$this->get('/stock', '\Grocy\Controllers\StockApiController:CurrentStock');
|
||||
$this->get('/stock/{entryId}/entry', '\Grocy\Controllers\StockApiController:StockEntry');
|
||||
$this->put('/stock', '\Grocy\Controllers\StockApiController:EditStock');
|
||||
$this->get('/stock/volatile', '\Grocy\Controllers\StockApiController:CurrentVolatileStock');
|
||||
$this->get('/stock/products/{productId}', '\Grocy\Controllers\StockApiController:ProductDetails');
|
||||
|
|
|
|||
|
|
@ -170,6 +170,11 @@ class StockService extends BaseService
|
|||
return $returnData;
|
||||
}
|
||||
|
||||
public function GetStockEntry($entryId)
|
||||
{
|
||||
return $this->Database->stock()->where('id', $entryId)->fetch();
|
||||
}
|
||||
|
||||
public function GetProductStockEntries($productId, $excludeOpened = false)
|
||||
{
|
||||
// In order of next use:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user