<?php

namespace AppBundle\Entity\Billing\Repository;
use AppBundle\Entity\Organization\Organization;
use Doctrine\ORM\EntityRepository;

/**
 * Class SddBankRepository
 * @package AppBundle\Entity\Billing\Repository
 */
class SddBankRepository extends EntityRepository
{
    public function getCountSddForOrganizationAndDate(Organization $organization, string $date)
    {
        $qb = $this->createQueryBuilder('sdd_bank');
        $qb
            ->join('sdd_bank.bills', 'bills')
            ->andWhere('bills.organization=:org')
            ->andWhere('sdd_bank.date LIKE :date')
            ->setParameter(':org',$organization)
            ->setParameter(':date',$date . '%');

        return count($qb->getQuery()->getResult());
    }
}