mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
Improve API stock action endpoint response (closes #769)
This commit is contained in:
parent
cef3086a63
commit
a5326aa95c
@ -194,6 +194,19 @@
|
|||||||
- The field `expiring_products` was renamed to `due_products`
|
- The field `expiring_products` was renamed to `due_products`
|
||||||
- The field `expired_products` now only contains expired products (so them with `Due date type = Expiration date`)
|
- The field `expired_products` now only contains expired products (so them with `Due date type = Expiration date`)
|
||||||
- The new field `overdue_products` contains only overdue products (so them with `Due date type = Best before date`)
|
- The new field `overdue_products` contains only overdue products (so them with `Due date type = Best before date`)
|
||||||
|
- The following endpoints now return all bookings of the transaction (so the response is now an array, was before a single stock booking - and a random one if the transaction affected multiple stock entries)
|
||||||
|
- PUT `/stock/entry/{entryId}`
|
||||||
|
- POST `/stock/products/{productId}/add`
|
||||||
|
- POST `/stock/products/{productId}/consume`
|
||||||
|
- POST `/stock/products/{productId}/transfer`
|
||||||
|
- POST `/stock/products/{productId}/inventory`
|
||||||
|
- POST `/stock/products/{productId}/open`
|
||||||
|
- POST `/stock/products/by-barcode/{barcode}/add`
|
||||||
|
- POST `/stock/products/by-barcode/{barcode}/consume`
|
||||||
|
- POST `/stock/products/by-barcode/{barcode}/transfer`
|
||||||
|
- POST `/stock/products/by-barcode/{barcode}/inventory`
|
||||||
|
- POST `/stock/products/by-barcode/{barcode}/open`
|
||||||
|
- (The response is the same as if you would fetch the stock transaction via `/stock/transactions/{transactionId}`)
|
||||||
- For better integration (apps), it's now possible to show a QR-Code for API keys (thanks @fipwmaqzufheoxq92ebc)
|
- For better integration (apps), it's now possible to show a QR-Code for API keys (thanks @fipwmaqzufheoxq92ebc)
|
||||||
- New QR-Code button on the "Manage API keys"-page (top right corner settings menu), the QR-Codes contains `<API-Url>|<API-Key>`
|
- New QR-Code button on the "Manage API keys"-page (top right corner settings menu), the QR-Codes contains `<API-Url>|<API-Key>`
|
||||||
- And on the calendar page when using the button "Share/Integrate calendar (iCal)", there the QR-Codes contains the Share-URL (which is displayed in the textbox above)
|
- And on the calendar page when using the button "Share/Integrate calendar (iCal)", there the QR-Codes contains the Share-URL (which is displayed in the textbox above)
|
||||||
|
@ -139,8 +139,9 @@ class StockApiController extends BaseApiController
|
|||||||
$transactionType = $requestBody['transactiontype'];
|
$transactionType = $requestBody['transactiontype'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$bookingId = $this->getStockService()->AddProduct($args['productId'], $requestBody['amount'], $bestBeforeDate, $transactionType, $purchasedDate, $price, $locationId, $shoppingLocationId);
|
$transactionId = $this->getStockService()->AddProduct($args['productId'], $requestBody['amount'], $bestBeforeDate, $transactionType, $purchasedDate, $price, $locationId, $shoppingLocationId);
|
||||||
return $this->ApiResponse($response, $this->getDatabase()->stock_log($bookingId));
|
$args['transactionId'] = $transactionId;
|
||||||
|
return $this->StockTransactions($request, $response, $args);
|
||||||
}
|
}
|
||||||
catch (\Exception $ex)
|
catch (\Exception $ex)
|
||||||
{
|
{
|
||||||
@ -293,8 +294,9 @@ class StockApiController extends BaseApiController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$transactionId = null;
|
$transactionId = null;
|
||||||
$bookingId = $this->getStockService()->ConsumeProduct($args['productId'], $requestBody['amount'], $spoiled, $transactionType, $specificStockEntryId, $recipeId, $locationId, $transactionId, $allowSubproductSubstitution, $consumeExact);
|
$transactionId = $this->getStockService()->ConsumeProduct($args['productId'], $requestBody['amount'], $spoiled, $transactionType, $specificStockEntryId, $recipeId, $locationId, $transactionId, $allowSubproductSubstitution, $consumeExact);
|
||||||
return $this->ApiResponse($response, $this->getDatabase()->stock_log($bookingId));
|
$args['transactionId'] = $transactionId;
|
||||||
|
return $this->StockTransactions($request, $response, $args);
|
||||||
}
|
}
|
||||||
catch (\Exception $ex)
|
catch (\Exception $ex)
|
||||||
{
|
{
|
||||||
@ -387,8 +389,9 @@ class StockApiController extends BaseApiController
|
|||||||
$shoppingLocationId = $requestBody['shopping_location_id'];
|
$shoppingLocationId = $requestBody['shopping_location_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$bookingId = $this->getStockService()->EditStockEntry($args['entryId'], $requestBody['amount'], $bestBeforeDate, $locationId, $shoppingLocationId, $price, $requestBody['open'], $requestBody['purchased_date']);
|
$transactionId = $this->getStockService()->EditStockEntry($args['entryId'], $requestBody['amount'], $bestBeforeDate, $locationId, $shoppingLocationId, $price, $requestBody['open'], $requestBody['purchased_date']);
|
||||||
return $this->ApiResponse($response, $this->getDatabase()->stock_log($bookingId));
|
$args['transactionId'] = $transactionId;
|
||||||
|
return $this->StockTransactions($request, $response, $args);
|
||||||
}
|
}
|
||||||
catch (\Exception $ex)
|
catch (\Exception $ex)
|
||||||
{
|
{
|
||||||
@ -465,8 +468,9 @@ class StockApiController extends BaseApiController
|
|||||||
$shoppingLocationId = $requestBody['shopping_location_id'];
|
$shoppingLocationId = $requestBody['shopping_location_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$bookingId = $this->getStockService()->InventoryProduct($args['productId'], $requestBody['new_amount'], $bestBeforeDate, $locationId, $price, $shoppingLocationId, $purchasedDate);
|
$transactionId = $this->getStockService()->InventoryProduct($args['productId'], $requestBody['new_amount'], $bestBeforeDate, $locationId, $price, $shoppingLocationId, $purchasedDate);
|
||||||
return $this->ApiResponse($response, $this->getDatabase()->stock_log($bookingId));
|
$args['transactionId'] = $transactionId;
|
||||||
|
return $this->StockTransactions($request, $response, $args);
|
||||||
}
|
}
|
||||||
catch (\Exception $ex)
|
catch (\Exception $ex)
|
||||||
{
|
{
|
||||||
@ -518,9 +522,9 @@ class StockApiController extends BaseApiController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$transactionId = null;
|
$transactionId = null;
|
||||||
|
$transactionId = $this->getStockService()->OpenProduct($args['productId'], $requestBody['amount'], $specificStockEntryId, $transactionId, $allowSubproductSubstitution);
|
||||||
$bookingId = $this->getStockService()->OpenProduct($args['productId'], $requestBody['amount'], $specificStockEntryId, $transactionId, $allowSubproductSubstitution);
|
$args['transactionId'] = $transactionId;
|
||||||
return $this->ApiResponse($response, $this->getDatabase()->stock_log($bookingId));
|
return $this->StockTransactions($request, $response, $args);
|
||||||
}
|
}
|
||||||
catch (\Exception $ex)
|
catch (\Exception $ex)
|
||||||
{
|
{
|
||||||
@ -670,7 +674,6 @@ class StockApiController extends BaseApiController
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
$transactionRows = $this->getDatabase()->stock_log()->where('transaction_id = :1', $args['transactionId'])->fetchAll();
|
$transactionRows = $this->getDatabase()->stock_log()->where('transaction_id = :1', $args['transactionId'])->fetchAll();
|
||||||
|
|
||||||
if (count($transactionRows) === 0)
|
if (count($transactionRows) === 0)
|
||||||
{
|
{
|
||||||
throw new \Exception('No transaction was found by the given transaction id');
|
throw new \Exception('No transaction was found by the given transaction id');
|
||||||
@ -719,8 +722,9 @@ class StockApiController extends BaseApiController
|
|||||||
$specificStockEntryId = $requestBody['stock_entry_id'];
|
$specificStockEntryId = $requestBody['stock_entry_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$bookingId = $this->getStockService()->TransferProduct($args['productId'], $requestBody['amount'], $requestBody['location_id_from'], $requestBody['location_id_to'], $specificStockEntryId);
|
$transactionId = $this->getStockService()->TransferProduct($args['productId'], $requestBody['amount'], $requestBody['location_id_from'], $requestBody['location_id_to'], $specificStockEntryId);
|
||||||
return $this->ApiResponse($response, $this->getDatabase()->stock_log($bookingId));
|
$args['transactionId'] = $transactionId;
|
||||||
|
return $this->StockTransactions($request, $response, $args);
|
||||||
}
|
}
|
||||||
catch (\Exception $ex)
|
catch (\Exception $ex)
|
||||||
{
|
{
|
||||||
|
@ -1473,7 +1473,10 @@
|
|||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/schemas/StockEntry"
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/StockLogEntry"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1830,10 +1833,13 @@
|
|||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
"$ref": "#/components/schemas/StockLogEntry"
|
"$ref": "#/components/schemas/StockLogEntry"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
"description": "The operation was not successful (possible errors are: Not existing product, invalid transaction type)",
|
"description": "The operation was not successful (possible errors are: Not existing product, invalid transaction type)",
|
||||||
@ -1921,10 +1927,13 @@
|
|||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
"$ref": "#/components/schemas/StockLogEntry"
|
"$ref": "#/components/schemas/StockLogEntry"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
"description": "The operation was not successful (possible errors are: Not existing product, invalid transaction type, given amount > current stock amount)",
|
"description": "The operation was not successful (possible errors are: Not existing product, invalid transaction type, given amount > current stock amount)",
|
||||||
@ -1997,10 +2006,13 @@
|
|||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
"$ref": "#/components/schemas/StockLogEntry"
|
"$ref": "#/components/schemas/StockLogEntry"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
"description": "The operation was not successful (possible errors are: Not existing product, no existing from or to location, given amount > current stock amount at the source location)",
|
"description": "The operation was not successful (possible errors are: Not existing product, no existing from or to location, given amount > current stock amount at the source location)",
|
||||||
@ -2074,10 +2086,13 @@
|
|||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
"$ref": "#/components/schemas/StockLogEntry"
|
"$ref": "#/components/schemas/StockLogEntry"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
"description": "The operation was not successful (possible errors are: Not existing product)",
|
"description": "The operation was not successful (possible errors are: Not existing product)",
|
||||||
@ -2142,10 +2157,13 @@
|
|||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
"$ref": "#/components/schemas/StockLogEntry"
|
"$ref": "#/components/schemas/StockLogEntry"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
"description": "The operation was not successful (possible errors are: Not existing product, given amount > current unopened stock amount)",
|
"description": "The operation was not successful (possible errors are: Not existing product, given amount > current unopened stock amount)",
|
||||||
@ -2265,10 +2283,13 @@
|
|||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
"$ref": "#/components/schemas/StockLogEntry"
|
"$ref": "#/components/schemas/StockLogEntry"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
"description": "The operation was not successful (possible errors are: Not existing product, invalid transaction type)",
|
"description": "The operation was not successful (possible errors are: Not existing product, invalid transaction type)",
|
||||||
@ -2356,10 +2377,13 @@
|
|||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
"$ref": "#/components/schemas/StockLogEntry"
|
"$ref": "#/components/schemas/StockLogEntry"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
"description": "The operation was not successful (possible errors are: Not existing product, invalid transaction type, given amount > current stock amount)",
|
"description": "The operation was not successful (possible errors are: Not existing product, invalid transaction type, given amount > current stock amount)",
|
||||||
@ -2432,10 +2456,13 @@
|
|||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
"$ref": "#/components/schemas/StockLogEntry"
|
"$ref": "#/components/schemas/StockLogEntry"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
"description": "The operation was not successful (possible errors are: Not existing product, no existing from or to location, given amount > current stock amount at the source location)",
|
"description": "The operation was not successful (possible errors are: Not existing product, no existing from or to location, given amount > current stock amount at the source location)",
|
||||||
@ -2504,10 +2531,13 @@
|
|||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
"$ref": "#/components/schemas/StockLogEntry"
|
"$ref": "#/components/schemas/StockLogEntry"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
"description": "The operation was not successful (possible errors are: Not existing product)",
|
"description": "The operation was not successful (possible errors are: Not existing product)",
|
||||||
@ -2572,10 +2602,13 @@
|
|||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
"$ref": "#/components/schemas/StockLogEntry"
|
"$ref": "#/components/schemas/StockLogEntry"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
"description": "The operation was not successful (possible errors are: Not existing product, given amount > current unopened stock amount)",
|
"description": "The operation was not successful (possible errors are: Not existing product, given amount > current unopened stock amount)",
|
||||||
@ -4770,6 +4803,9 @@
|
|||||||
"stock_id": {
|
"stock_id": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"transaction_id": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"transaction_type": {
|
"transaction_type": {
|
||||||
"$ref": "#/components/internalSchemas/StockTransactionType"
|
"$ref": "#/components/internalSchemas/StockTransactionType"
|
||||||
},
|
},
|
||||||
|
@ -72,11 +72,11 @@
|
|||||||
|
|
||||||
if (productDetails.product.enable_tare_weight_handling == 1 && !jsonData.exact_amount)
|
if (productDetails.product.enable_tare_weight_handling == 1 && !jsonData.exact_amount)
|
||||||
{
|
{
|
||||||
var successMessage = __t('Removed %1$s of %2$s from stock', Math.abs(jsonForm.amount - (parseFloat(productDetails.product.tare_weight) + parseFloat(productDetails.stock_amount))) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse.transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
var successMessage = __t('Removed %1$s of %2$s from stock', Math.abs(jsonForm.amount - (parseFloat(productDetails.product.tare_weight) + parseFloat(productDetails.stock_amount))) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var successMessage = __t('Removed %1$s of %2$s from stock', Math.abs(jsonForm.amount) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse.transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
var successMessage = __t('Removed %1$s of %2$s from stock', Math.abs(jsonForm.amount) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (GetUriParam("embedded") !== undefined)
|
||||||
@ -166,7 +166,7 @@ $('#save-mark-as-open-button').on('click', function(e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Grocy.FrontendHelpers.EndUiBusy("consume-form");
|
Grocy.FrontendHelpers.EndUiBusy("consume-form");
|
||||||
toastr.success(__t('Marked %1$s of %2$s as opened', jsonForm.amount + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + result.transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>');
|
toastr.success(__t('Marked %1$s of %2$s as opened', jsonForm.amount + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + result[0].transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>');
|
||||||
|
|
||||||
if (BoolVal(Grocy.UserSettings.stock_default_consume_amount_use_quick_consume_amount))
|
if (BoolVal(Grocy.UserSettings.stock_default_consume_amount_use_quick_consume_amount))
|
||||||
{
|
{
|
||||||
|
@ -65,7 +65,7 @@
|
|||||||
Grocy.Api.Get('stock/products/' + jsonForm.product_id,
|
Grocy.Api.Get('stock/products/' + jsonForm.product_id,
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
var successMessage = __t('Stock amount of %1$s is now %2$s', result.product.name, result.stock_amount + " " + __n(result.stock_amount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural)) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse.transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
var successMessage = __t('Stock amount of %1$s is now %2$s', result.product.name, result.stock_amount + " " + __n(result.stock_amount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural)) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||||
|
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
|
@ -635,7 +635,7 @@ $(document).on('click', '.product-consume-button', function(e)
|
|||||||
Grocy.Api.Get('stock/products/' + productId,
|
Grocy.Api.Get('stock/products/' + productId,
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
var toastMessage = __t('Removed %1$s of %2$s from stock', consumeAmount.toString() + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural), result.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse.transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
var toastMessage = __t('Removed %1$s of %2$s from stock', consumeAmount.toString() + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural), result.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||||
|
|
||||||
Grocy.FrontendHelpers.EndUiBusy();
|
Grocy.FrontendHelpers.EndUiBusy();
|
||||||
toastr.success(toastMessage);
|
toastr.success(toastMessage);
|
||||||
|
@ -99,7 +99,7 @@ $('#save-purchase-button').on('click', function(e)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var successMessage = __t('Added %1$s of %2$s to stock', result.amount + " " + __n(result.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + result.transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
var successMessage = __t('Added %1$s of %2$s to stock', result.amount + " " + __n(result.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + result[0].transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||||
|
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
|
@ -124,11 +124,11 @@ $(document).on('click', '.product-consume-button', function(e)
|
|||||||
{
|
{
|
||||||
if (result.product.enable_tare_weight_handling == 1)
|
if (result.product.enable_tare_weight_handling == 1)
|
||||||
{
|
{
|
||||||
var toastMessage = __t('Removed %1$s of %2$s from stock', parseFloat(originalTotalStockAmount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural), result.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse.transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
var toastMessage = __t('Removed %1$s of %2$s from stock', parseFloat(originalTotalStockAmount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural), result.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var toastMessage = __t('Removed %1$s of %2$s from stock', parseFloat(consumeAmount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural), result.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse.transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
var toastMessage = __t('Removed %1$s of %2$s from stock', parseFloat(consumeAmount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural), result.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wasSpoiled)
|
if (wasSpoiled)
|
||||||
@ -184,7 +184,7 @@ $(document).on('click', '.product-open-button', function(e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Grocy.FrontendHelpers.EndUiBusy();
|
Grocy.FrontendHelpers.EndUiBusy();
|
||||||
toastr.success(__t('Marked %1$s of %2$s as opened', parseFloat(amount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + productQuName, productName) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse.transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>');
|
toastr.success(__t('Marked %1$s of %2$s as opened', parseFloat(amount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + productQuName, productName) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>');
|
||||||
RefreshStatistics();
|
RefreshStatistics();
|
||||||
RefreshProductRow(productId);
|
RefreshProductRow(productId);
|
||||||
},
|
},
|
||||||
|
@ -51,11 +51,11 @@
|
|||||||
|
|
||||||
if (productDetails.product.enable_tare_weight_handling == 1)
|
if (productDetails.product.enable_tare_weight_handling == 1)
|
||||||
{
|
{
|
||||||
var successMessage = __t('Transfered %1$s of %2$s from %3$s to %4$s', Math.abs(jsonForm.amount - parseFloat(productDetails.product.tare_weight)) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name, $('option:selected', "#location_id_from").text(), $('option:selected', "#location_id_to").text()) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse.transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
var successMessage = __t('Transfered %1$s of %2$s from %3$s to %4$s', Math.abs(jsonForm.amount - parseFloat(productDetails.product.tare_weight)) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name, $('option:selected', "#location_id_from").text(), $('option:selected', "#location_id_to").text()) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var successMessage = __t('Transfered %1$s of %2$s from %3$s to %4$s', Math.abs(jsonForm.amount) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name, $('option:selected', "#location_id_from").text(), $('option:selected', "#location_id_to").text()) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse.transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
var successMessage = __t('Transfered %1$s of %2$s from %3$s to %4$s', Math.abs(jsonForm.amount) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name, $('option:selected', "#location_id_from").text(), $('option:selected', "#location_id_to").text()) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (GetUriParam("embedded") !== undefined)
|
||||||
|
@ -165,8 +165,6 @@ class StockService extends BaseService
|
|||||||
]);
|
]);
|
||||||
$logRow->save();
|
$logRow->save();
|
||||||
|
|
||||||
$returnValue = $this->getDatabase()->lastInsertId();
|
|
||||||
|
|
||||||
$stockRow = $this->getDatabase()->stock()->createRow([
|
$stockRow = $this->getDatabase()->stock()->createRow([
|
||||||
'product_id' => $productId,
|
'product_id' => $productId,
|
||||||
'amount' => $amount,
|
'amount' => $amount,
|
||||||
@ -179,7 +177,7 @@ class StockService extends BaseService
|
|||||||
]);
|
]);
|
||||||
$stockRow->save();
|
$stockRow->save();
|
||||||
|
|
||||||
return $returnValue;
|
return $transactionId;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -363,7 +361,7 @@ class StockService extends BaseService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getDatabase()->lastInsertId();
|
return $transactionId;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -440,7 +438,7 @@ class StockService extends BaseService
|
|||||||
]);
|
]);
|
||||||
$logNewRowForStockUpdate->save();
|
$logNewRowForStockUpdate->save();
|
||||||
|
|
||||||
return $this->getDatabase()->lastInsertId();
|
return $transactionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ExternalBarcodeLookup($barcode, $addFoundProduct)
|
public function ExternalBarcodeLookup($barcode, $addFoundProduct)
|
||||||
@ -742,7 +740,6 @@ class StockService extends BaseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Tare weight handling
|
// Tare weight handling
|
||||||
|
|
||||||
// The given amount is the new total amount including the container weight (gross)
|
// The given amount is the new total amount including the container weight (gross)
|
||||||
// So assume that the amount in stock is the amount also including the container weight
|
// So assume that the amount in stock is the amount also including the container weight
|
||||||
$containerWeight = 0;
|
$containerWeight = 0;
|
||||||
@ -909,7 +906,7 @@ class StockService extends BaseService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getDatabase()->lastInsertId();
|
return $transactionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function RemoveProductFromShoppingList($productId, $amount = 1, $listId = 1)
|
public function RemoveProductFromShoppingList($productId, $amount = 1, $listId = 1)
|
||||||
@ -955,7 +952,6 @@ class StockService extends BaseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Tare weight handling
|
// Tare weight handling
|
||||||
|
|
||||||
// The given amount is the new total amount including the container weight (gross)
|
// The given amount is the new total amount including the container weight (gross)
|
||||||
// The amount to be posted needs to be the absolute value of the given amount - stock amount - tare weight
|
// The amount to be posted needs to be the absolute value of the given amount - stock amount - tare weight
|
||||||
$productDetails = (object) $this->GetProductDetails($productId);
|
$productDetails = (object) $this->GetProductDetails($productId);
|
||||||
@ -1126,7 +1122,7 @@ class StockService extends BaseService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getDatabase()->lastInsertId();
|
return $transactionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function UndoBooking($bookingId, $skipCorrelatedBookings = false)
|
public function UndoBooking($bookingId, $skipCorrelatedBookings = false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user