From 260cccd2992ac6a58f4cf42220f74609c5f0bb61 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Mon, 18 Apr 2022 17:21:23 +0200 Subject: [PATCH] Code formatting / naming --- localization/strings.pot | 1 - public/viewjs/productform.js | 22 ++++++++++++++-------- services/StockService.php | 7 +++++-- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/localization/strings.pot b/localization/strings.pot index 93238a29..c1c1fdfc 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -2330,6 +2330,5 @@ msgstr "" msgid "Move on open" msgstr "" - msgid "When checked, opening the product will move one unit to the default consume location" msgstr "" diff --git a/public/viewjs/productform.js b/public/viewjs/productform.js index 90106713..59a6bca8 100644 --- a/public/viewjs/productform.js +++ b/public/viewjs/productform.js @@ -239,20 +239,26 @@ $('#product-form input').keyup(function(event) $('#location_id').change(function(event) { Grocy.FrontendHelpers.ValidateForm('product-form'); - updateMoveOnOpen(); -}); -$('#default_consume_location_id').change(function(event) { - updateMoveOnOpen(); + UpdateMoveOnOpen(); }); -function updateMoveOnOpen() { +$('#default_consume_location_id').change(function(event) +{ + UpdateMoveOnOpen(); +}); + +function UpdateMoveOnOpen() +{ var defaultLocation = $("#location_id :selected").val(); var consumeLocationLocation = $("#default_consume_location_id :selected").val(); - if (!consumeLocationLocation || defaultLocation === consumeLocationLocation) { + if (!consumeLocationLocation || defaultLocation === consumeLocationLocation) + { document.getElementById("move_on_open").checked = false; $("#move_on_open").attr("disabled", true); - } else { + } + else + { $("#move_on_open").attr("disabled", false); } } @@ -572,7 +578,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e) } }); -updateMoveOnOpen(); +UpdateMoveOnOpen(); Grocy.FrontendHelpers.ValidateForm("product-form"); Grocy.Components.ProductPicker.GetPicker().trigger("change"); diff --git a/services/StockService.php b/services/StockService.php index 84728376..804040ca 100644 --- a/services/StockService.php +++ b/services/StockService.php @@ -1057,9 +1057,12 @@ class StockService extends BaseService $amount = 0; } - if ($product->move_on_open) { + + if ($product->move_on_open) + { $locationIdTo = $product->default_consume_location_id; - if ($locationIdTo && $locationIdTo !== $stockEntry->location_id) { + if ($locationIdTo && $locationIdTo !== $stockEntry->location_id) + { $this->TransferProduct($stockEntry->product_id, $amount, $stockEntry->location_id, $locationIdTo, $stockEntry->stock_id, $transactionId); } }