mirror of
https://github.com/grocy/grocy.git
synced 2026-04-05 12:26:15 +02:00
Formatting / feature flag checks / proper data type comparision
This commit is contained in:
parent
9578f1696b
commit
2f071e945a
|
|
@ -288,19 +288,20 @@ if (Grocy.Components.ProductPicker !== undefined)
|
|||
|
||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
|
||||
{
|
||||
var best_before;
|
||||
if (productDetails.location.is_freezer.toString() == "1")
|
||||
var dueDays;
|
||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRODUCT_FREEZING && BoolVal(productDetails.location.is_freezer))
|
||||
{
|
||||
best_before = productDetails.product.default_best_before_days_after_freezing;
|
||||
dueDays = productDetails.product.default_best_before_days_after_freezing;
|
||||
}
|
||||
else
|
||||
{
|
||||
best_before = productDetails.product.default_best_before_days;
|
||||
dueDays = productDetails.product.default_best_before_days;
|
||||
}
|
||||
|
||||
if (best_before.toString() !== '0')
|
||||
dueDays = parseFloat(dueDays);
|
||||
if (dueDays != 0)
|
||||
{
|
||||
if (best_before == -1)
|
||||
if (dueDays == -1)
|
||||
{
|
||||
if (!$("#datetimepicker-shortcut").is(":checked"))
|
||||
{
|
||||
|
|
@ -309,7 +310,7 @@ if (Grocy.Components.ProductPicker !== undefined)
|
|||
}
|
||||
else
|
||||
{
|
||||
Grocy.Components.DateTimePicker.SetValue(moment().add(best_before, 'days').format('YYYY-MM-DD'));
|
||||
Grocy.Components.DateTimePicker.SetValue(moment().add(dueDays, 'days').format('YYYY-MM-DD'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,13 +147,15 @@ class StockService extends BaseService
|
|||
if ($locationId !== null && !$this->LocationExists($locationId))
|
||||
{
|
||||
throw new \Exception('Location does not exist');
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$location = $this->getDatabase()->locations()->where('id', $locationId)->fetch();
|
||||
}
|
||||
|
||||
if (GROCY_FEATURE_FLAG_STOCK_PRODUCT_FREEZING && $locationId !== null && intval($location->is_freezer) === 1 && $productDetails->product->default_best_before_days_after_freezing >= -1)
|
||||
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 ($productDetails->product->default_best_before_days_after_freezing == -1)
|
||||
if (intval($productDetails->product->default_best_before_days_after_freezing) == -1)
|
||||
{
|
||||
$bestBeforeDate = date('2999-12-31');
|
||||
}
|
||||
|
|
@ -161,7 +163,8 @@ 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 (intval($productDetails->product->default_best_before_days) == -1)
|
||||
{
|
||||
$bestBeforeDate = date('2999-12-31');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user