Prefill barcode note on /purchase and /inventory (closes #2193)

This commit is contained in:
Bernd Bestel 2023-04-17 19:54:24 +02:00
parent 84bd74a1bc
commit f4874ed8d0
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
3 changed files with 19 additions and 8 deletions

View File

@ -32,6 +32,7 @@
- Changed that for the product's average and last price (and for the price history chart) stock transactions with an empty or `0` price are ignored
- Added a filter option to only show currently out-of-stock products on the products list (master data) page
- When clicking the product name on the products list (master data) page, the product card will now be displayed (like on the stock overview page)
- When using/scanning a product barcode and the purchase or inventory page, the barcode's note will now also be prefilled (if any)
- Fixed that hiding the "Purchased date" column (table options) on the stock entries page didn't work
- Fixed that sorting by the "Value" and "Min. stock amount" columns on the stock overview page didn't work
- Fixed that the consumed amount was wrong, when consuming multiple substituted subproducts at once and when multiple/different conversion factors were involved

View File

@ -272,23 +272,28 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
Grocy.Api.Get('objects/product_barcodes?query[]=barcode=' + document.getElementById("product_id").getAttribute("barcode"),
function(barcodeResult)
{
if (barcodeResult != null)
if (barcodeResult)
{
var barcode = barcodeResult[0];
if (barcode != null)
if (barcode)
{
if (barcode.amount != null)
if (barcode.amount)
{
$("#display_amount").val(barcode.amount);
$("#display_amount").select();
}
if (barcode.qu_id != null)
if (barcode.qu_id)
{
Grocy.Components.ProductAmountPicker.SetQuantityUnit(barcode.qu_id);
}
if (barcode.note)
{
$("#note").val(barcode.note);
}
$(".input-group-productamountpicker").trigger("change");
Grocy.FrontendHelpers.ValidateForm('inventory-form');
RefreshLocaleNumberInput();

View File

@ -357,20 +357,20 @@ if (Grocy.Components.ProductPicker !== undefined)
Grocy.Api.Get('objects/product_barcodes?query[]=barcode=' + document.getElementById("product_id").getAttribute("barcode"),
function(barcodeResult)
{
if (barcodeResult != null)
if (barcodeResult)
{
var barcode = barcodeResult[0];
$("#purchase-form").attr("data-used-barcode", barcode.id);
if (barcode != null)
if (barcode)
{
if (barcode.amount != null)
if (barcode.amount)
{
$("#display_amount").val(barcode.amount);
$("#display_amount").select();
}
if (barcode.qu_id != null)
if (barcode.qu_id)
{
Grocy.Components.ProductAmountPicker.SetQuantityUnit(barcode.qu_id);
}
@ -386,6 +386,11 @@ if (Grocy.Components.ProductPicker !== undefined)
$("#price-type-total-price").click();
}
if (barcode.note)
{
$("#note").val(barcode.note);
}
$(".input-group-productamountpicker").trigger("change");
Grocy.FrontendHelpers.ValidateForm('purchase-form');
RefreshLocaleNumberInput();