diff --git a/changelog/53_UNRELEASED_2019-xx-xx.md b/changelog/53_UNRELEASED_2019-xx-xx.md index 64192e8b..69ca005b 100644 --- a/changelog/53_UNRELEASED_2019-xx-xx.md +++ b/changelog/53_UNRELEASED_2019-xx-xx.md @@ -5,6 +5,7 @@ - After product actions (consume/purchase/etc.) on the stock overview page on a sub product, now also the parent product (row) is refreshed - It's now possible to accumulate min. stock amounts on parent product level (new option per product, means the sub product will never be "missing" then, only the parent product) - When adding a product to the shopping list from the new context/more menu from the stock overview page and if the product is already on the shopping list, the amount of that entry will be updated acccordingly instead of adding a new (double) shopping list item +- On the purchase page there is now an option to select that the price is the total price (for the whole amount) - below the price field, defaults to "Unit price" (as it was until now), when set to "Total price", the entered price will be divided by the amount before posting ### Recipe improvements/fixes - Fixed a problem regarding quantity unit conversion handling for recipe ingredients of products with no unit relations, but only a different purchase/stock quantity unit diff --git a/localization/strings.pot b/localization/strings.pot index 89cc8cfe..5593f8d7 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -1528,3 +1528,12 @@ msgstr "" msgid "Are you sure to remove this conversion?" msgstr "" + +msgid "Unit price" +msgstr "" + +msgid "Total price" +msgstr "" + +msgid "in %s and based on the purchase quantity unit" +msgstr "" diff --git a/public/viewjs/purchase.js b/public/viewjs/purchase.js index 75b11f5a..15f4fe8e 100644 --- a/public/viewjs/purchase.js +++ b/public/viewjs/purchase.js @@ -14,6 +14,16 @@ if (!jsonForm.price.toString().isEmpty()) { price = parseFloat(jsonForm.price).toFixed(2); + + if ($("input[name='price-type']:checked").val() == "total-price") + { + price = price / amount; + } + } + + if (!Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) + { + price = 0; } var jsonData = {}; diff --git a/views/purchase.blade.php b/views/purchase.blade.php index 354495b2..c493ff97 100644 --- a/views/purchase.blade.php +++ b/views/purchase.blade.php @@ -57,10 +57,19 @@ 'min' => 0, 'step' => 0.0001, 'value' => '', - 'hint' => $__t('in %s per purchase quantity unit', GROCY_CURRENCY), + 'hint' => $__t('in %s and based on the purchase quantity unit', GROCY_CURRENCY), 'invalidFeedback' => $__t('The price cannot be lower than %s', '0'), - 'isRequired' => false + 'isRequired' => false, + 'additionalGroupCssClasses' => 'mb-1' )) +
+ + +
+
+ + +
@else @endif