src/Repository/Accounting/PaymentRepository.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Repository\Accounting;
  3. use App\Entity\Accounting\Payment;
  4. use App\Entity\Booking\Quote;
  5. use App\Entity\ParameterCodes;
  6. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\Persistence\ManagerRegistry;
  9. /**
  10.  * @method Payment|null find($id, $lockMode = null, $lockVersion = null)
  11.  * @method Payment|null findOneBy(array $criteria, array $orderBy = null)
  12.  * @method Payment[]    findAll()
  13.  * @method Payment[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  14.  */
  15. class PaymentRepository extends ServiceEntityRepository
  16. {
  17.     public function __construct(ManagerRegistry $registry)
  18.     {
  19.         parent::__construct($registryPayment::class);
  20.     }
  21.     /**
  22.      * @return Collection|Payment[]
  23.      */
  24.     public function findByQuote(Quote $quote, ?string $statusCode nullbool $manual false, array $orderBy = ["paymentAt""ASC"])
  25.     {
  26.         $qb $this->createQueryBuilder('p')
  27.             ->innerJoin('p.status''s')
  28.             ->innerJoin('p.quote''q')
  29.             ->innerJoin('p.mode''m')
  30.             ->innerJoin('m.parameterAttributeValues''pav')
  31.             ->innerJoin('pav.parameterTypeAttribute''pta');
  32.         $qb->where($qb->expr()->eq('q.id'':quote'))->setParameter('quote'$quote->getId());
  33.         if (null !== $statusCode) {
  34.             $qb->andWhere($qb->expr()->eq('s.code'':status'))->setParameter('status'$statusCode);
  35.         }
  36.         return $qb
  37.             ->andWhere($qb->expr()->eq('pta.code'':attributeCode'))->setParameter('attributeCode'ParameterCodes::PAYMENT_MODE_ORIGIN)
  38.             ->andWhere($qb->expr()->eq('pav.value'':manual'))->setParameter('manual'$manual "Paiement manuel" "Paiement bancaire")
  39.             ->addOrderBy('p.'.$orderBy[0], $orderBy[1])
  40.             ->getQuery()
  41.             ->getResult();
  42.     }
  43. }