Fixed default consume rule ORDER BY handling related to stock_next_use (fixes #1979)

This commit is contained in:
Bernd Bestel
2022-08-26 11:15:15 +02:00
parent d883474f03
commit c0d0b8fc90
5 changed files with 128 additions and 12 deletions

View File

@@ -821,7 +821,7 @@ class StockService extends BaseService
return $returnData;
}
public function GetProductStockEntries($productId, $excludeOpened = false, $allowSubproductSubstitution = false, $ordered = true)
public function GetProductStockEntries($productId, $excludeOpened = false, $allowSubproductSubstitution = false)
{
$sqlWhereProductId = 'product_id = ' . $productId;
if ($allowSubproductSubstitution)
@@ -835,14 +835,7 @@ class StockService extends BaseService
$sqlWhereAndOpen = 'AND open = 0';
}
$result = $this->getDatabase()->stock_next_use()->where($sqlWhereProductId . ' ' . $sqlWhereAndOpen);
if ($ordered)
{
return $result->orderBy('product_id', 'ASC')->orderBy('priority', 'DESC');
}
return $result;
return $this->getDatabase()->stock_next_use()->where($sqlWhereProductId . ' ' . $sqlWhereAndOpen);
}
public function GetLocationStockEntries($locationId)
@@ -857,7 +850,7 @@ class StockService extends BaseService
public function GetProductStockEntriesForLocation($productId, $locationId, $excludeOpened = false, $allowSubproductSubstitution = false)
{
$stockEntries = $this->GetProductStockEntries($productId, $excludeOpened, $allowSubproductSubstitution, true);
$stockEntries = $this->GetProductStockEntries($productId, $excludeOpened, $allowSubproductSubstitution);
return FindAllObjectsInArrayByPropertyValue($stockEntries, 'location_id', $locationId);
}