diff --git a/changelog/77_UNRELEASED_xxxx-xx-xx.md b/changelog/77_UNRELEASED_xxxx-xx-xx.md index dd3fafa5..30222266 100644 --- a/changelog/77_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/77_UNRELEASED_xxxx-xx-xx.md @@ -23,6 +23,10 @@ - Added a new product option "Can't be opened" - When enabled the product open functionality for that product is disabled - Defaults to disabled, so no changed behavior when not configured +- Added a new product option "Default purchase price type" + - Can be used to set the default price type (Unit price / Total price) on the purchase page per product + - Previously "Unit price" was the default on purchase and the selection was not saved and not reset when selecting another product, means the price type selection was retained when doing multiple purchase transactions in one go + - The default for the new product option is "Unspecified" which keeps the previous behavior - When products are automatically added to the shopping list (e.g. by the "below defined min. stock amount"-functionality or when adding missing recipe ingredients) the product's "Default quantity unit purchase" is now used (instead of the product's "Quantity unit stock") - Product barcode matching is now case-insensitive - Added a new column "Product picture" on the products list (master data) page (hidden by default) diff --git a/localization/strings.pot b/localization/strings.pot index 3daab67d..33603884 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -2461,3 +2461,12 @@ msgstr "" msgid "Can't be opened" msgstr "" + +msgid "Default purchase price type" +msgstr "" + +msgid "This will be used as the default price type selection on purchase" +msgstr "" + +msgid "Unspecified" +msgstr "" diff --git a/migrations/0248.sql b/migrations/0248.sql index c3b07331..72ee0252 100644 --- a/migrations/0248.sql +++ b/migrations/0248.sql @@ -1,6 +1,9 @@ ALTER TABLE products ADD disable_open TINYINT NOT NULL DEFAULT 0 CHECK(disable_open IN (0, 1)); +ALTER TABLE products +ADD default_purchase_price_type TINYINT NOT NULL DEFAULT 1 CHECK(default_purchase_price_type IN (1, 2, 3)); + DROP VIEW uihelper_stock_current_overview; CREATE VIEW uihelper_stock_current_overview AS diff --git a/public/viewjs/purchase.js b/public/viewjs/purchase.js index de5215ba..9c2e18a8 100644 --- a/public/viewjs/purchase.js +++ b/public/viewjs/purchase.js @@ -343,6 +343,15 @@ if (Grocy.Components.ProductPicker !== undefined) $("#stock_label_type").trigger("change"); } + if (productDetails.product.default_purchase_price_type == 2) + { + $("#price-type-unit-price").click(); + } + else if (productDetails.product.default_purchase_price_type == 3) + { + $("#price-type-total-price").click(); + } + setTimeout(function() { $('#display_amount').focus(); diff --git a/views/productform.blade.php b/views/productform.blade.php index 1429436d..c5409b6e 100644 --- a/views/productform.blade.php +++ b/views/productform.blade.php @@ -570,6 +570,57 @@ @endif + @if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) +