support multiple invoice repositories (#1084)
This commit is contained in:
@@ -41,9 +41,9 @@ class ActivityQuery extends ProjectQuery
|
||||
|
||||
/**
|
||||
* @param bool $globalsOnly
|
||||
* @return ActivityQuery
|
||||
* @return self
|
||||
*/
|
||||
public function setGlobalsOnly($globalsOnly): ActivityQuery
|
||||
public function setGlobalsOnly($globalsOnly): self
|
||||
{
|
||||
$this->globalsOnly = (bool) $globalsOnly;
|
||||
|
||||
@@ -60,9 +60,9 @@ class ActivityQuery extends ProjectQuery
|
||||
|
||||
/**
|
||||
* @param Project|int|null $project
|
||||
* @return ActivityQuery
|
||||
* @return self
|
||||
*/
|
||||
public function setProject($project = null): ActivityQuery
|
||||
public function setProject($project = null): self
|
||||
{
|
||||
$this->project = $project;
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ class BaseQuery
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @return $this
|
||||
* @return self
|
||||
*/
|
||||
public function setCurrentUser(User $user)
|
||||
{
|
||||
@@ -102,7 +102,7 @@ class BaseQuery
|
||||
|
||||
/**
|
||||
* @param int $page
|
||||
* @return $this
|
||||
* @return self
|
||||
*/
|
||||
public function setPage($page)
|
||||
{
|
||||
@@ -118,7 +118,7 @@ class BaseQuery
|
||||
|
||||
/**
|
||||
* @param int $pageSize
|
||||
* @return $this
|
||||
* @return self
|
||||
*/
|
||||
public function setPageSize($pageSize)
|
||||
{
|
||||
@@ -138,7 +138,7 @@ class BaseQuery
|
||||
* You need to validate carefully if this value is used from a user-input.
|
||||
*
|
||||
* @param string $orderBy
|
||||
* @return $this
|
||||
* @return self
|
||||
*/
|
||||
public function setOrderBy($orderBy)
|
||||
{
|
||||
@@ -154,7 +154,7 @@ class BaseQuery
|
||||
|
||||
/**
|
||||
* @param string $order
|
||||
* @return $this
|
||||
* @return self
|
||||
*/
|
||||
public function setOrder($order)
|
||||
{
|
||||
@@ -205,7 +205,7 @@ class BaseQuery
|
||||
|
||||
/**
|
||||
* @param SearchTerm|null $searchTerm
|
||||
* @return BaseQuery
|
||||
* @return self
|
||||
*/
|
||||
public function setSearchTerm(?SearchTerm $searchTerm)
|
||||
{
|
||||
|
||||
51
src/Repository/TimesheetInvoiceItemRepository.php
Normal file
51
src/Repository/TimesheetInvoiceItemRepository.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Timesheet;
|
||||
use App\Invoice\InvoiceItemInterface;
|
||||
use App\Invoice\InvoiceItemRepositoryInterface;
|
||||
use App\Repository\Query\InvoiceQuery;
|
||||
|
||||
final class TimesheetInvoiceItemRepository implements InvoiceItemRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @var TimesheetRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
public function __construct(TimesheetRepository $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InvoiceQuery $query
|
||||
* @return InvoiceItemInterface[]
|
||||
*/
|
||||
public function getInvoiceItemsForQuery(InvoiceQuery $query): iterable
|
||||
{
|
||||
return $this->repository->getTimesheetsForQuery($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InvoiceItemInterface[] $invoiceItems
|
||||
*/
|
||||
public function setExported(array $invoiceItems)
|
||||
{
|
||||
foreach ($invoiceItems as $item) {
|
||||
if (!$item instanceof Timesheet) {
|
||||
throw new \InvalidArgumentException('TimesheetInvoiceItemRepository only supports Timesheet entities');
|
||||
}
|
||||
}
|
||||
|
||||
$this->repository->setExported($invoiceItems);
|
||||
}
|
||||
}
|
||||
@@ -609,9 +609,9 @@ class TimesheetRepository extends EntityRepository
|
||||
}
|
||||
|
||||
if ($query->getExported() === TimesheetQuery::STATE_EXPORTED) {
|
||||
$qb->andWhere('t.exported = :exported')->setParameter('exported', true);
|
||||
$qb->andWhere('t.exported = :exported')->setParameter('exported', true, \PDO::PARAM_BOOL);
|
||||
} elseif ($query->getExported() === TimesheetQuery::STATE_NOT_EXPORTED) {
|
||||
$qb->andWhere('t.exported = :exported')->setParameter('exported', false);
|
||||
$qb->andWhere('t.exported = :exported')->setParameter('exported', false, \PDO::PARAM_BOOL);
|
||||
}
|
||||
|
||||
if (null !== $query->getActivity()) {
|
||||
|
||||
Reference in New Issue
Block a user