mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
StockService: Set the product's bestBeforeDate to the freezer date if it is being purchased to a freezer (#1672)
* StockService: Set the product's bestBeforeDate to the freezer date if it is being purchased to a freezer * Formatting / feature flag checks / proper data type comparision * Prefill due date also on location change Co-authored-by: Bernd Bestel <bernd@berrnd.de>
This commit is contained in:
committed by
GitHub
parent
10bd5ce900
commit
a7f3f64d89
@@ -144,7 +144,27 @@ class StockService extends BaseService
|
||||
//Set the default due date, if none is supplied
|
||||
if ($bestBeforeDate == null)
|
||||
{
|
||||
if (intval($productDetails->product->default_best_before_days) == -1)
|
||||
if ($locationId !== null && !$this->LocationExists($locationId))
|
||||
{
|
||||
throw new \Exception('Location does not exist');
|
||||
}
|
||||
else
|
||||
{
|
||||
$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 (intval($productDetails->product->default_best_before_days_after_freezing) == -1)
|
||||
{
|
||||
$bestBeforeDate = date('2999-12-31');
|
||||
}
|
||||
else
|
||||
{
|
||||
$bestBeforeDate = date('Y-m-d', strtotime('+' . $productDetails->product->default_best_before_days_after_freezing . ' days'));
|
||||
}
|
||||
}
|
||||
elseif (intval($productDetails->product->default_best_before_days) == -1)
|
||||
{
|
||||
$bestBeforeDate = date('2999-12-31');
|
||||
}
|
||||
|
Reference in New Issue
Block a user