mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
Show a warning on purchase when purchased best before date is < in stock (closes #948)
This commit is contained in:
parent
db5c9ce3e8
commit
f85b89d4fa
@ -30,6 +30,7 @@ _- (Because the stock quantity unit is now the base for everything, it cannot be
|
|||||||
|
|
||||||
### Stock improvements/fixes
|
### Stock improvements/fixes
|
||||||
- When creating a quantity unit conversion it's now possible to automatically create the inverse conversion (thanks @kriddles)
|
- When creating a quantity unit conversion it's now possible to automatically create the inverse conversion (thanks @kriddles)
|
||||||
|
- On purchase there is now a warning shown, when the best before date of the purchased product is earlier than the next best before date in stock (enabled by default, can be disabled by a new stock setting (top right corner settings menu))
|
||||||
- Optimized/clarified what the total/unit price is on the purchase page (thanks @kriddles)
|
- Optimized/clarified what the total/unit price is on the purchase page (thanks @kriddles)
|
||||||
- On the purchase page the amount field is now displayed above/before the best before date for better `TAB` handling (thanks @kriddles)
|
- On the purchase page the amount field is now displayed above/before the best before date for better `TAB` handling (thanks @kriddles)
|
||||||
- Changed that when `FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING` is disabled, products now get internally a best before of "never expires" (aka `2999-12-31`) instead of today (thanks @kriddles)
|
- Changed that when `FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING` is disabled, products now get internally a best before of "never expires" (aka `2999-12-31`) instead of today (thanks @kriddles)
|
||||||
|
@ -120,6 +120,7 @@ DefaultUserSetting('scan_mode_consume_enabled', false);
|
|||||||
DefaultUserSetting('scan_mode_purchase_enabled', false);
|
DefaultUserSetting('scan_mode_purchase_enabled', false);
|
||||||
DefaultUserSetting('show_icon_on_stock_overview_page_when_product_is_on_shopping_list', true);
|
DefaultUserSetting('show_icon_on_stock_overview_page_when_product_is_on_shopping_list', true);
|
||||||
DefaultUserSetting('show_purchased_date_on_purchase', false); // Wheter the purchased date should be editable on purchase (defaults to today otherwise)
|
DefaultUserSetting('show_purchased_date_on_purchase', false); // Wheter the purchased date should be editable on purchase (defaults to today otherwise)
|
||||||
|
DefaultUserSetting('show_warning_on_purchase_when_best_before_date_is_earlier_than_next', true); // Show a warning on purchase when the best before date of the purchased product is earlier than the next best before date in stock
|
||||||
|
|
||||||
// Shopping list settings
|
// Shopping list settings
|
||||||
DefaultUserSetting('shopping_list_to_stock_workflow_auto_submit_when_prefilled', false); // Automatically do the booking using the last price and the amount of the shopping list item, if the product has "Default best before days" set
|
DefaultUserSetting('shopping_list_to_stock_workflow_auto_submit_when_prefilled', false); // Automatically do the booking using the last price and the amount of the shopping list item, if the product has "Default best before days" set
|
||||||
|
@ -1924,3 +1924,9 @@ msgstr ""
|
|||||||
|
|
||||||
msgid "This is the default quantity unit used when adding this product to the shopping list"
|
msgid "This is the default quantity unit used when adding this product to the shopping list"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Show a warning when the best before date of the purchased product is earlier than the next best before date in stock"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "There are items in stock which expire earlier"
|
||||||
|
msgstr ""
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
$('#save-purchase-button').on('click', function(e)
|
var CurrentProductDetails;
|
||||||
|
|
||||||
|
$('#save-purchase-button').on('click', function(e)
|
||||||
{
|
{
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@ -97,6 +99,14 @@
|
|||||||
toastr.success(successMessage);
|
toastr.success(successMessage);
|
||||||
Grocy.Components.ProductPicker.FinishFlow();
|
Grocy.Components.ProductPicker.FinishFlow();
|
||||||
|
|
||||||
|
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING && BoolVal(Grocy.UserSettings.show_warning_on_purchase_when_best_before_date_is_earlier_than_next))
|
||||||
|
{
|
||||||
|
if (moment(jsonData.best_before_date).isBefore(CurrentProductDetails.next_best_before_date))
|
||||||
|
{
|
||||||
|
toastr.warning(__t("There are items in stock which expire earlier"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Grocy.Components.ProductAmountPicker.Reset();
|
Grocy.Components.ProductAmountPicker.Reset();
|
||||||
$("#display_amount").attr("min", "1");
|
$("#display_amount").attr("min", "1");
|
||||||
$("#display_amount").attr("step", "1");
|
$("#display_amount").attr("step", "1");
|
||||||
@ -162,6 +172,8 @@ if (Grocy.Components.ProductPicker !== undefined)
|
|||||||
Grocy.Api.Get('stock/products/' + productId,
|
Grocy.Api.Get('stock/products/' + productId,
|
||||||
function(productDetails)
|
function(productDetails)
|
||||||
{
|
{
|
||||||
|
CurrentProductDetails = productDetails;
|
||||||
|
|
||||||
Grocy.Components.ProductAmountPicker.Reload(productDetails.product.id, productDetails.quantity_unit_stock.id);
|
Grocy.Components.ProductAmountPicker.Reload(productDetails.product.id, productDetails.quantity_unit_stock.id);
|
||||||
Grocy.Components.ProductAmountPicker.SetQuantityUnit(productDetails.default_quantity_unit_purchase.id);
|
Grocy.Components.ProductAmountPicker.SetQuantityUnit(productDetails.default_quantity_unit_purchase.id);
|
||||||
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_purchase_amount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }));
|
$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_purchase_amount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }));
|
||||||
|
@ -15,3 +15,8 @@ if (BoolVal(Grocy.UserSettings.show_purchased_date_on_purchase))
|
|||||||
{
|
{
|
||||||
$("#show_purchased_date_on_purchase").prop("checked", true);
|
$("#show_purchased_date_on_purchase").prop("checked", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (BoolVal(Grocy.UserSettings.show_warning_on_purchase_when_best_before_date_is_earlier_than_next))
|
||||||
|
{
|
||||||
|
$("#show_warning_on_purchase_when_best_before_date_is_earlier_than_next").prop("checked", true);
|
||||||
|
}
|
||||||
|
@ -104,6 +104,19 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="custom-control custom-checkbox">
|
||||||
|
<input type="checkbox"
|
||||||
|
class="form-check-input custom-control-input user-setting-control"
|
||||||
|
id="show_warning_on_purchase_when_best_before_date_is_earlier_than_next"
|
||||||
|
data-setting-key="show_warning_on_purchase_when_best_before_date_is_earlier_than_next">
|
||||||
|
<label class="form-check-label custom-control-label"
|
||||||
|
for="show_warning_on_purchase_when_best_before_date_is_earlier_than_next">
|
||||||
|
{{ $__t('Show a warning when the best before date of the purchased product is earlier than the next best before date in stock') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<h4 class="mt-2">{{ $__t('Consume') }}</h4>
|
<h4 class="mt-2">{{ $__t('Consume') }}</h4>
|
||||||
@include('components.numberpicker', array(
|
@include('components.numberpicker', array(
|
||||||
'id' => 'stock_default_consume_amount',
|
'id' => 'stock_default_consume_amount',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user