Allow decimal numbers in "Factor purchase to stock quantity unit" when "Allow partial units in stock" is enabled (closes #351)

This commit is contained in:
Bernd Bestel 2019-09-17 20:02:27 +02:00
parent bbd8e8c1fa
commit e326e69d49
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
2 changed files with 11 additions and 15 deletions

View File

@ -9,6 +9,7 @@
- Products "inherit" the default conversion and additionally can have their own / override the default ones
- It's now possible to print a "Location Content Sheet" with the current stock per location - new button at the top of the stock overview page (thought to hang it at the location, note used amounts on paper and track it in grocy later)
- The product description now can have formattings (HTML/WYSIWYG editor like for recipes)
- "Factor purchase to stock quantity unit" (product option) can now also be a decimal number when "Allow partial units in stock" is enabled
- Recipe improvements
- Based on the new linked quantity units, recipe ingredients can now use any product related unit, the amount is calculated according to the cnoversion factor of the unit relation
- Chores improvements
@ -16,7 +17,7 @@
- Option per chore, different "assignment types" like "Random", "Who least did first", etc.
- On the chores overview page the list can be filterd to only show chores assigned to the currently logged in user (or to any other user)
- New option "Due date rollover" per chore which means the chore can never be overdue, the due date will shift forward each day when due
- When tracking an execution from the chores overview page, filter are re-applied afterwards (means when have filtered the page to only show overdue chores and after the execution the chore is not overdue anymore, it will now immediately hide id)
- When tracking an execution from the chores overview page, filters are re-applied afterwards (means when have filtered the page to only show overdue chores and after the execution the chore is not overdue anymore, it will now immediately hide id)
- Equipment improvements/fixes
- Fixed that the delete button not always deleted the currently selected equipment item
- Userfield improvements/fixes

View File

@ -201,18 +201,7 @@ $('.input-group-qu').on('change', function(e)
var quIdStock = $("#qu_id_stock").val();
var factor = $('#qu_factor_purchase_to_stock').val();
if (quIdPurchase != quIdStock)
{
$('#qu_factor_purchase_to_stock').attr("min", 2);
$("#qu_factor_purchase_to_stock").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %s', '2'));
}
else
{
$('#qu_factor_purchase_to_stock').attr("min", 1);
$("#qu_factor_purchase_to_stock").parent().find(".invalid-feedback").text(__t('The amount cannot be lower than %s', '1'));
}
if (factor > 1)
if (factor > 1 || quIdPurchase != quIdStock)
{
$('#qu-conversion-info').text(__t('This means 1 %1$s purchased will be converted into %2$s %3$s in stock', $("#qu_id_purchase option:selected").text(), (1 * factor).toString(), $("#qu_id_stock option:selected").text()));
$('#qu-conversion-info').removeClass('d-none');
@ -298,13 +287,19 @@ $("#allow_partial_units_in_stock").on("click", function()
{
if (this.checked)
{
$("#min_stock_amount").attr("min", "0.00");
$("#min_stock_amount").attr("step", "0.01");
$("#min_stock_amount").attr("min", "0.0000");
$("#min_stock_amount").attr("step", "0.0001");
$("#qu_factor_purchase_to_stock").attr("min", "0.0001");
$("#qu_factor_purchase_to_stock").attr("step", "0.0001");
$("#qu_factor_purchase_to_stock").parent().find(".invalid-feedback").text(__t('This cannot be lower than %1$s and must be a valid number with max. %2$s decimal places', 0.0001.toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 4 }), '4'));
}
else
{
$("#min_stock_amount").attr("min", "0");
$("#min_stock_amount").attr("step", "1");
$("#qu_factor_purchase_to_stock").attr("min", "1");
$("#qu_factor_purchase_to_stock").attr("step", "1");
$("#qu_factor_purchase_to_stock").parent().find(".invalid-feedback").text(__t('This cannot be lower than %1$s and must be a valid number with max. %2$s decimal places', '1', '0'));
}
Grocy.FrontendHelpers.ValidateForm("product-form");