mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 20:26:42 +00:00
Allow decimal amounts in general for the shopping list
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
|
|
||||||
### Shopping list improvements
|
### Shopping list improvements
|
||||||
|
- Decimal amounts are now allowed (for any product, rounded by two decimal places)
|
||||||
- "Add products that are below defined min. stock amount" always rounded up the missing amount to an integral number, this now allows decimal numbers
|
- "Add products that are below defined min. stock amount" always rounded up the missing amount to an integral number, this now allows decimal numbers
|
||||||
|
|
||||||
### Recipe improvements/fixes
|
### Recipe improvements/fixes
|
||||||
|
@@ -117,19 +117,6 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
|||||||
{
|
{
|
||||||
$('#amount_qu_unit').text(productDetails.quantity_unit_purchase.name);
|
$('#amount_qu_unit').text(productDetails.quantity_unit_purchase.name);
|
||||||
|
|
||||||
if (productDetails.product.allow_partial_units_in_stock == 1)
|
|
||||||
{
|
|
||||||
$("#amount").attr("min", "0.01");
|
|
||||||
$("#amount").attr("step", "0.01");
|
|
||||||
$("#amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %s', 0.01.toLocaleString()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$("#amount").attr("min", "1");
|
|
||||||
$("#amount").attr("step", "1");
|
|
||||||
$("#amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %s', '1'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#amount').focus();
|
$('#amount').focus();
|
||||||
Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');
|
Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');
|
||||||
},
|
},
|
||||||
@@ -194,3 +181,5 @@ if (GetUriParam("amount") !== undefined)
|
|||||||
$("#amount").val(parseFloat(GetUriParam("amount")).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: 4 }));
|
$("#amount").val(parseFloat(GetUriParam("amount")).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: 4 }));
|
||||||
Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');
|
Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$("#amount").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %s', 0.01.toLocaleString()));
|
||||||
|
@@ -38,10 +38,10 @@ class RecipesService extends BaseService
|
|||||||
{
|
{
|
||||||
$product = $this->getDataBase()->products($recipePosition->product_id);
|
$product = $this->getDataBase()->products($recipePosition->product_id);
|
||||||
|
|
||||||
$toOrderAmount = ceil(($recipePosition->missing_amount - $recipePosition->amount_on_shopping_list) / $product->qu_factor_purchase_to_stock);
|
$toOrderAmount = round(($recipePosition->missing_amount - $recipePosition->amount_on_shopping_list) / $product->qu_factor_purchase_to_stock, 2);
|
||||||
if ($recipe->not_check_shoppinglist == 1)
|
if ($recipe->not_check_shoppinglist == 1)
|
||||||
{
|
{
|
||||||
$toOrderAmount = ceil($recipePosition->missing_amount / $product->qu_factor_purchase_to_stock);
|
$toOrderAmount = round($recipePosition->missing_amount / $product->qu_factor_purchase_to_stock, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($toOrderAmount > 0)
|
if($toOrderAmount > 0)
|
||||||
|
@@ -905,7 +905,7 @@ class StockService extends BaseService
|
|||||||
if ($productRow != null && !empty($productRow))
|
if ($productRow != null && !empty($productRow))
|
||||||
{
|
{
|
||||||
$newAmount = $productRow->amount - $amount;
|
$newAmount = $productRow->amount - $amount;
|
||||||
if ($newAmount < 1)
|
if ($newAmount < 0.01)
|
||||||
{
|
{
|
||||||
$productRow->delete();
|
$productRow->delete();
|
||||||
}
|
}
|
||||||
|
@@ -51,9 +51,10 @@
|
|||||||
'id' => 'amount',
|
'id' => 'amount',
|
||||||
'label' => 'Amount',
|
'label' => 'Amount',
|
||||||
'hintId' => 'amount_qu_unit',
|
'hintId' => 'amount_qu_unit',
|
||||||
'min' => 0,
|
'min' => 0.01,
|
||||||
|
'step' => 0.01,
|
||||||
'value' => $value,
|
'value' => $value,
|
||||||
'invalidFeedback' => $__t('The amount cannot be lower than %s', '1')
|
'invalidFeedback' => $__t('The amount cannot be lower than %s', '0.01')
|
||||||
))
|
))
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
Reference in New Issue
Block a user