Skip to content

Commit

Permalink
Set averagePrice to 0 if there are no stock entries, relates to #500
Browse files Browse the repository at this point in the history
  • Loading branch information
Timo A. Hummel committed Nov 28, 2015
1 parent fe66410 commit eabea0f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/PartKeepr/PartBundle/Entity/Part.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit eabea0f

Please sign in to comment.