mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 12:20:22 +00:00
Allow price up to 4 decimals instead of 2 (#1077)
* Allow price to be 4 decimals * remove logging * Finalize custom decimal places by user setting * Typo Co-authored-by: Bernd Bestel <bernd@berrnd.de>
This commit is contained in:
@@ -255,8 +255,8 @@
|
||||
'id' => 'product_amount',
|
||||
'label' => 'Amount',
|
||||
'hintId' => 'amount_qu_unit',
|
||||
'min' => 0.0001,
|
||||
'decimals' => 4,
|
||||
'min' => '',
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'invalidFeedback' => $__t('The amount cannot be lower than %s', '1'),
|
||||
'isRequired' => false,
|
||||
'value' => $value
|
||||
|
@@ -36,7 +36,7 @@
|
||||
value="{{ $value }}"
|
||||
min="{{ number_format($min, $decimals, '.', '') }}"
|
||||
max="{{ number_format($max, $decimals, '.', '') }}"
|
||||
step="@if($decimals == 0){{1}}@else{{'.' . substr('0000000001', -$decimals)}}@endif"
|
||||
step="@if($decimals == 0){{1}}@else{{'.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1'}}@endif"
|
||||
@if($isRequired)
|
||||
required
|
||||
@endif>
|
||||
|
@@ -11,8 +11,8 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'display_amount',
|
||||
'label' => 'Amount',
|
||||
'min' => 0.0001,
|
||||
'decimals' => 4,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => $value,
|
||||
'invalidFeedback' => $__t('This cannot be negative and must be an integral number'),
|
||||
'additionalGroupCssClasses' => 'col-4 mb-1',
|
||||
|
@@ -54,8 +54,8 @@
|
||||
'id' => 'amount',
|
||||
'label' => 'Amount',
|
||||
'hintId' => 'amount_qu_unit',
|
||||
'min' => 0.0001,
|
||||
'decimals' => 4,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => 0,
|
||||
'invalidFeedback' => $__t('The amount cannot be lower than %s', '1'),
|
||||
'additionalHtmlContextHelp' => '<div id="tare-weight-handling-info"
|
||||
|
@@ -23,7 +23,7 @@
|
||||
'label' => 'New amount',
|
||||
'hintId' => 'new_amount_qu_unit',
|
||||
'min' => 0,
|
||||
'decimals' => 4,
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => 1,
|
||||
'invalidFeedback' => $__t('The amount cannot be lower than %s', '0'),
|
||||
'additionalAttributes' => 'data-not-equal="-1"',
|
||||
@@ -65,7 +65,7 @@
|
||||
'id' => 'price',
|
||||
'label' => 'Price',
|
||||
'min' => 0,
|
||||
'decimals' => 2,
|
||||
'decimals' => $userSettings['stock_decimal_places_prices'],
|
||||
'value' => '',
|
||||
'hint' => $__t('in %s per purchase quantity unit', GROCY_CURRENCY),
|
||||
'additionalHtmlContextHelp' => '<br><span class="small text-muted">' . $__t('This will apply to added products') . '</span>',
|
||||
|
@@ -61,8 +61,8 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'recipe_servings',
|
||||
'label' => 'Servings',
|
||||
'min' => 0.01,
|
||||
'decimals' => 2,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => '1',
|
||||
'invalidFeedback' => $__t('This cannot be lower than %s', '1')
|
||||
))
|
||||
|
@@ -55,8 +55,8 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'qu_factor_purchase_to_stock',
|
||||
'label' => 'Factor purchase to stock quantity unit',
|
||||
'min' => 0.0001,
|
||||
'decimals' => 4,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => $value,
|
||||
'isRequired' => true,
|
||||
'invalidFeedback' => $__t('The amount cannot be lower than %s', '1'),
|
||||
|
@@ -142,8 +142,8 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'min_stock_amount',
|
||||
'label' => 'Minimum stock amount',
|
||||
'min' => 0.0001,
|
||||
'decimals' => 4,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => $value,
|
||||
'invalidFeedback' => $__t('The amount cannot be lower than %s', '0'),
|
||||
'additionalGroupCssClasses' => 'mb-1'
|
||||
@@ -245,8 +245,8 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'qu_factor_purchase_to_stock',
|
||||
'label' => 'Factor purchase to stock quantity unit',
|
||||
'min' => 0.0001,
|
||||
'decimals' => 4,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => $value,
|
||||
'invalidFeedback' => $__t('The amount cannot be lower than %s', '1'),
|
||||
'additionalCssClasses' => 'input-group-qu',
|
||||
@@ -287,8 +287,8 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'tare_weight',
|
||||
'label' => 'Tare weight',
|
||||
'min' => 0.0001,
|
||||
'decimals' => 4,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => $value,
|
||||
'invalidFeedback' => $__t('This cannot be lower than %s', '0'),
|
||||
'additionalAttributes' => $additionalAttributes,
|
||||
@@ -316,8 +316,8 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'calories',
|
||||
'label' => 'Energy (kcal)',
|
||||
'min' => 0.0001,
|
||||
'decimals' => 4,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => $value,
|
||||
'invalidFeedback' => $__t('The amount cannot be lower than %s', '0'),
|
||||
'hint' => $__t('Per stock quantity unit'),
|
||||
|
@@ -47,8 +47,8 @@
|
||||
'id' => 'amount',
|
||||
'label' => 'Amount',
|
||||
'hintId' => 'amount_qu_unit',
|
||||
'min' => 0.0001,
|
||||
'decimals' => 4,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'invalidFeedback' => $__t('The amount cannot be lower than %s', '1'),
|
||||
'additionalHtmlContextHelp' => '<div id="tare-weight-handling-info"
|
||||
class="text-info font-italic d-none">' . $__t('Tare weight handling enabled - please weigh the whole container, the amount to be posted will be automatically calculcated') . '</div>'
|
||||
@@ -85,7 +85,6 @@
|
||||
'shortcutLabel' => 'Never expires',
|
||||
'earlierThanInfoLimit' => date('Y-m-d'),
|
||||
'earlierThanInfoText' => $__t('The given date is earlier than today, are you sure?'),
|
||||
'additionalGroupCssClasses' => $additionalGroupCssClasses,
|
||||
'activateNumberPad' => GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_FIELD_NUMBER_PAD
|
||||
))
|
||||
@endif
|
||||
@@ -94,14 +93,15 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'price',
|
||||
'label' => 'Price',
|
||||
'min' => 0.01,
|
||||
'decimals' => 2,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_prices'] - 1) . '1',
|
||||
'decimals' => $userSettings['stock_decimal_places_prices'],
|
||||
'value' => '',
|
||||
'hintId' => 'price-hint',
|
||||
'invalidFeedback' => $__t('The price cannot be lower than %s', '0'),
|
||||
'isRequired' => false,
|
||||
'additionalGroupCssClasses' => 'mb-1'
|
||||
))
|
||||
|
||||
<div class="form-check form-check-inline mb-3">
|
||||
<input class="form-check-input"
|
||||
type="radio"
|
||||
@@ -135,8 +135,8 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'qu_factor_purchase_to_stock',
|
||||
'label' => 'Factor purchase to stock quantity unit',
|
||||
'min' => 0.0001,
|
||||
'decimals' => 4,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'additionalGroupCssClasses' => 'd-none',
|
||||
'invalidFeedback' => $__t('The amount cannot be lower than %s', '1'),
|
||||
'additionalCssClasses' => 'input-group-qu',
|
||||
|
@@ -81,8 +81,8 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'factor',
|
||||
'label' => 'Factor',
|
||||
'min' => 0.0001,
|
||||
'decimals' => 4,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => $value,
|
||||
'invalidFeedback' => $__t('This cannot be lower than %1$s and must be a valid number with max. %2$s decimal places', '0', '3'),
|
||||
'additionalHtmlElements' => '<p id="qu-conversion-info"
|
||||
|
@@ -38,8 +38,8 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'amount',
|
||||
'label' => 'Amount',
|
||||
'min' => 0.0001,
|
||||
'decimals' => 4,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'isRequired' => false,
|
||||
'value' => 1
|
||||
))
|
||||
|
@@ -91,8 +91,8 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'base_servings',
|
||||
'label' => 'Servings',
|
||||
'min' => 0.01,
|
||||
'decimals' => 2,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => $value,
|
||||
'invalidFeedback' => $__t('This cannot be lower than %s', '1'),
|
||||
'hint' => $__t('The ingredients listed here result in this amount of servings')
|
||||
@@ -334,8 +334,8 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'includes_servings',
|
||||
'label' => 'Servings',
|
||||
'min' => 0.01,
|
||||
'decimals' => 2,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => '1',
|
||||
'invalidFeedback' => $__t('This cannot be lower than %s', '1')
|
||||
))
|
||||
|
@@ -106,8 +106,8 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'price_factor',
|
||||
'label' => 'Price factor',
|
||||
'min' => 0.01,
|
||||
'decimals' => 2,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => '',
|
||||
'hint' => $__t('The resulting price of this ingredient will be multiplied by this factor'),
|
||||
'invalidFeedback' => $__t('This cannot be lower than %s', '0'),
|
||||
|
@@ -297,8 +297,8 @@
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'servings-scale',
|
||||
'label' => 'Desired servings',
|
||||
'min' => 0.01,
|
||||
'decimals' => 2,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => $recipe->desired_servings,
|
||||
'invalidFeedback' => $__t('This cannot be lower than %s', '1'),
|
||||
'additionalAttributes' => 'data-recipe-id="' . $recipe->id . '"',
|
||||
|
@@ -64,10 +64,10 @@
|
||||
'id' => 'amount',
|
||||
'label' => 'Amount',
|
||||
'hintId' => 'amount_qu_unit',
|
||||
'min' => 0.0001,
|
||||
'decimals' => 4,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => $value,
|
||||
'invalidFeedback' => $__t('The amount cannot be lower than %s', '0.01')
|
||||
'invalidFeedback' => $__t('The amount cannot be lower than %s', '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1')
|
||||
))
|
||||
|
||||
<div class="form-group">
|
||||
|
@@ -66,8 +66,8 @@
|
||||
'id' => 'qu_factor_purchase_to_stock',
|
||||
'label' => 'Factor purchase to stock quantity unit',
|
||||
'value' => $stockEntry->qu_factor_purchase_to_stock,
|
||||
'min' => 0.0001,
|
||||
'decimals' => 4,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'invalidFeedback' => $__t('The amount cannot be lower than %s', '1'),
|
||||
'additionalCssClasses' => 'input-group-qu',
|
||||
'additionalHtmlElements' => '<p id="qu-conversion-info"
|
||||
@@ -89,8 +89,8 @@
|
||||
'id' => 'price',
|
||||
'value' => $price,
|
||||
'label' => 'Price',
|
||||
'min' => 0.01,
|
||||
'decimals' => 2,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_prices'] - 1) . '1',
|
||||
'decimals' => $userSettings['stock_decimal_places_prices'],
|
||||
'hint' => $__t('in %s per purchase quantity unit', GROCY_CURRENCY),
|
||||
'invalidFeedback' => $__t('The price cannot be lower than %s', '0'),
|
||||
'isRequired' => false
|
||||
|
@@ -71,7 +71,7 @@
|
||||
'additionalAttributes' => 'data-setting-key="stock_default_purchase_amount"',
|
||||
'label' => 'Default amount for purchase',
|
||||
'min' => 0,
|
||||
'decimals' => 4,
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'invalidFeedback' => $__t('This cannot be lower than %s', '1'),
|
||||
'additionalCssClasses' => 'user-setting-control'
|
||||
))
|
||||
@@ -82,11 +82,33 @@
|
||||
'additionalAttributes' => 'data-setting-key="stock_default_consume_amount"',
|
||||
'label' => 'Default amount for consume',
|
||||
'min' => 0,
|
||||
'decimals' => 4,
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'invalidFeedback' => $__t('This cannot be lower than %s', '1'),
|
||||
'additionalCssClasses' => 'user-setting-control'
|
||||
))
|
||||
|
||||
<h4 class="mt-2">{{ $__t('Common') }}</h4>
|
||||
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'stock_price_decimal_amounts',
|
||||
'additionalAttributes' => 'data-setting-key="stock_price_decimal_amounts"',
|
||||
'label' => 'Decimal places allowed for amounts',
|
||||
'min' => 0,
|
||||
'decimals' => 0,
|
||||
'invalidFeedback' => $__t('This cannot be lower than %s', '0'),
|
||||
'additionalCssClasses' => 'user-setting-control'
|
||||
))
|
||||
|
||||
@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="checkbox">
|
||||
<label for="show_icon_on_stock_overview_page_when_product_is_on_shopping_list">
|
||||
|
@@ -46,8 +46,8 @@
|
||||
'id' => 'amount',
|
||||
'label' => 'Amount',
|
||||
'hintId' => 'amount_qu_unit',
|
||||
'min' => 0.0001,
|
||||
'decimals' => 4,
|
||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts'] - 1) . '1',
|
||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||
'value' => 1,
|
||||
'invalidFeedback' => $__t('The amount cannot be lower than %s', '1'),
|
||||
'additionalHtmlContextHelp' => '<div id="tare-weight-handling-info"
|
||||
|
Reference in New Issue
Block a user