Don't allow tare weight handling enabled products to be opened (closes #770)

This commit is contained in:
Bernd Bestel 2020-11-14 22:51:06 +01:00
parent 62c9c285ba
commit 28276191cc
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
3 changed files with 7 additions and 1 deletions

View File

@ -60,6 +60,7 @@ _- (Because the stock quantity unit is now the base for everything, it cannot be
- Fixed that `FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING` is set to `false`, the purchase page validation failed (thanks @fipwmaqzufheoxq92ebc) - Fixed that `FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING` is set to `false`, the purchase page validation failed (thanks @fipwmaqzufheoxq92ebc)
- Fixed that consuming products with enabled tare weight handling did not work on the stock entries page (also fixed that opening those products is not possible there) - Fixed that consuming products with enabled tare weight handling did not work on the stock entries page (also fixed that opening those products is not possible there)
- Fixed that the recipes dropdown on the consume page also displayed internal recipes (thanks @kriddles) - Fixed that the recipes dropdown on the consume page also displayed internal recipes (thanks @kriddles)
- Fixed that opening tare weight handling enabled products is not possible via the UI and the API (as this makes no sense)
### Shopping list improvements ### Shopping list improvements
- Decimal amounts are now allowed (for any product, rounded by two decimal places) - Decimal amounts are now allowed (for any product, rounded by two decimal places)

View File

@ -372,7 +372,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
$('#display_amount').focus(); $('#display_amount').focus();
} }
if (productDetails.stock_amount == productDetails.stock_amount_opened) if (productDetails.stock_amount == productDetails.stock_amount_opened || productDetails.product.enable_tare_weight_handling == 1)
{ {
$("#save-mark-as-open-button").addClass("disabled"); $("#save-mark-as-open-button").addClass("disabled");
} }

View File

@ -740,6 +740,11 @@ class StockService extends BaseService
$potentialStockEntries = $this->GetProductStockEntries($productId, true); $potentialStockEntries = $this->GetProductStockEntries($productId, true);
$product = $this->getDatabase()->products($productId); $product = $this->getDatabase()->products($productId);
if ($product->enable_tare_weight_handling == 1)
{
throw new \Exception('Opening tare weight handling enabled products is not supported');
}
if ($amount > $productStockAmountUnopened) if ($amount > $productStockAmountUnopened)
{ {
throw new \Exception('Amount to be opened cannot be > current unopened stock amount'); throw new \Exception('Amount to be opened cannot be > current unopened stock amount');