mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 17:45:39 +00:00
Fixed that product-opened-actions had no transaction_id in stock_log (fixes #732)
This commit is contained in:
parent
7d9bad58b5
commit
1686fcca8e
@ -17,6 +17,7 @@
|
||||
- Fixed that "Default best before days" and "Default best before days after opened" on the product edit page were always shown regardless of the feature flags `FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING` and `FEATURE_FLAG_STOCK_PRODUCT_OPENED_TRACKING`
|
||||
- Fixed that the form validation limits for the amount input and products with enabled tare weight handling were wrong
|
||||
- Fixed that the price was saved wrong for products with a different purchase/stock quantity unit when using "Total price" on purchase (resulted for example in wrong recipe costs)
|
||||
- Fixed that undoing "product-opened"-actions was not possible
|
||||
|
||||
### Shopping list fixes
|
||||
- Fixed that the "shopping list to stock workflow"-dialog was not visible in compact view
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user