Code formatting / naming

This commit is contained in:
Bernd Bestel 2022-04-18 17:21:23 +02:00
parent 4374712346
commit 260cccd299
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
3 changed files with 19 additions and 11 deletions

View File

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

View File

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

View File

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