mirror of
https://github.com/grocy/grocy.git
synced 2025-08-16 02:34:44 +00:00
Prevent opening more products than are unopened in stock
This commit is contained in:
@@ -119,7 +119,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
||||
Grocy.Components.ProductCard.Refresh(productId);
|
||||
|
||||
Grocy.Api.Get('stock/get-product-details/' + productId,
|
||||
function (productDetails)
|
||||
function(productDetails)
|
||||
{
|
||||
$('#amount').attr('max', productDetails.stock_amount);
|
||||
$('#amount_qu_unit').text(productDetails.quantity_unit_stock.name);
|
||||
@@ -137,6 +137,15 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
||||
Grocy.FrontendHelpers.ValidateForm('consume-form');
|
||||
$('#amount').focus();
|
||||
}
|
||||
|
||||
if (productDetails.stock_amount == productDetails.stock_amount_opened)
|
||||
{
|
||||
$("#save-mark-as-open-button").addClass("disabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#save-mark-as-open-button").removeClass("disabled");
|
||||
}
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
Reference in New Issue
Block a user