code: protected function getGetAvailableSumBySubjectQuery()
      {
          if (null !== $this->getAvailableSumBySubjectQuery) {
              return $this->getAvailableSumBySubjectQuery;
          }
  
          $as = $this->getAlias();
          $qb = $this->createFindBySubjectQueryBuilder();
  
          $qb
              ->andWhere($qb->expr()->gte($as . '.availableStock', 0))
              ->select('SUM(' . $as . '.availableStock) as available');
  
          return $this->getAvailableSumBySubjectQuery = $qb->getQuery();
      }
docs: Returns the "get available quantity sum by subject" query.
  
  @return \Doctrine\ORM\Query