allow increasing invoice numbers per day (#2433)

This commit is contained in:
Kevin Papst
2021-03-14 13:53:36 +01:00
committed by GitHub
parent c0378b4f51
commit 9a2fd9ba91
8 changed files with 142 additions and 19 deletions

View File

@@ -40,6 +40,20 @@ class InvoiceRepository extends EntityRepository
$entityManager->flush();
}
public function hasInvoice(string $invoiceNumber): bool
{
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('count(i.id) as counter')
->from(Invoice::class, 'i')
->andWhere($qb->expr()->eq('i.invoiceNumber', ':number'))
->setParameter('number', $invoiceNumber)
;
$counter = (int) $qb->getQuery()->getSingleScalarResult();
return $counter > 0;
}
private function getCounterFor(\DateTime $start, \DateTime $end, ?Customer $customer = null): int
{
$qb = $this->getEntityManager()->createQueryBuilder();