mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Fixed that product-opened-actions had no transaction_id in stock_log (fixes #732)
This commit is contained in:
@@ -724,7 +724,7 @@ class StockService extends BaseService
|
||||
return null;
|
||||
}
|
||||
|
||||
public function OpenProduct(int $productId, float $amount, $specificStockEntryId = 'default')
|
||||
public function OpenProduct(int $productId, float $amount, $specificStockEntryId = 'default', &$transactionId = null)
|
||||
{
|
||||
if (!$this->ProductExists($productId))
|
||||
{
|
||||
@@ -745,6 +745,11 @@ class StockService extends BaseService
|
||||
$potentialStockEntries = FindAllObjectsInArrayByPropertyValue($potentialStockEntries, 'stock_id', $specificStockEntryId);
|
||||
}
|
||||
|
||||
if ($transactionId === null)
|
||||
{
|
||||
$transactionId = uniqid();
|
||||
}
|
||||
|
||||
foreach ($potentialStockEntries as $stockEntry)
|
||||
{
|
||||
if ($amount == 0)
|
||||
@@ -768,7 +773,8 @@ class StockService extends BaseService
|
||||
'stock_id' => $stockEntry->stock_id,
|
||||
'transaction_type' => self::TRANSACTION_TYPE_PRODUCT_OPENED,
|
||||
'price' => $stockEntry->price,
|
||||
'opened_date' => date('Y-m-d')
|
||||
'opened_date' => date('Y-m-d'),
|
||||
'transaction_id' => $transactionId
|
||||
));
|
||||
$logRow->save();
|
||||
|
||||
@@ -802,7 +808,8 @@ class StockService extends BaseService
|
||||
'stock_id' => $stockEntry->stock_id,
|
||||
'transaction_type' => self::TRANSACTION_TYPE_PRODUCT_OPENED,
|
||||
'price' => $stockEntry->price,
|
||||
'opened_date' => date('Y-m-d')
|
||||
'opened_date' => date('Y-m-d'),
|
||||
'transaction_id' => $transactionId
|
||||
));
|
||||
$logRow->save();
|
||||
|
||||
|
Reference in New Issue
Block a user