mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Dont return null in getPartsInstockSum() function, when no part lots are defined yet.
This should fix issue #38.
This commit is contained in:
parent
64964f3b4d
commit
a28747b7ba
2 changed files with 6 additions and 6 deletions
|
@ -50,12 +50,12 @@ class PartRepository extends NamedDBElementRepository
|
|||
/**
|
||||
* Gets the summed up instock of all parts (only parts without an measurent unit).
|
||||
*
|
||||
* @return string
|
||||
* @return float
|
||||
*
|
||||
* @throws \Doctrine\ORM\NoResultException
|
||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
||||
*/
|
||||
public function getPartsInstockSum(): string
|
||||
public function getPartsInstockSum(): float
|
||||
{
|
||||
$qb = new QueryBuilder($this->getEntityManager());
|
||||
$qb->select('SUM(part_lot.amount)')
|
||||
|
@ -65,7 +65,7 @@ class PartRepository extends NamedDBElementRepository
|
|||
|
||||
$query = $qb->getQuery();
|
||||
|
||||
return $query->getSingleScalarResult();
|
||||
return (float) ($query->getSingleScalarResult() ?? 0.0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,6 +86,6 @@ class PartRepository extends NamedDBElementRepository
|
|||
|
||||
$query = $qb->getQuery();
|
||||
|
||||
return (int) $query->getSingleScalarResult();
|
||||
return (int) ($query->getSingleScalarResult() ?? 0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue