Support -1 for "Default due days after freezing" (closes #846)

This commit is contained in:
Bernd Bestel 2020-12-19 17:32:47 +01:00
parent 362b3f8508
commit 250b308d5d
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
3 changed files with 12 additions and 4 deletions

View File

@ -69,6 +69,7 @@
- Added more filters on the stock journal page
- Added a grouped/summarized stock journal (new button "Journal summary" at the top of the stock journal page) (thanks @fipwmaqzufheoxq92ebc)
- Provides an overview of summarized transactions per product, transaction type and user + summarized amount
- The product option "Default due days after freezing" now also supports `-1` (like the option "Default due days") to set the product to "never due" on freezing
- Fixed that changing the products "Factor purchase to stock quantity unit" not longer messes up historical prices (which results for example in wrong recipe costs) (thanks @kriddles)
- Fixed that when adding products through a product picker workflow and when the created products contains special characters, the product was not preselected on the previous page (thanks @Forceu)
- Fixed that when editing a product the default store was not visible / always empty regardless if the product had one set (thanks @kriddles)

View File

@ -1005,9 +1005,16 @@ 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 > 0)
if (intval($locationFrom->is_freezer) === 0 && intval($locationTo->is_freezer) === 1 && $productDetails->product->default_best_before_days_after_freezing >= -1)
{
$newBestBeforeDate = date('Y-m-d', strtotime('+' . $productDetails->product->default_best_before_days_after_freezing . ' days'));
if ($productDetails->product->default_best_before_days_after_freezing == -1)
{
$newBestBeforeDate = date('2999-12-31');
}
else
{
$newBestBeforeDate = date('Y-m-d', strtotime('+' . $productDetails->product->default_best_before_days_after_freezing . ' days'));
}
}
// Product was moved from a freezer to non-freezer location -> thaw

View File

@ -376,14 +376,14 @@
'label' => 'Default due days after freezing',
'min' => -1,
'value' => $value,
'hint' => $__t('On moving this product to a freezer location (so when freezing it), the due date will be replaced by today + this amount of days')
'hint' => $__t('On moving this product to a freezer location (so when freezing it), the due date will be replaced by today + this amount of days') . ' (' . $__t('-1 means that this product will be never overdue') . ')'
))
@php if($mode == 'edit') { $value = $product->default_best_before_days_after_thawing; } else { $value = 0; } @endphp
@include('components.numberpicker', array(
'id' => 'default_best_before_days_after_thawing',
'label' => 'Default due days after thawing',
'min' => -1,
'min' => 0,
'value' => $value,
'hint' => $__t('On moving this product from a freezer location (so when thawing it), the due date will be replaced by today + this amount of days')
))