mirror of
https://github.com/grocy/grocy.git
synced 2026-04-06 21:06: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']));
|
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)
|
public function StockBooking(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||||
{
|
{
|
||||||
try
|
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": {
|
"/stock/volatile": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "Returns all products which are expiring soon, are already expired or currently missing",
|
"summary": "Returns all products which are expiring soon, are already expired or currently missing",
|
||||||
|
|
@ -3203,7 +3244,6 @@
|
||||||
"quantity_unit_conversions",
|
"quantity_unit_conversions",
|
||||||
"shopping_list",
|
"shopping_list",
|
||||||
"shopping_lists",
|
"shopping_lists",
|
||||||
"stock",
|
|
||||||
"recipes",
|
"recipes",
|
||||||
"recipes_pos",
|
"recipes_pos",
|
||||||
"recipes_nestings",
|
"recipes_nestings",
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ $(document).on("click", ".product-add-to-shopping-list-button", function(e)
|
||||||
|
|
||||||
function RefreshStockDetailRow(stockRowId)
|
function RefreshStockDetailRow(stockRowId)
|
||||||
{
|
{
|
||||||
Grocy.Api.Get("objects/stock/" + stockRowId,
|
Grocy.Api.Get("stock/" + stockRowId + "/entry",
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
var stockRow = $('#stock-' + stockRowId + '-row');
|
var stockRow = $('#stock-' + stockRowId + '-row');
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var stockRowId = GetUriParam('stockRowId');
|
var stockRowId = GetUriParam('stockRowId');
|
||||||
Grocy.Api.Get("objects/stock/" + stockRowId,
|
Grocy.Api.Get("stock/" + stockRowId + "/entry",
|
||||||
function(stockEntry)
|
function(stockEntry)
|
||||||
{
|
{
|
||||||
Grocy.Components.LocationPicker.SetId(stockEntry.location_id);
|
Grocy.Components.LocationPicker.SetId(stockEntry.location_id);
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,7 @@ $app->group('/api', function()
|
||||||
if (GROCY_FEATURE_FLAG_STOCK)
|
if (GROCY_FEATURE_FLAG_STOCK)
|
||||||
{
|
{
|
||||||
$this->get('/stock', '\Grocy\Controllers\StockApiController:CurrentStock');
|
$this->get('/stock', '\Grocy\Controllers\StockApiController:CurrentStock');
|
||||||
|
$this->get('/stock/{entryId}/entry', '\Grocy\Controllers\StockApiController:StockEntry');
|
||||||
$this->put('/stock', '\Grocy\Controllers\StockApiController:EditStock');
|
$this->put('/stock', '\Grocy\Controllers\StockApiController:EditStock');
|
||||||
$this->get('/stock/volatile', '\Grocy\Controllers\StockApiController:CurrentVolatileStock');
|
$this->get('/stock/volatile', '\Grocy\Controllers\StockApiController:CurrentVolatileStock');
|
||||||
$this->get('/stock/products/{productId}', '\Grocy\Controllers\StockApiController:ProductDetails');
|
$this->get('/stock/products/{productId}', '\Grocy\Controllers\StockApiController:ProductDetails');
|
||||||
|
|
|
||||||
|
|
@ -170,6 +170,11 @@ class StockService extends BaseService
|
||||||
return $returnData;
|
return $returnData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function GetStockEntry($entryId)
|
||||||
|
{
|
||||||
|
return $this->Database->stock()->where('id', $entryId)->fetch();
|
||||||
|
}
|
||||||
|
|
||||||
public function GetProductStockEntries($productId, $excludeOpened = false)
|
public function GetProductStockEntries($productId, $excludeOpened = false)
|
||||||
{
|
{
|
||||||
// In order of next use:
|
// In order of next use:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user