BillCreditRepository.php 792 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace AppBundle\Entity\Billing\Repository;
  3. use AppBundle\Entity\Organization\Organization;
  4. use Doctrine\ORM\EntityRepository;
  5. /**
  6. * Class BillRepository
  7. * @package AppBundle\Entity\AccessAndFunction\Repository
  8. */
  9. class BillCreditRepository extends EntityRepository
  10. {
  11. public function findMaxBNumberByOrganization(Organization $organization)
  12. {
  13. $qb = $this->createQueryBuilder('b');
  14. $qb->select('max(b.billCreditInteger) as billCreditNumber')
  15. ->join('b.bill','bil')
  16. ->join('bil.access','acc')
  17. ->andWhere('acc.organization=:org')
  18. ->orderBy('b.id', 'DESC')
  19. ->setParameter(':org',$organization)
  20. ->setMaxResults(1);
  21. return $qb->getQuery()->getOneOrNullResult();
  22. }
  23. }
  24. ?>