Never extend the original due date on when opening a product which has default_best_before_days (closes #1342)

This commit is contained in:
Bernd Bestel
2021-07-12 17:56:09 +02:00
parent 866d6647d2
commit 247221950d
4 changed files with 9 additions and 2 deletions

View File

@@ -891,6 +891,12 @@ class StockService extends BaseService
if ($product->default_best_before_days_after_open > 0)
{
$newBestBeforeDate = date('Y-m-d', strtotime('+' . $product->default_best_before_days_after_open . ' days'));
// The new due date should be never > the original due date
if (strtotime($newBestBeforeDate) > strtotime($stockEntry->best_before_date))
{
$newBestBeforeDate = $stockEntry->best_before_date;
}
}
if ($allowSubproductSubstitution && $stockEntry->product_id != $productId)