\
');
- if (productDetails.product.picture_file_name && !productDetails.product.picture_file_name.isEmpty())
+ if (productDetails.product.picture_file_name)
{
element.prepend('
')
}
@@ -823,7 +823,7 @@ $(document).on('click', '.product-consume-button', function(e)
Grocy.FrontendHelpers.BeginUiBusy();
var productId = $(e.currentTarget).attr('data-product-id');
- var consumeAmount = parseFloat($(e.currentTarget).attr('data-product-amount'));
+ var consumeAmount = Number.parseFloat($(e.currentTarget).attr('data-product-amount'));
var mealPlanEntryId = $(e.currentTarget).attr('data-mealplan-entry-id');
Grocy.Api.Post('stock/products/' + productId + '/consume', { 'amount': consumeAmount, 'spoiled': false },
diff --git a/public/viewjs/productform.js b/public/viewjs/productform.js
index c6dbdcb2..554ab8cd 100644
--- a/public/viewjs/productform.js
+++ b/public/viewjs/productform.js
@@ -93,11 +93,6 @@ $('.save-product-button').on('click', function(e)
jsonData.parent_product_id = parentProductId;
Grocy.FrontendHelpers.BeginUiBusy("product-form");
- if (jsonData.parent_product_id.toString().isEmpty())
- {
- jsonData.parent_product_id = null;
- }
-
if ($("#product-picture")[0].files.length > 0)
{
var someRandomStuff = Math.random().toString(36).substring(2, 100) + Math.random().toString(36).substring(2, 100);
@@ -396,7 +391,7 @@ if (Grocy.EditMode == "create" && GetUriParam("copy-of") != undefined)
{
Grocy.Components.ProductPicker.SetId(sourceProduct.parent_product_id);
}
- if (sourceProduct.description != null && !sourceProduct.description.isEmpty())
+ if (sourceProduct.description)
{
$("#description").summernote("pasteHTML", sourceProduct.description);
}
diff --git a/public/viewjs/purchase.js b/public/viewjs/purchase.js
index 9049d902..71254ee1 100644
--- a/public/viewjs/purchase.js
+++ b/public/viewjs/purchase.js
@@ -37,16 +37,16 @@ $('#save-purchase-button').on('click', function(e)
}
else
{
- var amount = jsonForm.display_amount;
+ var amount = Number.parseFloat(jsonForm.display_amount);
if (BoolVal(productDetails.product.enable_tare_weight_handling))
{
- amount -= parseFloat(productDetails.product.tare_weight);
+ amount -= productDetails.product.tare_weight;
}
- var price = parseFloat(jsonForm.price * $("#qu_id option:selected").attr("data-qu-factor")).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
+ var price = Number.parseFloat(jsonForm.price * $("#qu_id option:selected").attr("data-qu-factor")).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
if ($("input[name='price-type']:checked").val() == "total-price")
{
- price = parseFloat(price / amount).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
+ price = (price / amount).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
}
jsonData.price = price;
@@ -119,10 +119,10 @@ $('#save-purchase-button').on('click', function(e)
);
}
- var amountMessage = parseFloat(jsonForm.amount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts });
+ var amountMessage = Number.parseFloat(jsonForm.amount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts });
if (BoolVal(productDetails.product.enable_tare_weight_handling))
{
- amountMessage = parseFloat(jsonForm.amount) - parseFloat(productDetails.stock_amount) - parseFloat(productDetails.product.tare_weight);
+ amountMessage = Number.parseFloat(jsonForm.amount) - productDetails.stock_amount - productDetails.product.tare_weight;
}
var successMessage = __t('Added %1$s of %2$s to stock', amountMessage + " " + __n(amountMessage, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural, true), productDetails.product.name) + ' ' + __t("Undo") + '';
@@ -200,7 +200,7 @@ $('#save-purchase-button').on('click', function(e)
Grocy.Components.ProductAmountPicker.Reset();
$("#purchase-form").removeAttr("data-used-barcode");
$("#display_amount").attr("min", Grocy.DefaultMinAmount);
- $('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_purchase_amount));
+ $('#display_amount').val(Grocy.UserSettings.stock_default_purchase_amount);
$(".input-group-productamountpicker").trigger("change");
$('#price').val('');
$("#tare-weight-handling-info").addClass("d-none");
@@ -280,13 +280,13 @@ if (Grocy.Components.ProductPicker !== undefined)
{
Grocy.Components.ProductAmountPicker.SetQuantityUnit(productDetails.default_quantity_unit_purchase.id);
}
- $('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_purchase_amount));
+ $('#display_amount').val(Grocy.UserSettings.stock_default_purchase_amount);
$(".input-group-productamountpicker").trigger("change");
if (GetUriParam("flow") === "shoppinglistitemtostock")
{
Grocy.Components.ProductAmountPicker.SetQuantityUnit(GetUriParam("quId"));
- $('#display_amount').val(parseFloat(GetUriParam("amount") * $("#qu_id option:selected").attr("data-qu-factor")));
+ $('#display_amount').val(Number.parseFloat(GetUriParam("amount") * $("#qu_id option:selected").attr("data-qu-factor")));
}
$(".input-group-productamountpicker").trigger("change");
@@ -314,7 +314,7 @@ if (Grocy.Components.ProductPicker !== undefined)
}
else
{
- $('#price').val(parseFloat(productDetails.last_price / $("#qu_id option:selected").attr("data-qu-factor")));
+ $('#price').val(productDetails.last_price / $("#qu_id option:selected").attr("data-qu-factor"));
}
var priceTypeUnitPrice = $("#price-type-unit-price");
@@ -325,7 +325,7 @@ if (Grocy.Components.ProductPicker !== undefined)
if (productDetails.product.enable_tare_weight_handling == 1)
{
- var minAmount = parseFloat(productDetails.product.tare_weight) / $("#qu_id option:selected").attr("data-qu-factor") + parseFloat(productDetails.stock_amount);
+ var minAmount = productDetails.product.tare_weight / $("#qu_id option:selected").attr("data-qu-factor") + productDetails.stock_amount;
$("#display_amount").attr("min", minAmount);
$("#tare-weight-handling-info").removeClass("d-none");
}
@@ -380,7 +380,7 @@ if (Grocy.Components.ProductPicker !== undefined)
Grocy.Components.ShoppingLocationPicker.SetId(barcode.shopping_location_id);
}
- if (barcode.last_price != null && !barcode.last_price.isEmpty())
+ if (barcode.last_price)
{
$("#price").val(barcode.last_price);
$("#price-type-total-price").click();
@@ -436,7 +436,6 @@ function PrefillBestBeforeDate(product, location)
dueDays = product.default_best_before_days;
}
- dueDays = parseFloat(dueDays);
if (dueDays != 0)
{
if (dueDays == -1)
@@ -472,7 +471,7 @@ if (Grocy.Components.LocationPicker !== undefined)
});
}
-$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_purchase_amount));
+$('#display_amount').val(Grocy.UserSettings.stock_default_purchase_amount);
RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change");
Grocy.FrontendHelpers.ValidateForm('purchase-form');
@@ -592,16 +591,16 @@ function refreshPriceHint()
if ($("input[name='price-type']:checked").val() == "total-price" || $("#qu_id").attr("data-destination-qu-name") != $("#qu_id option:selected").text())
{
- var amount = $('#display_amount').val();
+ var amount = Number.parseFloat($('#display_amount').val());
if (BoolVal(CurrentProductDetails.product.enable_tare_weight_handling))
{
- amount -= parseFloat(CurrentProductDetails.product.tare_weight);
+ amount -= CurrentProductDetails.product.tare_weight;
}
- var price = parseFloat($('#price').val() * $("#qu_id option:selected").attr("data-qu-factor")).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
+ var price = Number.parseFloat($('#price').val() * $("#qu_id option:selected").attr("data-qu-factor")).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
if ($("input[name='price-type']:checked").val() == "total-price")
{
- price = parseFloat(price / amount).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
+ price = (price / amount).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
}
$('#price-hint').text(__t('means %1$s per %2$s', price.toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display }), $("#qu_id").attr("data-destination-qu-name")));
diff --git a/public/viewjs/quantityunitform.js b/public/viewjs/quantityunitform.js
index 5acba767..366030bd 100644
--- a/public/viewjs/quantityunitform.js
+++ b/public/viewjs/quantityunitform.js
@@ -101,7 +101,7 @@
$('#quantityunit-form input').keyup(function(event)
{
- if (!$("#name").val().isEmpty())
+ if ($("#name").val())
{
$("#qu-conversion-headline-info").text(__t('1 %s is the same as...', $("#name").val()));
}
diff --git a/public/viewjs/quantityunitpluraltesting.js b/public/viewjs/quantityunitpluraltesting.js
index 0ee08c16..c5169ce8 100644
--- a/public/viewjs/quantityunitpluraltesting.js
+++ b/public/viewjs/quantityunitpluraltesting.js
@@ -19,7 +19,7 @@ function RefreshQuPluralTestingResult()
var pluralForm = $("#qu_id option:selected").data("plural-form");
var amount = $("#amount").val();
- if (singularForm.toString().isEmpty() || amount.toString().isEmpty())
+ if (!singularForm || !amount)
{
return;
}
diff --git a/public/viewjs/recipes.js b/public/viewjs/recipes.js
index e2bba809..34fb17c3 100644
--- a/public/viewjs/recipes.js
+++ b/public/viewjs/recipes.js
@@ -72,7 +72,7 @@ $("#search").on("keyup", Delay(function()
recipesTables.search(value).draw();
- if (value.isEmpty())
+ if (!value)
{
RemoveUriParam("search");
}
@@ -120,7 +120,7 @@ $("#status-filter").on("change", function()
}
}
- if (value.isEmpty())
+ if (!value)
{
RemoveUriParam("status");
}
diff --git a/public/viewjs/shoppinglist.js b/public/viewjs/shoppinglist.js
index 965a30a8..c7f5dff5 100644
--- a/public/viewjs/shoppinglist.js
+++ b/public/viewjs/shoppinglist.js
@@ -508,7 +508,7 @@ $(document).on("click", "#print-shopping-list-button", function(e)
$(".print-timestamp").text(moment().format("l LT"));
$("#description-for-print").html($("#description").val());
- if ($("#description").text().isEmpty())
+ if (!$("#description").text())
{
$("#description-for-print").parent().addClass("d-print-none");
}
diff --git a/public/viewjs/shoppinglistitemform.js b/public/viewjs/shoppinglistitemform.js
index 3fc88947..1c126e46 100644
--- a/public/viewjs/shoppinglistitemform.js
+++ b/public/viewjs/shoppinglistitemform.js
@@ -15,7 +15,7 @@ $('#save-shoppinglist-button').on('click', function(e)
}
var jsonData = $('#shoppinglist-form').serializeJSON();
- var displayAmount = parseFloat(jsonData.display_amount);
+ var displayAmount = Number.parseFloat(jsonData.display_amount);
if (!jsonData.product_id)
{
jsonData.amount = jsonData.display_amount;
@@ -200,7 +200,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
Grocy.Components.ProductAmountPicker.SetQuantityUnit(productDetails.default_quantity_unit_purchase.id);
}
- if ($("#display_amount").val().toString().isEmpty())
+ if (!$("#display_amount").val())
{
$("#display_amount").val(1);
$("#display_amount").trigger("change");
@@ -267,7 +267,7 @@ if (GetUriParam("list") !== undefined)
if (GetUriParam("amount") !== undefined)
{
- $("#display_amount").val(parseFloat(GetUriParam("amount")));
+ $("#display_amount").val(Number.parseFloat(GetUriParam("amount")));
RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change");
Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');
diff --git a/public/viewjs/stockentries.js b/public/viewjs/stockentries.js
index a0d180b3..1eae6e7b 100644
--- a/public/viewjs/stockentries.js
+++ b/public/viewjs/stockentries.js
@@ -19,7 +19,7 @@ $.fn.dataTable.ext.search.push(function(settings, data, dataIndex)
{
var productId = Grocy.Components.ProductPicker.GetValue();
- if ((isNaN(productId) || productId == "" || productId == data[1]))
+ if (!productId || Number.isNaN(productId) || productId == data[1])
{
return true;
}
@@ -71,7 +71,7 @@ $(document).on('click', '.stock-consume-button', function(e)
var locationId = $(e.currentTarget).attr('data-location-id');
var specificStockEntryId = $(e.currentTarget).attr('data-stock-id');
var stockRowId = $(e.currentTarget).attr('data-stockrow-id');
- var consumeAmount = $(e.currentTarget).attr('data-consume-amount');
+ var consumeAmount = Number.parseFloat($(e.currentTarget).attr('data-consume-amount'));
var wasSpoiled = $(e.currentTarget).hasClass("stock-consume-button-spoiled");
@@ -81,7 +81,7 @@ $(document).on('click', '.stock-consume-button', function(e)
Grocy.Api.Get('stock/products/' + productId,
function(result)
{
- var toastMessage = __t('Removed %1$s of %2$s from stock', parseFloat(consumeAmount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural, true), result.product.name) + ' ' + __t("Undo") + '';
+ var toastMessage = __t('Removed %1$s of %2$s from stock', consumeAmount.toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural, true), result.product.name) + ' ' + __t("Undo") + '';
if (wasSpoiled)
{
toastMessage += " (" + __t("Spoiled") + ")";
@@ -249,13 +249,13 @@ function RefreshStockEntryRow(stockRowId)
Grocy.Api.Get("stock/products/" + result.product_id,
function(productDetails)
{
- if (result.price == null || result.price.isEmpty())
+ if (!result.price)
{
result.price = 0;
}
- $('#stock-' + stockRowId + '-price').text(__t("%1$s per %2$s", (Number.parseFloat(result.price) * Number.parseFloat(productDetails.qu_conversion_factor_purchase_to_stock)).toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display }), productDetails.default_quantity_unit_purchase.name));
- $('#stock-' + stockRowId + '-price').attr("data-original-title", __t("%1$s per %2$s", Number.parseFloat(result.price).toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display }), productDetails.quantity_unit_stock.name));
+ $('#stock-' + stockRowId + '-price').text(__t("%1$s per %2$s", (result.price * productDetails.qu_conversion_factor_purchase_to_stock).toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display }), productDetails.default_quantity_unit_purchase.name));
+ $('#stock-' + stockRowId + '-price').attr("data-original-title", __t("%1$s per %2$s", result.price.toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices_display }), productDetails.quantity_unit_stock.name));
},
function(xhr)
{
@@ -267,7 +267,7 @@ function RefreshStockEntryRow(stockRowId)
$('#stock-' + stockRowId + '-purchased-date').text(result.purchased_date);
$('#stock-' + stockRowId + '-purchased-date-timeago').attr('datetime', result.purchased_date + ' 23:59:59');
- if (result.shopping_location_id != null && !result.shopping_location_id.isEmpty())
+ if (result.shopping_location_id)
{
var shoppingLocationName = "";
Grocy.Api.Get("objects/shopping_locations/" + result.shopping_location_id,
diff --git a/public/viewjs/stockentryform.js b/public/viewjs/stockentryform.js
index 9a32560a..dc217287 100644
--- a/public/viewjs/stockentryform.js
+++ b/public/viewjs/stockentryform.js
@@ -15,9 +15,9 @@
var jsonForm = $('#stockentry-form').serializeJSON();
Grocy.FrontendHelpers.BeginUiBusy("stockentry-form");
- if (!jsonForm.price.toString().isEmpty())
+ if (jsonForm.price)
{
- price = parseFloat(jsonForm.price).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
+ price = Number.parseFloat(jsonForm.price).toFixed(Grocy.UserSettings.stock_decimal_places_prices_input);
}
var jsonData = {};
diff --git a/public/viewjs/stockjournal.js b/public/viewjs/stockjournal.js
index 2664fa65..3b582cf3 100644
--- a/public/viewjs/stockjournal.js
+++ b/public/viewjs/stockjournal.js
@@ -108,7 +108,7 @@ $(document).on('click', '.undo-stock-booking-button', function(e)
var correlationId = $("#stock-booking-" + bookingId + "-row").attr("data-correlation-id");
var correspondingBookingsRoot = $("#stock-booking-" + bookingId + "-row");
- if (!correlationId.isEmpty())
+ if (correlationId)
{
correspondingBookingsRoot = $(".stock-booking-correlation-" + correlationId);
}
diff --git a/public/viewjs/stockoverview.js b/public/viewjs/stockoverview.js
index 896c668d..ae2ff774 100755
--- a/public/viewjs/stockoverview.js
+++ b/public/viewjs/stockoverview.js
@@ -137,8 +137,8 @@ $(document).on('click', '.product-consume-button', function(e)
Grocy.FrontendHelpers.BeginUiBusy();
var productId = $(e.currentTarget).attr('data-product-id');
- var consumeAmount = $(e.currentTarget).attr('data-consume-amount');
- var originalTotalStockAmount = $(e.currentTarget).attr('data-original-total-stock-amount');
+ var consumeAmount = Number.parseFloat($(e.currentTarget).attr('data-consume-amount'));
+ var originalTotalStockAmount = Number.parseFloat($(e.currentTarget).attr('data-original-total-stock-amount'));
var wasSpoiled = $(e.currentTarget).hasClass("product-consume-button-spoiled");
Grocy.Api.Post('stock/products/' + productId + '/consume', { 'amount': consumeAmount, 'spoiled': wasSpoiled, 'allow_subproduct_substitution': true },
@@ -149,11 +149,11 @@ $(document).on('click', '.product-consume-button', function(e)
{
if (result.product.enable_tare_weight_handling == 1)
{
- var toastMessage = __t('Removed %1$s of %2$s from stock', parseFloat(originalTotalStockAmount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural, true), result.product.name) + ' ' + __t("Undo") + '';
+ var toastMessage = __t('Removed %1$s of %2$s from stock', originalTotalStockAmount.toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural, true), result.product.name) + ' ' + __t("Undo") + '';
}
else
{
- var toastMessage = __t('Removed %1$s of %2$s from stock', parseFloat(consumeAmount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural, true), result.product.name) + ' ' + __t("Undo") + '';
+ var toastMessage = __t('Removed %1$s of %2$s from stock', consumeAmount.toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural, true), result.product.name) + ' ' + __t("Undo") + '';
}
if (wasSpoiled)
@@ -194,7 +194,7 @@ $(document).on('click', '.product-open-button', function(e)
var productId = $(e.currentTarget).attr('data-product-id');
var productName = $(e.currentTarget).attr('data-product-name');
var productQuName = $(e.currentTarget).attr('data-product-qu-name');
- var amount = $(e.currentTarget).attr('data-open-amount');
+ var amount = Number.parseFloat($(e.currentTarget).attr('data-open-amount'));
var button = $(e.currentTarget);
Grocy.Api.Post('stock/products/' + productId + '/open', { 'amount': amount, 'allow_subproduct_substitution': true },
@@ -209,7 +209,7 @@ $(document).on('click', '.product-open-button', function(e)
}
Grocy.FrontendHelpers.EndUiBusy();
- toastr.success(__t('Marked %1$s of %2$s as opened', parseFloat(amount).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + productQuName, productName) + ' ' + __t("Undo") + '');
+ toastr.success(__t('Marked %1$s of %2$s as opened', amount.toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }) + " " + productQuName, productName) + ' ' + __t("Undo") + '');
if (result.product.move_on_open == 1 && result.default_consume_location != null)
{
@@ -254,7 +254,7 @@ function RefreshStatistics()
var valueSum = 0;
result.forEach(element =>
{
- valueSum += parseFloat(element.value);
+ valueSum += element.value;
});
$("#info-current-stock").text(__n(result.length, '%s Product', '%s Products') + ", " + __t('%s total value', valueSum.toLocaleString(undefined, { style: "currency", currency: Grocy.Currency })));
}
@@ -295,7 +295,7 @@ function RefreshProductRow(productId)
function(result)
{
// Also refresh the parent product, if any
- if (result.product.parent_product_id !== null && !result.product.parent_product_id.toString().isEmpty())
+ if (result.product.parent_product_id)
{
RefreshProductRow(result.product.parent_product_id);
}
@@ -326,7 +326,7 @@ function RefreshProductRow(productId)
{
productRow.addClass("table-warning");
}
- else if (parseFloat(result.product.min_stock_amount) > 0 && parseFloat(result.stock_amount_aggregated) < parseFloat(result.product.min_stock_amount))
+ else if (result.product.min_stock_amount > 0 && result.stock_amount_aggregated < result.product.min_stock_amount)
{
productRow.addClass("table-info");
}
@@ -373,7 +373,7 @@ function RefreshProductRow(productId)
$('#product-' + productId + '-opened-amount').text("");
}
- if (parseInt(result.is_aggregated_amount) === 1)
+ if (result.is_aggregated_amount == 1)
{
$('#product-' + productId + '-amount-aggregated').text(result.stock_amount_aggregated);
diff --git a/public/viewjs/transfer.js b/public/viewjs/transfer.js
index 1eb58cde..a9a15aa3 100644
--- a/public/viewjs/transfer.js
+++ b/public/viewjs/transfer.js
@@ -61,7 +61,7 @@
if (productDetails.product.enable_tare_weight_handling == 1)
{
- var successMessage = __t('Transfered %1$s of %2$s from %3$s to %4$s', Math.abs(jsonForm.amount - parseFloat(productDetails.product.tare_weight)) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural, true), productDetails.product.name, $('option:selected', "#location_id_from").text(), $('option:selected', "#location_id_to").text()) + ' ' + __t("Undo") + '';
+ var successMessage = __t('Transfered %1$s of %2$s from %3$s to %4$s', Math.abs(jsonForm.amount - productDetails.product.tare_weight) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural, true), productDetails.product.name, $('option:selected', "#location_id_from").text(), $('option:selected', "#location_id_to").text()) + ' ' + __t("Undo") + '';
}
else
{
@@ -80,7 +80,7 @@
toastr.success(successMessage);
Grocy.Components.ProductPicker.FinishFlow();
- if (parseInt($("#location_id_from option:selected").attr("data-is-freezer")) === 0 && parseInt($("#location_id_to option:selected").attr("data-is-freezer")) === 1) // Frozen
+ if ($("#location_id_from option:selected").attr("data-is-freezer") == 0 && $("#location_id_to option:selected").attr("data-is-freezer") == 1) // Frozen
{
toastr.info('' + __t("Frozen") + " ");
@@ -89,7 +89,7 @@
toastr.warning(__t("This product shouldn't be frozen"));
}
}
- if (parseInt($("#location_id_from option:selected").attr("data-is-freezer")) === 1 && parseInt($("#location_id_to option:selected").attr("data-is-freezer")) === 0) // Thawed
+ if ($("#location_id_from option:selected").attr("data-is-freezer") == 1 && $("#location_id_to option:selected").attr("data-is-freezer") == 0) // Thawed
{
toastr.info('' + __t("Thawed") + " ");
}
@@ -106,7 +106,7 @@
$("#location_id_from").find("option").remove().end().append("");
$("#display_amount").attr("min", Grocy.DefaultMinAmount);
$("#display_amount").removeAttr("max");
- $('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_transfer_amount));
+ $('#display_amount').val(Grocy.UserSettings.stock_default_transfer_amount);
RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change");
$("#tare-weight-handling-info").addClass("d-none");
@@ -271,7 +271,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
}
});
-$('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_transfer_amount));
+$('#display_amount').val(Grocy.UserSettings.stock_default_transfer_amount);
$(".input-group-productamountpicker").trigger("change");
Grocy.FrontendHelpers.ValidateForm('transfer-form');
RefreshLocaleNumberInput();
@@ -316,7 +316,7 @@ $("#location_id_from").on('change', function(e)
if ($("#specific_stock_entry option[value='" + stockEntry.stock_id + "']").length == 0)
{
var noteTxt = "";
- if (stockEntry.note != null && !stockEntry.note.isEmpty())
+ if (stockEntry.note)
{
noteTxt = " " + stockEntry.note;
}
@@ -333,7 +333,7 @@ $("#location_id_from").on('change', function(e)
$("#specific_stock_entry").val(stockId);
}
- sumValue = sumValue + parseFloat(stockEntry.amount);
+ sumValue = sumValue + stockEntry.amount;
}
});
$("#display_amount").attr("max", sumValue * $("#qu_id option:selected").attr("data-qu-factor"));
@@ -363,7 +363,7 @@ $("#location_id_to").on('change', function(e)
$("#qu_id").on('change', function(e)
{
- $("#display_amount").attr("max", parseFloat($('#display_amount').attr("data-stock-amount")) * $("#qu_id option:selected").attr("data-qu-factor"));
+ $("#display_amount").attr("max", Number.parseFloat($('#display_amount').attr("data-stock-amount")) * $("#qu_id option:selected").attr("data-qu-factor"));
});
$('#display_amount').on('focus', function(e)
@@ -410,7 +410,7 @@ $("#specific_stock_entry").on("change", function(e)
{
if (stockEntry.location_id == $("#location_id_from").val() || stockEntry.location_id == "")
{
- sumValue = sumValue + parseFloat(stockEntry.amount);
+ sumValue = sumValue + stockEntry.amount;
}
});
$("#display_amount").attr("max", sumValue * $("#qu_id option:selected").attr("data-qu-factor"));
diff --git a/public/viewjs/userfieldform.js b/public/viewjs/userfieldform.js
index 257a7d6f..1823500a 100644
--- a/public/viewjs/userfieldform.js
+++ b/public/viewjs/userfieldform.js
@@ -16,7 +16,7 @@
Grocy.FrontendHelpers.BeginUiBusy("userfield-form");
var redirectUrl = U("/userfields");
- if (typeof GetUriParam("entity") !== "undefined" && !GetUriParam("entity").isEmpty())
+ if (GetUriParam("entity"))
{
redirectUrl = U("/userfields?entity=" + GetUriParam("entity"));
}
@@ -113,7 +113,7 @@ $("#type").on("change", function(e)
$('#entity').focus();
-if (typeof GetUriParam("entity") !== "undefined" && !GetUriParam("entity").isEmpty())
+if (GetUriParam("entity"))
{
$("#entity").val(GetUriParam("entity"));
$("#entity").trigger("change");
diff --git a/public/viewjs/userfields.js b/public/viewjs/userfields.js
index 39231a10..2f6c8d13 100644
--- a/public/viewjs/userfields.js
+++ b/public/viewjs/userfields.js
@@ -76,7 +76,7 @@ $(document).on('click', '.userfield-delete-button', function(e)
});
});
-if (GetUriParam("entity") != undefined && !GetUriParam("entity").isEmpty())
+if (GetUriParam("entity")
{
$("#entity-filter").val(GetUriParam("entity"));
$("#entity-filter").trigger("change");
diff --git a/services/DatabaseMigrationService.php b/services/DatabaseMigrationService.php
index abfe3b42..646211df 100644
--- a/services/DatabaseMigrationService.php
+++ b/services/DatabaseMigrationService.php
@@ -45,8 +45,7 @@ class DatabaseMigrationService extends BaseService
private function ExecutePhpMigrationWhenNeeded(int $migrationId, string $phpFile, int &$migrationCounter)
{
$rowCount = $this->getDatabaseService()->ExecuteDbQuery('SELECT COUNT(*) FROM migrations WHERE migration = ' . $migrationId)->fetchColumn();
-
- if (intval($rowCount) === 0 || $migrationId == self::EMERGENCY_MIGRATION_ID || $migrationId == self::DOALWAYS_MIGRATION_ID)
+ if ($rowCount == 0 || $migrationId == self::EMERGENCY_MIGRATION_ID || $migrationId == self::DOALWAYS_MIGRATION_ID)
{
include $phpFile;
@@ -61,8 +60,7 @@ class DatabaseMigrationService extends BaseService
private function ExecuteSqlMigrationWhenNeeded(int $migrationId, string $sql, int &$migrationCounter)
{
$rowCount = $this->getDatabaseService()->ExecuteDbQuery('SELECT COUNT(*) FROM migrations WHERE migration = ' . $migrationId)->fetchColumn();
-
- if (intval($rowCount) === 0 || $migrationId == self::EMERGENCY_MIGRATION_ID || $migrationId == self::DOALWAYS_MIGRATION_ID)
+ if ($rowCount == 0 || $migrationId == self::EMERGENCY_MIGRATION_ID || $migrationId == self::DOALWAYS_MIGRATION_ID)
{
$this->getDatabaseService()->GetDbConnectionRaw()->beginTransaction();
diff --git a/services/DatabaseService.php b/services/DatabaseService.php
index c093f361..2c65e205 100644
--- a/services/DatabaseService.php
+++ b/services/DatabaseService.php
@@ -69,6 +69,7 @@ class DatabaseService
{
$pdo = new \PDO('sqlite:' . $this->GetDbFilePath());
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
+ $pdo->setAttribute(\PDO::ATTR_ORACLE_NULLS, \PDO::NULL_EMPTY_STRING);
$pdo->sqliteCreateFunction('regexp', function ($pattern, $value) {
mb_regex_encoding('UTF-8');
diff --git a/services/DemoDataGeneratorService.php b/services/DemoDataGeneratorService.php
index faf07d7b..c057b7b6 100644
--- a/services/DemoDataGeneratorService.php
+++ b/services/DemoDataGeneratorService.php
@@ -16,8 +16,7 @@ class DemoDataGeneratorService extends BaseService
public function PopulateDemoData()
{
$rowCount = $this->getDatabaseService()->ExecuteDbQuery('SELECT COUNT(*) FROM migrations WHERE migration = -1')->fetchColumn();
-
- if (intval($rowCount) === 0)
+ if ($rowCount == 0)
{
$loremIpsum = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.';
$loremIpsumWithHtmlFormattings = "
Lorem ipsum
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
At vero eos et accusam et justo duo dolores et ea rebum.
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
Lorem ipsum
Lorem ipsum dolor sit amet, consetetur \r\nsadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et \r\ndolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et\r\n justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea \r\ntakimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit \r\namet, consetetur sadipscing elitr,\r\n sed diam nonumy eirmod tempor invidunt ut labore et dolore magna \r\naliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo \r\ndolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus \r\nest Lorem ipsum dolor sit amet.
";
@@ -301,7 +300,7 @@ class DemoDataGeneratorService extends BaseService
{
foreach ($this->getDatabase()->chores() as $chore)
{
- $hours = intval($chore->period_interval);
+ $hours = $chore->period_interval;
if ($chore->period_type == 'weekly')
{
$hours *= 7 * 24;
diff --git a/services/LocalizationService.php b/services/LocalizationService.php
index dd701a5e..8a10831a 100644
--- a/services/LocalizationService.php
+++ b/services/LocalizationService.php
@@ -44,7 +44,7 @@ class LocalizationService
{
if ($this->Po->getHeader(Translations::HEADER_PLURAL) !== null)
{
- return $this->Po->getPluralForms()[0];
+ return intval($this->Po->getPluralForms()[0]);
}
else
{
diff --git a/services/RecipesService.php b/services/RecipesService.php
index 79a73704..8a24d26a 100644
--- a/services/RecipesService.php
+++ b/services/RecipesService.php
@@ -44,7 +44,7 @@ class RecipesService extends BaseService
$conversion = $this->getDatabase()->quantity_unit_conversions_resolved()->where('product_id = :1 AND from_qu_id = :2 AND to_qu_id = :3', $recipePosition->product_id, $recipePosition->qu_id, $product->qu_id_stock)->fetch();
if ($conversion != null)
{
- $toOrderAmount = $toOrderAmount * floatval($conversion->factor);
+ $toOrderAmount = $toOrderAmount * $conversion->factor;
}
}
@@ -106,7 +106,7 @@ class RecipesService extends BaseService
{
$product = $this->getDatabase()->products()->where('id = :1', $recipeRow->product_id)->fetch();
$recipeResolvedRow = $this->getDatabase()->recipes_resolved()->where('recipe_id = :1', $recipeId)->fetch();
- $this->getStockService()->AddProduct($recipeRow->product_id, floatval($recipeRow->desired_servings), null, StockService::TRANSACTION_TYPE_SELF_PRODUCTION, date('Y-m-d'), floatval($recipeResolvedRow->costs_per_serving), null, null, $dummyTransactionId, $product->default_stock_label_type, true);
+ $this->getStockService()->AddProduct($recipeRow->product_id, $recipeRow->desired_servings, null, StockService::TRANSACTION_TYPE_SELF_PRODUCTION, date('Y-m-d'), $recipeResolvedRow->costs_per_serving, null, null, $dummyTransactionId, $product->default_stock_label_type, true);
}
}
diff --git a/services/SessionService.php b/services/SessionService.php
index 2c7c4b6b..ccd3bb85 100644
--- a/services/SessionService.php
+++ b/services/SessionService.php
@@ -12,7 +12,7 @@ class SessionService extends BaseService
public function CreateSession($userId, $stayLoggedInPermanently = false)
{
$newSessionKey = $this->GenerateSessionKey();
- $expires = date('Y-m-d H:i:s', intval(time() + 2592000));
+ $expires = date('Y-m-d H:i:s', time() + 2592000);
// Default is that sessions expire in 30 days
if ($stayLoggedInPermanently === true)
diff --git a/services/StockService.php b/services/StockService.php
index c67bc115..70eca912 100644
--- a/services/StockService.php
+++ b/services/StockService.php
@@ -130,15 +130,15 @@ class StockService extends BaseService
{
if ($addExactAmount)
{
- $amount = floatval($productDetails->stock_amount) + floatval($productDetails->product->tare_weight) + $amount;
+ $amount = $productDetails->stock_amount + $productDetails->product->tare_weight + $amount;
}
- if ($amount <= floatval($productDetails->product->tare_weight) + floatval($productDetails->stock_amount))
+ if ($amount <= $productDetails->product->tare_weight + $productDetails->stock_amount)
{
throw new \Exception('The amount cannot be lower or equal than the defined tare weight + current stock amount');
}
- $amount = $amount - floatval($productDetails->stock_amount) - floatval($productDetails->product->tare_weight);
+ $amount = $amount - $productDetails->stock_amount - $productDetails->product->tare_weight;
}
//Set the default due date, if none is supplied
@@ -153,9 +153,9 @@ class StockService extends BaseService
$location = $this->getDatabase()->locations()->where('id', $locationId)->fetch();
}
- if (GROCY_FEATURE_FLAG_STOCK_PRODUCT_FREEZING && $locationId !== null && intval($location->is_freezer) === 1 && intval($productDetails->product->default_best_before_days_after_freezing) >= -1)
+ if (GROCY_FEATURE_FLAG_STOCK_PRODUCT_FREEZING && $locationId !== null && $location->is_freezer == 1 && $productDetails->product->default_best_before_days_after_freezing >= -1)
{
- if (intval($productDetails->product->default_best_before_days_after_freezing) == -1)
+ if ($productDetails->product->default_best_before_days_after_freezing == -1)
{
$bestBeforeDate = date('2999-12-31');
}
@@ -164,11 +164,11 @@ class StockService extends BaseService
$bestBeforeDate = date('Y-m-d', strtotime('+' . $productDetails->product->default_best_before_days_after_freezing . ' days'));
}
}
- elseif (intval($productDetails->product->default_best_before_days) == -1)
+ elseif ($productDetails->product->default_best_before_days == -1)
{
$bestBeforeDate = date('2999-12-31');
}
- elseif (intval($productDetails->product->default_best_before_days) > 0)
+ elseif ($productDetails->product->default_best_before_days > 0)
{
$bestBeforeDate = date('Y-m-d', strtotime(date('Y-m-d') . ' + ' . $productDetails->product->default_best_before_days . ' days'));
}
@@ -378,14 +378,14 @@ class StockService extends BaseService
{
if ($consumeExactAmount)
{
- $amount = floatval($productDetails->stock_amount) + floatval($productDetails->product->tare_weight) - $amount;
+ $amount = $productDetails->stock_amount + $productDetails->product->tare_weight - $amount;
}
- if ($amount < floatval($productDetails->product->tare_weight))
+ if ($amount < $productDetails->product->tare_weight)
{
throw new \Exception('The amount cannot be lower than the defined tare weight');
}
- $amount = abs($amount - floatval($productDetails->stock_amount) - floatval($productDetails->product->tare_weight));
+ $amount = abs($amount - $productDetails->stock_amount - $productDetails->product->tare_weight);
}
if ($transactionType === self::TRANSACTION_TYPE_CONSUME || $transactionType === self::TRANSACTION_TYPE_INVENTORY_CORRECTION)
@@ -406,7 +406,7 @@ class StockService extends BaseService
$potentialStockEntries = FindAllObjectsInArrayByPropertyValue($potentialStockEntries, 'stock_id', $specificStockEntryId);
}
- $productStockAmount = floatval($productDetails->stock_amount_aggregated);
+ $productStockAmount = $productDetails->stock_amount_aggregated;
if (round($amount, 2) > round($productStockAmount, 2))
{
throw new \Exception('Amount to be consumed cannot be > current stock amount (if supplied, at the desired location)');
@@ -431,7 +431,7 @@ class StockService extends BaseService
$conversion = $this->getDatabase()->quantity_unit_conversions_resolved()->where('product_id = :1 AND from_qu_id = :2 AND to_qu_id = :3', $stockEntry->product_id, $productDetails->product->qu_id_stock, $subProduct->qu_id_stock)->fetch();
if ($conversion != null)
{
- $amount = $amount * floatval($conversion->factor);
+ $amount = $amount * $conversion->factor;
}
}
@@ -465,7 +465,7 @@ class StockService extends BaseService
{
// A sub product with QU conversions was used
// => Convert the rest amount back to be based on the original (parent) product for the next round
- $amount = $amount / floatval($conversion->factor);
+ $amount = $amount / $conversion->factor;
}
}
else
@@ -502,7 +502,7 @@ class StockService extends BaseService
if (boolval($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'shopping_list_auto_add_below_min_stock_amount')))
{
- $this->AddMissingProductsToShoppingList(intval($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'shopping_list_auto_add_below_min_stock_amount_list_id')));
+ $this->AddMissingProductsToShoppingList($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'shopping_list_auto_add_below_min_stock_amount_list_id'));
}
return $transactionId;
@@ -749,7 +749,7 @@ class StockService extends BaseService
$quStock = $this->getDatabase()->quantity_units($product->qu_id_stock);
$quConsume = $this->getDatabase()->quantity_units($product->qu_id_consume);
$location = $this->getDatabase()->locations($product->location_id);
- $averageShelfLifeDays = intval($this->getDatabase()->stock_average_product_shelf_life()->where('id', $productId)->fetch()->average_shelf_life_days);
+ $averageShelfLifeDays = $this->getDatabase()->stock_average_product_shelf_life()->where('id', $productId)->fetch()->average_shelf_life_days;
$currentPrice = $this->getDatabase()->products_current_price()->where('product_id', $productId)->fetch()->price;
$consumeCount = $this->getDatabase()->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_CONSUME)->where('undone = 0')->sum('amount') * -1;
@@ -816,7 +816,7 @@ class StockService extends BaseService
{
throw new \Exception('Invalid grocycode');
}
- return intval($gc->GetId());
+ return $gc->GetId();
}
$potentialProduct = $this->getDatabase()->product_barcodes()->where('barcode = :1 COLLATE NOCASE', $barcode)->fetch();
@@ -825,7 +825,7 @@ class StockService extends BaseService
throw new \Exception("No product with barcode $barcode found");
}
- return intval($potentialProduct->product_id);
+ return $potentialProduct->product_id;
}
public function GetProductPriceHistory(int $productId)
@@ -931,16 +931,16 @@ class StockService extends BaseService
if ($productDetails->product->enable_tare_weight_handling == 1)
{
- $containerWeight = floatval($productDetails->product->tare_weight);
+ $containerWeight = $productDetails->product->tare_weight;
}
- if ($newAmount == floatval($productDetails->stock_amount) + $containerWeight)
+ if ($newAmount == $productDetails->stock_amount + $containerWeight)
{
throw new \Exception('The new amount cannot equal the current stock amount');
}
- elseif ($newAmount > floatval($productDetails->stock_amount) + $containerWeight)
+ elseif ($newAmount > $productDetails->stock_amount + $containerWeight)
{
- $bookingAmount = $newAmount - floatval($productDetails->stock_amount);
+ $bookingAmount = $newAmount - $productDetails->stock_amount;
if ($productDetails->product->enable_tare_weight_handling == 1)
{
@@ -972,7 +972,7 @@ class StockService extends BaseService
}
$productDetails = (object) $this->GetProductDetails($productId);
- $productStockAmountUnopened = floatval($productDetails->stock_amount_aggregated) - floatval($productDetails->stock_amount_opened_aggregated);
+ $productStockAmountUnopened = $productDetails->stock_amount_aggregated - $productDetails->stock_amount_opened_aggregated;
$potentialStockEntries = $this->GetProductStockEntries($productId, true, $allowSubproductSubstitution);
$product = $this->getDatabase()->products($productId);
@@ -1038,7 +1038,7 @@ class StockService extends BaseService
$conversion = $this->getDatabase()->quantity_unit_conversions_resolved()->where('product_id = :1 AND from_qu_id = :2 AND to_qu_id = :3', $stockEntry->product_id, $product->qu_id_stock, $subProduct->qu_id_stock)->fetch();
if ($conversion != null)
{
- $amount = $amount * floatval($conversion->factor);
+ $amount = $amount * $conversion->factor;
}
}
@@ -1127,7 +1127,7 @@ class StockService extends BaseService
if (boolval($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'shopping_list_auto_add_below_min_stock_amount')))
{
- $this->AddMissingProductsToShoppingList(intval($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'shopping_list_auto_add_below_min_stock_amount_list_id')));
+ $this->AddMissingProductsToShoppingList($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'shopping_list_auto_add_below_min_stock_amount_list_id'));
}
return $transactionId;
@@ -1142,10 +1142,10 @@ class StockService extends BaseService
$productRow = $this->getDatabase()->shopping_list()->where('product_id = :1', $productId)->fetch();
- //If no entry was found with for this product, we return gracefully
+ // If no entry was found with for this product, we return gracefully
if ($productRow != null && !empty($productRow))
{
- $decimals = intval($this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'stock_decimal_places_amounts'));
+ $decimals = $this->getUsersService()->GetUserSetting(GROCY_USER_ID, 'stock_decimal_places_amounts');
$newAmount = $productRow->amount - $amount;
if ($newAmount < floatval('0.' . str_repeat('0', $decimals - ($decimals <= 0 ? 0 : 1)) . '1'))
@@ -1186,7 +1186,7 @@ class StockService extends BaseService
$factor = 1.0;
if ($conversion != null)
{
- $factor = floatval($conversion->factor);
+ $factor = $conversion->factor;
}
$amount = round($row->amount * $factor);
@@ -1274,12 +1274,12 @@ class StockService extends BaseService
{
// Hard fail for now, as we not yet support transferring tare weight enabled products
throw new \Exception('Transferring tare weight enabled products is not yet possible');
- if ($amount < floatval($productDetails->product->tare_weight))
+ if ($amount < $productDetails->product->tare_weight)
{
throw new \Exception('The amount cannot be lower than the defined tare weight');
}
- $amount = abs($amount - floatval($productDetails->stock_amount) - floatval($productDetails->product->tare_weight));
+ $amount = abs($amount - $productDetails->stock_amount - $productDetails->product->tare_weight);
}
$productStockAmountAtFromLocation = $this->getDatabase()->stock()->where('product_id = :1 AND location_id = :2', $productId, $locationIdFrom)->sum('amount');
@@ -1314,7 +1314,7 @@ class StockService extends BaseService
$locationTo = $this->getDatabase()->locations()->where('id', $locationIdTo)->fetch();
// Product was moved from a non-freezer to freezer location -> freeze
- if (intval($locationFrom->is_freezer) === 0 && intval($locationTo->is_freezer) === 1 && $productDetails->product->default_best_before_days_after_freezing >= -1)
+ if ($locationFrom->is_freezer == 0 && $locationTo->is_freezer == 1 && $productDetails->product->default_best_before_days_after_freezing >= -1)
{
if ($productDetails->product->default_best_before_days_after_freezing == -1)
{
@@ -1327,7 +1327,7 @@ class StockService extends BaseService
}
// Product was moved from a freezer to non-freezer location -> thaw
- if (intval($locationFrom->is_freezer) === 1 && intval($locationTo->is_freezer) === 0 && $productDetails->product->default_best_before_days_after_thawing > 0)
+ if ($locationFrom->is_freezer == 1 && $locationTo->is_freezer == 0 && $productDetails->product->default_best_before_days_after_thawing > 0)
{
$newBestBeforeDate = date('Y-m-d', strtotime('+' . $productDetails->product->default_best_before_days_after_thawing . ' days'));
}
@@ -1689,7 +1689,7 @@ class StockService extends BaseService
$factor = 1.0;
if ($conversion != null)
{
- $factor = floatval($conversion->factor);
+ $factor = $conversion->factor;
}
$this->getDatabaseService()->ExecuteDbStatement('UPDATE stock SET product_id = ' . $productIdToKeep . ', amount = amount * ' . $factor . ' WHERE product_id = ' . $productIdToRemove);
diff --git a/views/productform.blade.php b/views/productform.blade.php
index 5cfa5896..de2afe03 100644
--- a/views/productform.blade.php
+++ b/views/productform.blade.php
@@ -524,13 +524,13 @@
name="default_stock_label_type">
+ $product->default_stock_label_type == 0 ) selected="selected" @endif value="0">{{ $__t('No label') }}
+ $product->default_stock_label_type == 1 ) selected="selected" @endif value="1">{{ $__t('Single label') }}
+ $product->default_stock_label_type == 2 ) selected="selected" @endif value="2">{{ $__t('Label per unit') }}
diff --git a/views/quantityunitform.blade.php b/views/quantityunitform.blade.php
index 032d95d6..b689cb7f 100644
--- a/views/quantityunitform.blade.php
+++ b/views/quantityunitform.blade.php
@@ -89,7 +89,7 @@
- @if(intval($pluralCount) > 2)
+ @if($pluralCount > 2)
@endif
diff --git a/views/recipes.blade.php b/views/recipes.blade.php
index 35b117b2..40199714 100644
--- a/views/recipes.blade.php
+++ b/views/recipes.blade.php
@@ -386,7 +386,7 @@
@endphp