diff --git a/src/PartKeepr/PartBundle/Entity/Part.php b/src/PartKeepr/PartBundle/Entity/Part.php index b75832b9c..5db7fd70e 100644 --- a/src/PartKeepr/PartBundle/Entity/Part.php +++ b/src/PartKeepr/PartBundle/Entity/Part.php @@ -804,7 +804,12 @@ public function recomputeStockLevels() $sum += $stockLevel->getStockLevel(); } - $this->setAveragePrice($price / $sum); + if ($sum > 0) { + $this->setAveragePrice($price / $sum); + } else { + $this->setAveragePrice(0); + } + $this->setStockLevel($sum); if ($sum < $this->getMinStockLevel()) {