mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
Fixed productcard spoil rate (fixes #1319)
This commit is contained in:
parent
7587ead732
commit
76cfe7fece
@ -32,6 +32,7 @@
|
||||
- Fixed that undoing a consume/open action from the success notification on the stock entries page was not possible
|
||||
- Fixed that adding a barcode to a product didn't save the selected quantity unit when the product only has a single one
|
||||
- Fixed that the store information on a stock entry was lost when transferring a partial amount to a different location
|
||||
- Fixed that the "Spoil rate" on the product card was wrong in some cases
|
||||
|
||||
### Shopping list improvements/fixes
|
||||
- The amount now defaults to `1` for adding items quicker
|
||||
|
@ -632,14 +632,14 @@ class StockService extends BaseService
|
||||
$averageShelfLifeDays = intval($this->getDatabase()->stock_average_product_shelf_life()->where('id', $productId)->fetch()->average_shelf_life_days);
|
||||
$defaultShoppingLocation = null;
|
||||
|
||||
$consumeCount = $this->getDatabase()->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_CONSUME)->where('undone = 0 AND spoiled = 0')->sum('amount') * -1;
|
||||
$consumeCount = $this->getDatabase()->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_CONSUME)->where('undone = 0')->sum('amount') * -1;
|
||||
$consumeCountSpoiled = $this->getDatabase()->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)
|
||||
if ($consumeCount == 0 || $consumeCount == null)
|
||||
{
|
||||
$consumeCount = 1;
|
||||
}
|
||||
|
||||
$spoilRate = ($consumeCountSpoiled * 100) / $consumeCount;
|
||||
$spoilRate = ($consumeCountSpoiled * 100.0) / $consumeCount;
|
||||
|
||||
return [
|
||||
'product' => $product,
|
||||
|
Loading…
x
Reference in New Issue
Block a user