Added a new product option default_purchase_price_type (closes #566)

This commit is contained in:
Bernd Bestel 2025-01-19 16:35:45 +01:00
parent f3effc5a60
commit e3965ed82c
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
5 changed files with 76 additions and 0 deletions

View File

@ -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)

View File

@ -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 ""

View File

@ -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

View File

@ -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();

View File

@ -570,6 +570,57 @@
</div>
@endif
@if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
<div class="form-group">
<label class="d-block my-0"
for="default_purchase_price_type">{{ $__t('Default purchase price type') }}
<i class="fa-solid fa-question-circle text-muted"
data-toggle="tooltip"
data-trigger="hover click"
title="{{ $__t('This will be used as the default price type selection on purchase') }}"></i>
</label>
<div class="custom-control custom-radio mt-n2">
<input class="custom-control-input"
type="radio"
name="default_purchase_price_type"
id="default-purchase-price-type-unspecified"
value="1"
@if($mode=='edit'
&&
$product->default_purchase_price_type == 1) checked @else checked @endif>
<label class="custom-control-label"
for="default-purchase-price-type-unspecified">{{ $__t('Unspecified') }}
</label>
</div>
<div class="custom-control custom-radio mt-n2">
<input class="custom-control-input"
type="radio"
name="default_purchase_price_type"
id="default-purchase-price-type-unit-price"
value="2"
@if($mode=='edit'
&&
$product->default_purchase_price_type == 2) checked @endif>
<label class="custom-control-label"
for="default-purchase-price-type-unit-price">{{ $__t('Unit price') }}
</label>
</div>
<div class="custom-control custom-radio mt-n2">
<input class="custom-control-input"
type="radio"
name="default_purchase_price_type"
id="default-purchase-price-type-total-price"
value="3"
@if($mode=='edit'
&&
$product->default_purchase_price_type == 3) checked @endif>
<label class="custom-control-label"
for="default-purchase-price-type-total-price">{{ $__t('Total price') }}
</label>
</div>
</div>
@endif
@if(GROCY_FEATURE_FLAG_STOCK_PRODUCT_OPENED_TRACKING)
<div class="form-group">
<div class="custom-control custom-checkbox">