From 4fcd97b1428d15ea89cac84e586f1a3c3f02fd7d Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Tue, 4 May 2021 12:29:20 +0200 Subject: [PATCH] do not include running entries in invoices (#2551) --- src/Controller/InvoiceController.php | 1 - src/Repository/Query/InvoiceQuery.php | 6 +++++- tests/Repository/Query/InvoiceQueryTest.php | 6 +++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Controller/InvoiceController.php b/src/Controller/InvoiceController.php index 1b28a36b..dc9d7b92 100644 --- a/src/Controller/InvoiceController.php +++ b/src/Controller/InvoiceController.php @@ -192,7 +192,6 @@ final class InvoiceController extends AbstractController $query->setBegin($begin); $query->setEnd($end); $query->setExported(InvoiceQuery::STATE_NOT_EXPORTED); - $query->setState(InvoiceQuery::STATE_STOPPED); // limit access to data from teams $query->setCurrentUser($this->getUser()); diff --git a/src/Repository/Query/InvoiceQuery.php b/src/Repository/Query/InvoiceQuery.php index b57c55e2..d7a9cf30 100644 --- a/src/Repository/Query/InvoiceQuery.php +++ b/src/Repository/Query/InvoiceQuery.php @@ -28,7 +28,11 @@ class InvoiceQuery extends TimesheetQuery public function __construct() { parent::__construct(); - $this->setBillable(true); + $this->setDefaults([ + 'state' => self::STATE_STOPPED, + 'billable' => true, + 'markAsExported' => false, + ]); } public function getTemplate(): ?InvoiceTemplate diff --git a/tests/Repository/Query/InvoiceQueryTest.php b/tests/Repository/Query/InvoiceQueryTest.php index 7d7dfcd5..9938c336 100644 --- a/tests/Repository/Query/InvoiceQueryTest.php +++ b/tests/Repository/Query/InvoiceQueryTest.php @@ -30,7 +30,11 @@ class InvoiceQueryTest extends TimesheetQueryTest $this->assertCustomer($sut); $this->assertProject($sut); $this->assertActivity($sut); - $this->assertState($sut); + + self::assertEquals(InvoiceQuery::STATE_STOPPED, $sut->getState()); + self::assertFalse($sut->isRunning()); + self::assertTrue($sut->isStopped()); + $this->assertExported($sut); $this->assertMarkAsExported($sut); $this->assertModifiedAfter($sut);