From 7f5ea04271ad1d3622093486dd2e95f4c01085c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Wed, 25 Oct 2023 22:34:10 +0200 Subject: [PATCH 01/10] Reverse travel --- .../presenters/DefaultPresenter.php | 15 ++++++++++++ .../templates/Default/detail.latte | 1 + app/model/Travel/Command.php | 18 +++++++++++++- .../Travel/Commands/Command/ReverseTravel.php | 23 ++++++++++++++++++ .../Handlers/Command/ReverseTravelHandler.php | 24 +++++++++++++++++++ frontend/icons.ts | 1 + 6 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 app/model/Travel/Commands/Command/ReverseTravel.php create mode 100644 app/model/Travel/Handlers/Command/ReverseTravelHandler.php diff --git a/app/AccountancyModule/TravelModule/presenters/DefaultPresenter.php b/app/AccountancyModule/TravelModule/presenters/DefaultPresenter.php index ac378b7b7..a6d217d2d 100644 --- a/app/AccountancyModule/TravelModule/presenters/DefaultPresenter.php +++ b/app/AccountancyModule/TravelModule/presenters/DefaultPresenter.php @@ -12,6 +12,7 @@ use Assert\Assertion; use Model\Services\PdfRenderer; use Model\Travel\Commands\Command\DuplicateTravel; +use Model\Travel\Commands\Command\ReverseTravel; use Model\Travel\Travel\TransportType; use Model\TravelService; use Model\UserService; @@ -171,6 +172,20 @@ public function handleDuplicateTravel(int $commandId, int $travelId): void $this->redirect('this'); } + public function handleReverseTravel(int $commandId, int $travelId): void + { + if (! $this->isCommandEditable($commandId)) { + $this->flashMessage('Nemáte oprávnění obrátit cestu.', 'danger'); + $this->redirect('default'); + } + + $this->commandBus->handle(new ReverseTravel($commandId, $travelId)); + + $this->flashMessage('Cesta byla obrácena.', 'success'); + + $this->redirect('this'); + } + public function handleOpenCommand(int $commandId): void { if (! $this->isCommandAccessible($commandId)) { diff --git a/app/AccountancyModule/TravelModule/templates/Default/detail.latte b/app/AccountancyModule/TravelModule/templates/Default/detail.latte index 5405ec0fd..22699c624 100644 --- a/app/AccountancyModule/TravelModule/templates/Default/detail.latte +++ b/app/AccountancyModule/TravelModule/templates/Default/detail.latte @@ -85,6 +85,7 @@
+
diff --git a/app/model/Travel/Command.php b/app/model/Travel/Command.php index 851818501..6f823b3d5 100644 --- a/app/model/Travel/Command.php +++ b/app/model/Travel/Command.php @@ -214,7 +214,23 @@ public function duplicateTravel(int $id): void } elseif ($travel instanceof TransportTravel) { $this->addTransportTravel($travel->getPrice(), $travel->getDetails()); } else { - throw new ShouldNotHappen('Uknown travel type'); + throw new ShouldNotHappen('Unknown travel type'); + } + } + + /** @throws TravelNotFound */ + public function reverseTravel(int $id): void + { + $travel = $this->getTravel($id); + $details = $travel->getDetails(); + $reversedDetails = new TravelDetails($details->getDate(), $details->getTransportType(), $details->getEndPlace(), $details->getStartPlace()); + + if ($travel instanceof VehicleTravel) { + $travel->update($travel->getDistance(), $reversedDetails); + } elseif ($travel instanceof TransportTravel) { + $travel->update($travel->getPrice(), $reversedDetails); + } else { + throw new ShouldNotHappen('Unknown travel type'); } } diff --git a/app/model/Travel/Commands/Command/ReverseTravel.php b/app/model/Travel/Commands/Command/ReverseTravel.php new file mode 100644 index 000000000..1badbb335 --- /dev/null +++ b/app/model/Travel/Commands/Command/ReverseTravel.php @@ -0,0 +1,23 @@ +commandId; + } + + public function getTravelId(): int + { + return $this->travelId; + } +} diff --git a/app/model/Travel/Handlers/Command/ReverseTravelHandler.php b/app/model/Travel/Handlers/Command/ReverseTravelHandler.php new file mode 100644 index 000000000..37843de55 --- /dev/null +++ b/app/model/Travel/Handlers/Command/ReverseTravelHandler.php @@ -0,0 +1,24 @@ +commands->find($command->getCommandId()); + + $travelCommand->reverseTravel($command->getTravelId()); + + $this->commands->save($travelCommand); + } +} diff --git a/frontend/icons.ts b/frontend/icons.ts index a6d42178b..f2b0adb4d 100644 --- a/frontend/icons.ts +++ b/frontend/icons.ts @@ -80,6 +80,7 @@ library.add( far.faTrashAlt, far.faUser, far.faQuestionCircle, + far.faExchangeAlt, // Brands fab.faGithub as IconDefinition, From 70cdeab371245c912af23a08aa3e7327e4b46709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Wed, 25 Oct 2023 22:53:41 +0200 Subject: [PATCH 02/10] test --- tests/unit/Travel/CommandTest.php | 64 +++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/tests/unit/Travel/CommandTest.php b/tests/unit/Travel/CommandTest.php index 36c638ea0..d22bc3d6e 100644 --- a/tests/unit/Travel/CommandTest.php +++ b/tests/unit/Travel/CommandTest.php @@ -433,6 +433,70 @@ public function testVehicleTravelIsDuplicated(): void self::assertEquals($travelDetails->getEndPlace(), $duplicatedTravelDetails->getEndPlace()); } + public function testTransportTravelIsReversed(): void + { + $passenger = new Passenger('Frantisek Masa', '---', 'Brno'); + $purpose = 'Cesta na střediskovku'; + $command = new Command(1, null, $passenger, $purpose, 'Brno', '', Money::CZK(0), Money::CZK(0), '', null, [], ''); + + $command->addTransportTravel( + Money::CZK(100), + new Command\TravelDetails( + new Date('now'), + TransportType::get(TransportType::BUS), + 'Praha', + 'Brno', + ), + ); + + $travel = $command->getTravels()[0]; + + $command->reverseTravel($travel->getId()); + + $reversedTravel = $command->getTravels()[0]; + + $travelDetails = $travel->getDetails(); + $reversedTravelDetails = $reversedTravel->getDetails(); + + self::assertEquals($travel->getId(), $reversedTravel->getId()); + self::assertEquals($travelDetails->getDate(), $reversedTravelDetails->getDate()); + self::assertEquals($travelDetails->getTransportType(), $reversedTravelDetails->getTransportType()); + self::assertEquals($travelDetails->getStartPlace(), $reversedTravelDetails->getEndPlace()); + self::assertEquals($travelDetails->getEndPlace(), $reversedTravelDetails->getStartPlace()); + } + + public function testVehicleTravelIsReversed(): void + { + $passenger = new Passenger('Frantisek Masa', '---', 'Brno'); + $purpose = 'Cesta na střediskovku'; + $command = new Command(1, null, $passenger, $purpose, 'Brno', '', Money::CZK(3120), Money::CZK(500), '', null, [], ''); + + $command->addVehicleTravel( + 123, + new Command\TravelDetails( + new Date('now'), + TransportType::get(TransportType::CAR), + 'Praha', + 'Brno', + ), + ); + + $travel = $command->getTravels()[0]; + + $command->reverseTravel($travel->getId()); + + $reversedTravel = $command->getTravels()[0]; + + $travelDetails = $travel->getDetails(); + $reversedTravelDetails = $reversedTravel->getDetails(); + + self::assertEquals($travel->getId(), $reversedTravel->getId()); + self::assertEquals($travelDetails->getDate(), $reversedTravelDetails->getDate()); + self::assertEquals($travelDetails->getTransportType(), $reversedTravelDetails->getTransportType()); + self::assertEquals($travelDetails->getStartPlace(), $reversedTravelDetails->getEndPlace()); + self::assertEquals($travelDetails->getEndPlace(), $reversedTravelDetails->getStartPlace()); + } + private function createCommand(Vehicle|null $vehicle = null): Command { return new Command( From c72485a235bbbaff234037289252696332c43a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Wed, 25 Oct 2023 23:24:08 +0200 Subject: [PATCH 03/10] cs fix --- app/model/Travel/Command.php | 4 ++-- app/model/Travel/Commands/Command/ReverseTravel.php | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/model/Travel/Command.php b/app/model/Travel/Command.php index 6f823b3d5..dcc0dcb81 100644 --- a/app/model/Travel/Command.php +++ b/app/model/Travel/Command.php @@ -221,8 +221,8 @@ public function duplicateTravel(int $id): void /** @throws TravelNotFound */ public function reverseTravel(int $id): void { - $travel = $this->getTravel($id); - $details = $travel->getDetails(); + $travel = $this->getTravel($id); + $details = $travel->getDetails(); $reversedDetails = new TravelDetails($details->getDate(), $details->getTransportType(), $details->getEndPlace(), $details->getStartPlace()); if ($travel instanceof VehicleTravel) { diff --git a/app/model/Travel/Commands/Command/ReverseTravel.php b/app/model/Travel/Commands/Command/ReverseTravel.php index 1badbb335..6ba167dfa 100644 --- a/app/model/Travel/Commands/Command/ReverseTravel.php +++ b/app/model/Travel/Commands/Command/ReverseTravel.php @@ -4,6 +4,8 @@ namespace Model\Travel\Commands\Command; +use Model\Travel\Handlers\Command\ReverseTravelHandler; + /** @see ReverseTravelHandler */ final class ReverseTravel { From a88a68279abdac830dc87928f2f3d980536ce1bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Wed, 25 Oct 2023 23:31:12 +0200 Subject: [PATCH 04/10] test fix --- tests/unit/Travel/CommandTest.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/unit/Travel/CommandTest.php b/tests/unit/Travel/CommandTest.php index d22bc3d6e..141149a87 100644 --- a/tests/unit/Travel/CommandTest.php +++ b/tests/unit/Travel/CommandTest.php @@ -450,12 +450,11 @@ public function testTransportTravelIsReversed(): void ); $travel = $command->getTravels()[0]; + $travelDetails = $travel->getDetails(); $command->reverseTravel($travel->getId()); $reversedTravel = $command->getTravels()[0]; - - $travelDetails = $travel->getDetails(); $reversedTravelDetails = $reversedTravel->getDetails(); self::assertEquals($travel->getId(), $reversedTravel->getId()); @@ -482,12 +481,11 @@ public function testVehicleTravelIsReversed(): void ); $travel = $command->getTravels()[0]; + $travelDetails = $travel->getDetails(); $command->reverseTravel($travel->getId()); $reversedTravel = $command->getTravels()[0]; - - $travelDetails = $travel->getDetails(); $reversedTravelDetails = $reversedTravel->getDetails(); self::assertEquals($travel->getId(), $reversedTravel->getId()); From 02e8c447f53b9356d536de932f8b4c481104a960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Wed, 25 Oct 2023 23:32:09 +0200 Subject: [PATCH 05/10] cs fix --- tests/unit/Travel/CommandTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit/Travel/CommandTest.php b/tests/unit/Travel/CommandTest.php index 141149a87..8e83e724f 100644 --- a/tests/unit/Travel/CommandTest.php +++ b/tests/unit/Travel/CommandTest.php @@ -449,12 +449,12 @@ public function testTransportTravelIsReversed(): void ), ); - $travel = $command->getTravels()[0]; + $travel = $command->getTravels()[0]; $travelDetails = $travel->getDetails(); $command->reverseTravel($travel->getId()); - $reversedTravel = $command->getTravels()[0]; + $reversedTravel = $command->getTravels()[0]; $reversedTravelDetails = $reversedTravel->getDetails(); self::assertEquals($travel->getId(), $reversedTravel->getId()); @@ -480,12 +480,12 @@ public function testVehicleTravelIsReversed(): void ), ); - $travel = $command->getTravels()[0]; + $travel = $command->getTravels()[0]; $travelDetails = $travel->getDetails(); $command->reverseTravel($travel->getId()); - $reversedTravel = $command->getTravels()[0]; + $reversedTravel = $command->getTravels()[0]; $reversedTravelDetails = $reversedTravel->getDetails(); self::assertEquals($travel->getId(), $reversedTravel->getId()); From 9ee538ef30178f768762496b85aae88cdad2fc3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Thu, 26 Oct 2023 00:04:57 +0200 Subject: [PATCH 06/10] icon fix --- .../TravelModule/templates/Default/detail.latte | 2 +- frontend/icons.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/AccountancyModule/TravelModule/templates/Default/detail.latte b/app/AccountancyModule/TravelModule/templates/Default/detail.latte index 22699c624..0ef6def1e 100644 --- a/app/AccountancyModule/TravelModule/templates/Default/detail.latte +++ b/app/AccountancyModule/TravelModule/templates/Default/detail.latte @@ -85,7 +85,7 @@
- +
diff --git a/frontend/icons.ts b/frontend/icons.ts index f2b0adb4d..3217b763e 100644 --- a/frontend/icons.ts +++ b/frontend/icons.ts @@ -60,6 +60,7 @@ library.add( fas.faThList, fas.faEllipsisV, fas.faUserGraduate, + fas.faExchange, // Regular icons far.faCalendar, @@ -80,7 +81,6 @@ library.add( far.faTrashAlt, far.faUser, far.faQuestionCircle, - far.faExchangeAlt, // Brands fab.faGithub as IconDefinition, From 157bf355700b2e2670197c5d20ef5d9844f2d766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Tue, 31 Oct 2023 21:26:06 +0100 Subject: [PATCH 07/10] return travel --- .../presenters/DefaultPresenter.php | 4 +- .../templates/Default/detail.latte | 2 +- app/model/Travel/Command.php | 6 +-- ...{ReverseTravel.php => AddReturnTravel.php} | 6 +-- ...Handler.php => AddReturnTravelHandler.php} | 8 ++-- frontend/icons.ts | 2 +- tests/unit/Travel/CommandTest.php | 39 ++++++++++--------- 7 files changed, 35 insertions(+), 32 deletions(-) rename app/model/Travel/Commands/Command/{ReverseTravel.php => AddReturnTravel.php} (73%) rename app/model/Travel/Handlers/Command/{ReverseTravelHandler.php => AddReturnTravelHandler.php} (62%) diff --git a/app/AccountancyModule/TravelModule/presenters/DefaultPresenter.php b/app/AccountancyModule/TravelModule/presenters/DefaultPresenter.php index a6d217d2d..a10d07a38 100644 --- a/app/AccountancyModule/TravelModule/presenters/DefaultPresenter.php +++ b/app/AccountancyModule/TravelModule/presenters/DefaultPresenter.php @@ -11,8 +11,8 @@ use App\Forms\BaseForm; use Assert\Assertion; use Model\Services\PdfRenderer; +use Model\Travel\Commands\Command\AddReturnTravel; use Model\Travel\Commands\Command\DuplicateTravel; -use Model\Travel\Commands\Command\ReverseTravel; use Model\Travel\Travel\TransportType; use Model\TravelService; use Model\UserService; @@ -179,7 +179,7 @@ public function handleReverseTravel(int $commandId, int $travelId): void $this->redirect('default'); } - $this->commandBus->handle(new ReverseTravel($commandId, $travelId)); + $this->commandBus->handle(new AddReturnTravel($commandId, $travelId)); $this->flashMessage('Cesta byla obrácena.', 'success'); diff --git a/app/AccountancyModule/TravelModule/templates/Default/detail.latte b/app/AccountancyModule/TravelModule/templates/Default/detail.latte index 0ef6def1e..355a7ecbe 100644 --- a/app/AccountancyModule/TravelModule/templates/Default/detail.latte +++ b/app/AccountancyModule/TravelModule/templates/Default/detail.latte @@ -85,7 +85,7 @@
- +
diff --git a/app/model/Travel/Command.php b/app/model/Travel/Command.php index dcc0dcb81..dda282917 100644 --- a/app/model/Travel/Command.php +++ b/app/model/Travel/Command.php @@ -219,16 +219,16 @@ public function duplicateTravel(int $id): void } /** @throws TravelNotFound */ - public function reverseTravel(int $id): void + public function addReturnTravel(int $id): void { $travel = $this->getTravel($id); $details = $travel->getDetails(); $reversedDetails = new TravelDetails($details->getDate(), $details->getTransportType(), $details->getEndPlace(), $details->getStartPlace()); if ($travel instanceof VehicleTravel) { - $travel->update($travel->getDistance(), $reversedDetails); + $this->addVehicleTravel($travel->getDistance(), $reversedDetails); } elseif ($travel instanceof TransportTravel) { - $travel->update($travel->getPrice(), $reversedDetails); + $this->addTransportTravel($travel->getPrice(), $reversedDetails); } else { throw new ShouldNotHappen('Unknown travel type'); } diff --git a/app/model/Travel/Commands/Command/ReverseTravel.php b/app/model/Travel/Commands/Command/AddReturnTravel.php similarity index 73% rename from app/model/Travel/Commands/Command/ReverseTravel.php rename to app/model/Travel/Commands/Command/AddReturnTravel.php index 6ba167dfa..b9c26b857 100644 --- a/app/model/Travel/Commands/Command/ReverseTravel.php +++ b/app/model/Travel/Commands/Command/AddReturnTravel.php @@ -4,10 +4,10 @@ namespace Model\Travel\Commands\Command; -use Model\Travel\Handlers\Command\ReverseTravelHandler; +use Model\Travel\Handlers\Command\AddReturnTravelHandler; -/** @see ReverseTravelHandler */ -final class ReverseTravel +/** @see AddReturnTravelHandler */ +final class AddReturnTravel { public function __construct(private int $commandId, private int $travelId) { diff --git a/app/model/Travel/Handlers/Command/ReverseTravelHandler.php b/app/model/Travel/Handlers/Command/AddReturnTravelHandler.php similarity index 62% rename from app/model/Travel/Handlers/Command/ReverseTravelHandler.php rename to app/model/Travel/Handlers/Command/AddReturnTravelHandler.php index 37843de55..e07fde633 100644 --- a/app/model/Travel/Handlers/Command/ReverseTravelHandler.php +++ b/app/model/Travel/Handlers/Command/AddReturnTravelHandler.php @@ -4,20 +4,20 @@ namespace Model\Travel\Handlers\Command; -use Model\Travel\Commands\Command\ReverseTravel; +use Model\Travel\Commands\Command\AddReturnTravel; use Model\Travel\Repositories\ICommandRepository; -final class ReverseTravelHandler +final class AddReturnTravelHandler { public function __construct(private ICommandRepository $commands) { } - public function __invoke(ReverseTravel $command): void + public function __invoke(AddReturnTravel $command): void { $travelCommand = $this->commands->find($command->getCommandId()); - $travelCommand->reverseTravel($command->getTravelId()); + $travelCommand->addReturnTravel($command->getTravelId()); $this->commands->save($travelCommand); } diff --git a/frontend/icons.ts b/frontend/icons.ts index 3217b763e..1f0b86876 100644 --- a/frontend/icons.ts +++ b/frontend/icons.ts @@ -60,7 +60,6 @@ library.add( fas.faThList, fas.faEllipsisV, fas.faUserGraduate, - fas.faExchange, // Regular icons far.faCalendar, @@ -81,6 +80,7 @@ library.add( far.faTrashAlt, far.faUser, far.faQuestionCircle, + far.faArrowAltCircleLeft, // Brands fab.faGithub as IconDefinition, diff --git a/tests/unit/Travel/CommandTest.php b/tests/unit/Travel/CommandTest.php index 8e83e724f..90119adab 100644 --- a/tests/unit/Travel/CommandTest.php +++ b/tests/unit/Travel/CommandTest.php @@ -449,19 +449,20 @@ public function testTransportTravelIsReversed(): void ), ); - $travel = $command->getTravels()[0]; - $travelDetails = $travel->getDetails(); + $travel = $command->getTravels()[0]; - $command->reverseTravel($travel->getId()); + $command->addReturnTravel($travel->getId()); - $reversedTravel = $command->getTravels()[0]; - $reversedTravelDetails = $reversedTravel->getDetails(); + $backTravel = $command->getTravels()[1]; - self::assertEquals($travel->getId(), $reversedTravel->getId()); - self::assertEquals($travelDetails->getDate(), $reversedTravelDetails->getDate()); - self::assertEquals($travelDetails->getTransportType(), $reversedTravelDetails->getTransportType()); - self::assertEquals($travelDetails->getStartPlace(), $reversedTravelDetails->getEndPlace()); - self::assertEquals($travelDetails->getEndPlace(), $reversedTravelDetails->getStartPlace()); + $travelDetails = $travel->getDetails(); + $backTravelDetails = $backTravel->getDetails(); + + self::assertNotEquals($travel->getId(), $backTravel->getId()); + self::assertEquals($travelDetails->getDate(), $backTravelDetails->getDate()); + self::assertEquals($travelDetails->getTransportType(), $backTravelDetails->getTransportType()); + self::assertEquals($travelDetails->getEndPlace(), $backTravelDetails->getStartPlace()); + self::assertEquals($travelDetails->getStartPlace(), $backTravelDetails->getEndPlace()); } public function testVehicleTravelIsReversed(): void @@ -483,16 +484,18 @@ public function testVehicleTravelIsReversed(): void $travel = $command->getTravels()[0]; $travelDetails = $travel->getDetails(); - $command->reverseTravel($travel->getId()); + $command->addReturnTravel($travel->getId()); + + $backTravel = $command->getTravels()[1]; - $reversedTravel = $command->getTravels()[0]; - $reversedTravelDetails = $reversedTravel->getDetails(); + $travelDetails = $travel->getDetails(); + $backTravelDetails = $backTravel->getDetails(); - self::assertEquals($travel->getId(), $reversedTravel->getId()); - self::assertEquals($travelDetails->getDate(), $reversedTravelDetails->getDate()); - self::assertEquals($travelDetails->getTransportType(), $reversedTravelDetails->getTransportType()); - self::assertEquals($travelDetails->getStartPlace(), $reversedTravelDetails->getEndPlace()); - self::assertEquals($travelDetails->getEndPlace(), $reversedTravelDetails->getStartPlace()); + self::assertNotEquals($travel->getId(), $backTravel->getId()); + self::assertEquals($travelDetails->getDate(), $backTravelDetails->getDate()); + self::assertEquals($travelDetails->getTransportType(), $backTravelDetails->getTransportType()); + self::assertEquals($travelDetails->getEndPlace(), $backTravelDetails->getStartPlace()); + self::assertEquals($travelDetails->getStartPlace(), $backTravelDetails->getEndPlace()); } private function createCommand(Vehicle|null $vehicle = null): Command From b2aa4d39fd585e9e597a9a4d4361a21ef4ed5ad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Tue, 31 Oct 2023 21:40:45 +0100 Subject: [PATCH 08/10] fixes --- .../TravelModule/presenters/DefaultPresenter.php | 6 +++--- .../TravelModule/templates/Default/detail.latte | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/AccountancyModule/TravelModule/presenters/DefaultPresenter.php b/app/AccountancyModule/TravelModule/presenters/DefaultPresenter.php index a10d07a38..4c1ca83fb 100644 --- a/app/AccountancyModule/TravelModule/presenters/DefaultPresenter.php +++ b/app/AccountancyModule/TravelModule/presenters/DefaultPresenter.php @@ -172,16 +172,16 @@ public function handleDuplicateTravel(int $commandId, int $travelId): void $this->redirect('this'); } - public function handleReverseTravel(int $commandId, int $travelId): void + public function handleAddReturnTravel(int $commandId, int $travelId): void { if (! $this->isCommandEditable($commandId)) { - $this->flashMessage('Nemáte oprávnění obrátit cestu.', 'danger'); + $this->flashMessage('Nemáte oprávnění přidat zpáteční cestu.', 'danger'); $this->redirect('default'); } $this->commandBus->handle(new AddReturnTravel($commandId, $travelId)); - $this->flashMessage('Cesta byla obrácena.', 'success'); + $this->flashMessage('Zpáteční cesta byla přidána.', 'success'); $this->redirect('this'); } diff --git a/app/AccountancyModule/TravelModule/templates/Default/detail.latte b/app/AccountancyModule/TravelModule/templates/Default/detail.latte index 355a7ecbe..71dc9ecd0 100644 --- a/app/AccountancyModule/TravelModule/templates/Default/detail.latte +++ b/app/AccountancyModule/TravelModule/templates/Default/detail.latte @@ -85,7 +85,7 @@
- +
From 8f636d5ae22ccc0ed03e780e9e285301db4615bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Tue, 31 Oct 2023 21:43:01 +0100 Subject: [PATCH 09/10] test fixes --- tests/unit/Travel/CommandTest.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/unit/Travel/CommandTest.php b/tests/unit/Travel/CommandTest.php index 90119adab..ccf6cb4bc 100644 --- a/tests/unit/Travel/CommandTest.php +++ b/tests/unit/Travel/CommandTest.php @@ -433,7 +433,7 @@ public function testVehicleTravelIsDuplicated(): void self::assertEquals($travelDetails->getEndPlace(), $duplicatedTravelDetails->getEndPlace()); } - public function testTransportTravelIsReversed(): void + public function testTransportTravelIsReturnAdded(): void { $passenger = new Passenger('Frantisek Masa', '---', 'Brno'); $purpose = 'Cesta na střediskovku'; @@ -465,7 +465,7 @@ public function testTransportTravelIsReversed(): void self::assertEquals($travelDetails->getStartPlace(), $backTravelDetails->getEndPlace()); } - public function testVehicleTravelIsReversed(): void + public function testVehicleTravelIsReturnAdded(): void { $passenger = new Passenger('Frantisek Masa', '---', 'Brno'); $purpose = 'Cesta na střediskovku'; @@ -482,7 +482,6 @@ public function testVehicleTravelIsReversed(): void ); $travel = $command->getTravels()[0]; - $travelDetails = $travel->getDetails(); $command->addReturnTravel($travel->getId()); From 13bead5ce33aa2e550169e7a572f4e097b6daa5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Tue, 31 Oct 2023 21:44:11 +0100 Subject: [PATCH 10/10] cs fix --- tests/unit/Travel/CommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/Travel/CommandTest.php b/tests/unit/Travel/CommandTest.php index ccf6cb4bc..d56114d31 100644 --- a/tests/unit/Travel/CommandTest.php +++ b/tests/unit/Travel/CommandTest.php @@ -481,7 +481,7 @@ public function testVehicleTravelIsReturnAdded(): void ), ); - $travel = $command->getTravels()[0]; + $travel = $command->getTravels()[0]; $command->addReturnTravel($travel->getId());