From efae0b193d8d085836cedbe24ac971b1e0754704 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Thu, 29 Dec 2022 11:21:33 +0100 Subject: [PATCH] Add amount to barcode created by the workflow InplaceAddBarcodeToExistingProduct on /purchase (closes #2085) --- changelog/70_UNRELEASED_xxxx.xx.xx.md | 1 + public/viewjs/components/productamountpicker.js | 2 +- public/viewjs/consume.js | 4 ++-- public/viewjs/inventory.js | 4 ++-- public/viewjs/purchase.js | 6 ++++-- public/viewjs/transfer.js | 4 ++-- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/changelog/70_UNRELEASED_xxxx.xx.xx.md b/changelog/70_UNRELEASED_xxxx.xx.xx.md index 767193a3..cfb83291 100644 --- a/changelog/70_UNRELEASED_xxxx.xx.xx.md +++ b/changelog/70_UNRELEASED_xxxx.xx.xx.md @@ -19,6 +19,7 @@ - The product's "Quick consume amount" is now displayed related to this quantity unit ("quick consume/open buttons" on the stock overview page) - Defaults to the product's "Quantity unit stock" (so no changed behavior when not configured) - Changed that when the ingredient option "Only check if any amount is in stock" is enabled, costs and calories are now based on the original entered amount instead of an "virtual" fixed amount of `1` +- When using the "Add as barcode to existing product" workflow on a purchase transaction, the selected quantity unit and the entered amount is now also added to the new barcode - Fixed that hiding the "Purchased date" column (table options) on the stock entries 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 diff --git a/public/viewjs/components/productamountpicker.js b/public/viewjs/components/productamountpicker.js index 0079090f..8d856e32 100644 --- a/public/viewjs/components/productamountpicker.js +++ b/public/viewjs/components/productamountpicker.js @@ -17,7 +17,7 @@ Grocy.Components.ProductAmountPicker.Reload = function(productId, destinationQuI // Only conversions related to the destination QU are needed // + only add one conversion per to_qu_id (multiple ones can be a result of contradictory definitions = user input bullshit) - if (conversion.from_qu_id == destinationQuId && !$('#qu_id option[value="' + conversion.to_qu_id + '"]').length) + if ((conversion.from_qu_id == destinationQuId || conversion.to_qu_id == destinationQuId) && !$('#qu_id option[value="' + conversion.to_qu_id + '"]').length) { $("#qu_id").append(''); } diff --git a/public/viewjs/consume.js b/public/viewjs/consume.js index 81073d38..abc3afd4 100644 --- a/public/viewjs/consume.js +++ b/public/viewjs/consume.js @@ -434,13 +434,13 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e) if (barcode != null) { - if (barcode.amount != null && !barcode.amount.isEmpty()) + if (barcode.amount != null) { $("#display_amount").val(barcode.amount); $("#display_amount").select(); } - if (barcode.qu_id != null && !barcode.qu_id.isEmpty()) + if (barcode.qu_id != null) { Grocy.Components.ProductAmountPicker.SetQuantityUnit(barcode.qu_id); } diff --git a/public/viewjs/inventory.js b/public/viewjs/inventory.js index b4c41f4a..55f9ba01 100644 --- a/public/viewjs/inventory.js +++ b/public/viewjs/inventory.js @@ -277,13 +277,13 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e) if (barcode != null) { - if (barcode.amount != null && !barcode.amount.isEmpty()) + if (barcode.amount != null) { $("#display_amount").val(barcode.amount); $("#display_amount").select(); } - if (barcode.qu_id != null && !barcode.qu_id.isEmpty()) + if (barcode.qu_id != null) { Grocy.Components.ProductAmountPicker.SetQuantityUnit(barcode.qu_id); } diff --git a/public/viewjs/purchase.js b/public/viewjs/purchase.js index 910caaec..8c0ba118 100644 --- a/public/viewjs/purchase.js +++ b/public/viewjs/purchase.js @@ -99,6 +99,8 @@ $('#save-purchase-button').on('click', function(e) jsonDataBarcode.barcode = GetUriParam("barcode"); jsonDataBarcode.product_id = jsonForm.product_id; jsonDataBarcode.shopping_location_id = jsonForm.shopping_location_id; + jsonDataBarcode.qu_id = jsonForm.qu_id; + jsonDataBarcode.amount = jsonForm.display_amount; Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode, function(result) @@ -361,13 +363,13 @@ if (Grocy.Components.ProductPicker !== undefined) if (barcode != null) { - if (barcode.amount != null && !barcode.amount.isEmpty()) + if (barcode.amount != null) { $("#display_amount").val(barcode.amount); $("#display_amount").select(); } - if (barcode.qu_id != null && !barcode.qu_id.isEmpty()) + if (barcode.qu_id != null) { Grocy.Components.ProductAmountPicker.SetQuantityUnit(barcode.qu_id); } diff --git a/public/viewjs/transfer.js b/public/viewjs/transfer.js index dec23cc5..1eb58cde 100644 --- a/public/viewjs/transfer.js +++ b/public/viewjs/transfer.js @@ -222,13 +222,13 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e) if (barcode != null) { - if (barcode.amount != null && !barcode.amount.isEmpty()) + if (barcode.amount != null) { $("#display_amount").val(barcode.amount); $("#display_amount").select(); } - if (barcode.qu_id != null && !barcode.qu_id.isEmpty()) + if (barcode.qu_id != null) { Grocy.Components.ProductAmountPicker.SetQuantityUnit(barcode.qu_id); }