mirror of
https://github.com/grocy/grocy.git
synced 2026-04-08 13:46:14 +02:00
Allow price to be 4 decimals
This commit is contained in:
parent
9e982979c3
commit
24d8b21901
|
|
@ -106,6 +106,7 @@ DefaultUserSetting('keep_screen_on_when_fullscreen_card', false); // Keep the sc
|
||||||
DefaultUserSetting('product_presets_location_id', -1); // Default location id for new products (-1 means no location is preset)
|
DefaultUserSetting('product_presets_location_id', -1); // Default location id for new products (-1 means no location is preset)
|
||||||
DefaultUserSetting('product_presets_product_group_id', -1); // Default product group id for new products (-1 means no product group is preset)
|
DefaultUserSetting('product_presets_product_group_id', -1); // Default product group id for new products (-1 means no product group is preset)
|
||||||
DefaultUserSetting('product_presets_qu_id', -1); // Default quantity unit id for new products (-1 means no quantity unit is preset)
|
DefaultUserSetting('product_presets_qu_id', -1); // Default quantity unit id for new products (-1 means no quantity unit is preset)
|
||||||
|
DefaultUserSetting('stock_decimal_places_prices', 4); // Default decimal places allowed for prices
|
||||||
DefaultUserSetting('stock_expiring_soon_days', 5);
|
DefaultUserSetting('stock_expiring_soon_days', 5);
|
||||||
DefaultUserSetting('stock_default_purchase_amount', 0);
|
DefaultUserSetting('stock_default_purchase_amount', 0);
|
||||||
DefaultUserSetting('stock_default_consume_amount', 1);
|
DefaultUserSetting('stock_default_consume_amount', 1);
|
||||||
|
|
|
||||||
|
|
@ -553,7 +553,7 @@ function RefreshLocaleNumberDisplay(rootSelector = "#page-content")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$(this).text(parseFloat($(this).text()).toLocaleString(undefined, { style: "currency", currency: Grocy.Currency }));
|
$(this).text(parseFloat($(this).text()).toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: 2, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices}));
|
||||||
});
|
});
|
||||||
|
|
||||||
$(rootSelector + " .locale-number.locale-number-quantity-amount").each(function()
|
$(rootSelector + " .locale-number.locale-number-quantity-amount").each(function()
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
var price = "";
|
var price = "";
|
||||||
if (!jsonForm.price.toString().isEmpty())
|
if (!jsonForm.price.toString().isEmpty())
|
||||||
{
|
{
|
||||||
price = parseFloat(jsonForm.price).toFixed(2);
|
price = parseFloat(jsonForm.price).toFixed(Grocy.UserSettings.stock_decimal_places_prices);
|
||||||
}
|
}
|
||||||
|
|
||||||
var jsonData = {};
|
var jsonData = {};
|
||||||
|
|
|
||||||
|
|
@ -8,27 +8,22 @@
|
||||||
Grocy.Api.Get('stock/products/' + jsonForm.product_id,
|
Grocy.Api.Get('stock/products/' + jsonForm.product_id,
|
||||||
function(productDetails)
|
function(productDetails)
|
||||||
{
|
{
|
||||||
var amount = jsonForm.amount * jsonForm.qu_factor_purchase_to_stock;
|
var jsonData = {};
|
||||||
|
jsonData.amount = jsonForm.amount * jsonForm.qu_factor_purchase_to_stock;
|
||||||
var price = "";
|
|
||||||
if (!jsonForm.price.toString().isEmpty())
|
|
||||||
{
|
|
||||||
// price is saved as 1 QU to stock
|
|
||||||
price = parseFloat(jsonForm.price / amount).toFixed(2);
|
|
||||||
|
|
||||||
if ($("input[name='price-type']:checked").val() == "total-price")
|
|
||||||
{
|
|
||||||
price = price / jsonForm.amount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
|
if (!Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
|
||||||
{
|
{
|
||||||
price = 0;
|
jsonData.price = 0;
|
||||||
}
|
} else {
|
||||||
|
// price is saved as 1 QU to stock
|
||||||
|
var price = parseFloat(jsonForm.price / jsonForm.qu_factor_purchase_to_stock).toFixed(Grocy.UserSettings.stock_decimal_places_prices);
|
||||||
|
|
||||||
var jsonData = {};
|
if ($("input[name='price-type']:checked").val() == "total-price")
|
||||||
jsonData.amount = amount;
|
{
|
||||||
|
price = parseFloat(price / jsonForm.amount).toFixed(Grocy.UserSettings.stock_decimal_places_prices);
|
||||||
|
}
|
||||||
|
jsonData.price = price;
|
||||||
|
}
|
||||||
|
|
||||||
if (Grocy.UserSettings.show_purchased_date_on_purchase)
|
if (Grocy.UserSettings.show_purchased_date_on_purchase)
|
||||||
{
|
{
|
||||||
|
|
@ -48,7 +43,6 @@
|
||||||
{
|
{
|
||||||
jsonData.shopping_location_id = Grocy.Components.ShoppingLocationPicker.GetValue();
|
jsonData.shopping_location_id = Grocy.Components.ShoppingLocationPicker.GetValue();
|
||||||
}
|
}
|
||||||
jsonData.price = price;
|
|
||||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)
|
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)
|
||||||
{
|
{
|
||||||
jsonData.location_id = Grocy.Components.LocationPicker.GetValue();
|
jsonData.location_id = Grocy.Components.LocationPicker.GetValue();
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
if (!jsonForm.price.toString().isEmpty())
|
if (!jsonForm.price.toString().isEmpty())
|
||||||
{
|
{
|
||||||
price = parseFloat(jsonForm.price).toFixed(2);
|
price = parseFloat(jsonForm.price).toFixed(Grocy.UserSettings.stock_decimal_places_prices);
|
||||||
}
|
}
|
||||||
|
|
||||||
var jsonData = {};
|
var jsonData = {};
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ $("#product_presets_qu_id").val(Grocy.UserSettings.product_presets_qu_id);
|
||||||
$("#stock_expiring_soon_days").val(Grocy.UserSettings.stock_expiring_soon_days);
|
$("#stock_expiring_soon_days").val(Grocy.UserSettings.stock_expiring_soon_days);
|
||||||
$("#stock_default_purchase_amount").val(Grocy.UserSettings.stock_default_purchase_amount);
|
$("#stock_default_purchase_amount").val(Grocy.UserSettings.stock_default_purchase_amount);
|
||||||
$("#stock_default_consume_amount").val(Grocy.UserSettings.stock_default_consume_amount);
|
$("#stock_default_consume_amount").val(Grocy.UserSettings.stock_default_consume_amount);
|
||||||
|
$("#stock_decimal_places_prices").val(Grocy.UserSettings.stock_decimal_places_prices);
|
||||||
|
|
||||||
if (BoolVal(Grocy.UserSettings.show_icon_on_stock_overview_page_when_product_is_on_shopping_list))
|
if (BoolVal(Grocy.UserSettings.show_icon_on_stock_overview_page_when_product_is_on_shopping_list))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -94,14 +94,15 @@
|
||||||
@include('components.numberpicker', array(
|
@include('components.numberpicker', array(
|
||||||
'id' => 'price',
|
'id' => 'price',
|
||||||
'label' => 'Price',
|
'label' => 'Price',
|
||||||
'min' => 0.01,
|
'min' => 0.0001,
|
||||||
'decimals' => 2,
|
'decimals' => $userSettings['stock_decimal_places_prices'],
|
||||||
'value' => '',
|
'value' => '',
|
||||||
'hintId' => 'price-hint',
|
'hintId' => 'price-hint',
|
||||||
'invalidFeedback' => $__t('The price cannot be lower than %s', '0'),
|
'invalidFeedback' => $__t('The price cannot be lower than %s', '0'),
|
||||||
'isRequired' => false,
|
'isRequired' => false,
|
||||||
'additionalGroupCssClasses' => 'mb-1'
|
'additionalGroupCssClasses' => 'mb-1'
|
||||||
))
|
))
|
||||||
|
|
||||||
<div class="form-check form-check-inline mb-3">
|
<div class="form-check form-check-inline mb-3">
|
||||||
<input class="form-check-input"
|
<input class="form-check-input"
|
||||||
type="radio"
|
type="radio"
|
||||||
|
|
|
||||||
|
|
@ -89,8 +89,8 @@
|
||||||
'id' => 'price',
|
'id' => 'price',
|
||||||
'value' => $price,
|
'value' => $price,
|
||||||
'label' => 'Price',
|
'label' => 'Price',
|
||||||
'min' => 0.01,
|
'min' => 0.0001,
|
||||||
'decimals' => 2,
|
'decimals' => $userSettings['stock_decimal_places_prices'],
|
||||||
'hint' => $__t('in %s per purchase quantity unit', GROCY_CURRENCY),
|
'hint' => $__t('in %s per purchase quantity unit', GROCY_CURRENCY),
|
||||||
'invalidFeedback' => $__t('The price cannot be lower than %s', '0'),
|
'invalidFeedback' => $__t('The price cannot be lower than %s', '0'),
|
||||||
'isRequired' => false
|
'isRequired' => false
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,17 @@
|
||||||
'additionalCssClasses' => 'user-setting-control'
|
'additionalCssClasses' => 'user-setting-control'
|
||||||
))
|
))
|
||||||
|
|
||||||
|
<h4 class="mt-2">{{ $__t('Price decimal places allowed') }}</h4>
|
||||||
|
@include('components.numberpicker', array(
|
||||||
|
'id' => 'stock_price_decimal_places',
|
||||||
|
'additionalAttributes' => 'data-setting-key="stock_price_decimal_places"',
|
||||||
|
'label' => 'Decimal places allowed for prices',
|
||||||
|
'min' => 0,
|
||||||
|
'decimals' => 0,
|
||||||
|
'invalidFeedback' => $__t('This cannot be lower than %s', '0'),
|
||||||
|
'additionalCssClasses' => 'user-setting-control'
|
||||||
|
))
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label for="show_icon_on_stock_overview_page_when_product_is_on_shopping_list">
|
<label for="show_icon_on_stock_overview_page_when_product_is_on_shopping_list">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user