Fixed that "Spoil rate" and "Average shelf life" on the product card was wrong in most cases

This commit is contained in:
Bernd Bestel
2019-09-21 13:30:44 +02:00
parent b57fd83cb8
commit e4437f5db1
4 changed files with 20 additions and 2 deletions

View File

@@ -115,7 +115,7 @@ class StockService extends BaseService
$lastPrice = $lastLogRow->price;
}
$consumeCount = $this->Database->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_CONSUME)->where('undone', 0)->sum('amount') * -1;
$consumeCount = $this->Database->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_CONSUME)->where('undone = 0 AND spoiled = 0')->sum('amount') * -1;
$consumeCountSpoiled = $this->Database->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_CONSUME)->where('undone = 0 AND spoiled = 1')->sum('amount') * -1;
if ($consumeCount == 0)
{