Optionally show out of stock products on the location content sheet (closes #1641)

This commit is contained in:
Bernd Bestel 2022-04-01 21:55:06 +02:00
parent ebfc55064e
commit f7c33a4579
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
6 changed files with 42 additions and 3 deletions

View File

@ -30,6 +30,7 @@
- When the product was once added to stock, there needs to exist a corresponding unit conversion for the new QU
- New product option "Disable own stock" (defaults to disabled)
- When enabled, the corresponding product can't have own stock, means it will not be selectable on purchase (useful for parent products which are just used as a summary/total view of the child products)
- The location content sheet can now optionally list also out of stock products (at the products default location, new checkbox "Show only in-stock products " at the top of the page, defaults to enabled)
- Added the product grocycode as a (hidden by default) column to the products list (master data)
- Fixed that consuming via the consume page was not possible when `FEATURE_FLAG_STOCK_LOCATION_TRACKING` was disabled

View File

@ -72,7 +72,7 @@ class StockController extends BaseController
'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'),
'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'),
'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),
'currentStockLocationContent' => $this->getStockService()->GetCurrentStockLocationContent()
'currentStockLocationContent' => $this->getStockService()->GetCurrentStockLocationContent(isset($request->getQueryParams()['include_out_of_stock']))
]);
}

View File

@ -2326,3 +2326,6 @@ msgstr ""
msgid "When enabled, this product can't have own stock, means it will not be selectable on purchase (useful for parent products which are just used as a summary/total view of the child products)"
msgstr ""
msgid "Out of stock items will be shown at the products default location"
msgstr ""

View File

@ -12,3 +12,18 @@ $(document).on("click", ".print-single-location-button", function(e)
$(".print-timestamp").text(moment().format("l LT"));
window.print();
});
$("#include-out-of-stock").change(function()
{
if (this.checked)
{
RemoveUriParam("include_out_of_stock");
}
else
{
UpdateUriParam("include_out_of_stock", true);
}
window.location.reload();
});

View File

@ -628,9 +628,15 @@ class StockService extends BaseService
return array_column($currentStockMapped, 0);
}
public function GetCurrentStockLocationContent()
public function GetCurrentStockLocationContent($includeOutOfStockProductsAtTheDefaultLocation = false)
{
$sql = 'SELECT sclc.* FROM stock_current_location_content sclc JOIN products p ON sclc.product_id = p.id ORDER BY p.name';
$leftJoin = '';
if ($includeOutOfStockProductsAtTheDefaultLocation)
{
$leftJoin = 'LEFT';
}
$sql = 'SELECT IFNULL(sclc.location_id, p.location_id) AS location_id, p.id AS product_id, IFNULL(sclc.amount, 0) AS amount, IFNULL(sclc.amount_opened, 0) AS amount_opened FROM products p ' . $leftJoin . ' JOIN stock_current_location_content sclc ON sclc.product_id = p.id WHERE p.active = 1 ORDER BY p.name';
return $this->getDatabaseService()->ExecuteDbQuery($sql)->fetchAll(\PDO::FETCH_OBJ);
}

View File

@ -36,6 +36,20 @@
data-trigger="hover click"
title="{{ $__t('Here you can print a page per location with the current stock, maybe to hang it there and note the consumed things on it') }}"></i>
</h2>
<div class="form-check custom-control custom-checkbox">
<input class="form-check-input custom-control-input"
type="checkbox"
id="include-out-of-stock"
checked>
<label class="form-check-label custom-control-label"
for="include-out-of-stock">
{{ $__t('Show only in-stock products') }}
<i class="fas fa-question-circle text-muted"
data-toggle="tooltip"
data-trigger="hover click"
title="{{ $__t('Out of stock items will be shown at the products default location') }}"></i>
</label>
</div>
<div class="float-right">
<button class="btn btn-outline-dark d-md-none mt-2 order-1 order-md-3"
type="button"