diff --git a/changelog/60_3.0.0_2020-12-22.md b/changelog/60_3.0.0_2020-12-22.md index 2b20c935..a262ac57 100644 --- a/changelog/60_3.0.0_2020-12-22.md +++ b/changelog/60_3.0.0_2020-12-22.md @@ -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) diff --git a/services/StockService.php b/services/StockService.php index 371ac5fe..6dbda4c4 100644 --- a/services/StockService.php +++ b/services/StockService.php @@ -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 diff --git a/views/productform.blade.php b/views/productform.blade.php index f75b6899..9bb61ed3 100644 --- a/views/productform.blade.php +++ b/views/productform.blade.php @@ -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') ))