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

@@ -33,6 +33,7 @@
- The product picker on the consume and transfer page now only shows products which are currently in stock - The product picker on the consume and transfer page now only shows products which are currently in stock
- Added a filter option to only show in-stock products on the products list page (master data) - Added a filter option to only show in-stock products on the products list page (master data)
- Added new columns on the stock overview page (hidden by default): Product description, product default location, parent product - Added new columns on the stock overview page (hidden by default): Product description, product default location, parent product
- Optimized that when opening a product which has "Default due days after opened" set, the resulting date now never extends the original due date
- Fixed that editing stock entries was not possible - Fixed that editing stock entries was not possible
- Fixed that consuming with Scan Mode was not possible - Fixed that consuming with Scan Mode was not possible
- Fixed that the current stock total value (header of the stock overview page) didn't include decimal amounts (thanks @Ape) - Fixed that the current stock total value (header of the stock overview page) didn't include decimal amounts (thanks @Ape)

View File

@@ -1903,7 +1903,7 @@ msgstr ""
msgid "Default due days" msgid "Default due days"
msgstr "" msgstr ""
msgid "When this product was marked as opened, the due date will be replaced by today + this amount of days (a value of 0 disables this)" msgid "When this product was marked as opened, the due date will be replaced by today + this amount of days, but only if the resulting date is not after the original due date (a value of 0 disables this)"
msgstr "" msgstr ""
msgid "Default due days after opened" msgid "Default due days after opened"

View File

@@ -891,6 +891,12 @@ class StockService extends BaseService
if ($product->default_best_before_days_after_open > 0) if ($product->default_best_before_days_after_open > 0)
{ {
$newBestBeforeDate = date('Y-m-d', strtotime('+' . $product->default_best_before_days_after_open . ' days')); $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) if ($allowSubproductSubstitution && $stockEntry->product_id != $productId)

View File

@@ -212,7 +212,7 @@
'label' => 'Default due days after opened', 'label' => 'Default due days after opened',
'min' => 0, 'min' => 0,
'value' => $value, 'value' => $value,
'hint' => $__t('When this product was marked as opened, the due date will be replaced by today + this amount of days (a value of 0 disables this)') 'hint' => $__t('When this product was marked as opened, the due date will be replaced by today + this amount of days, but only if the resulting date is not after the original due date (a value of 0 disables this)')
)) ))
@else @else
<input type="hidden" <input type="hidden"