-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2414 from skaut/education-cashbook-years
Pokladní knihy vzdělávaček a jejich kategorie specifické pro rok
- Loading branch information
Showing
21 changed files
with
152 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
app/model/Cashbook/ReadModel/Queries/SkautisEducationYearQuery.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Model\Cashbook\ReadModel\Queries; | ||
|
||
use Model\Cashbook\Cashbook\CashbookId; | ||
use Model\Cashbook\ReadModel\QueryHandlers\SkautisEducationYearQueryHandler; | ||
|
||
/** @see SkautisEducationYearQueryHandler */ | ||
final class SkautisEducationYearQuery | ||
{ | ||
public function __construct(private CashbookId $cashbookId) | ||
{ | ||
} | ||
|
||
public function getCashbookId(): CashbookId | ||
{ | ||
return $this->cashbookId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
app/model/Cashbook/ReadModel/QueryHandlers/SkautisEducationYearQueryHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Model\Cashbook\ReadModel\QueryHandlers; | ||
|
||
use Model\Cashbook\CashbookNotFound; | ||
use Model\Cashbook\Exception\UnitNotFound; | ||
use Model\Cashbook\ObjectType; | ||
use Model\Cashbook\ReadModel\Queries\SkautisEducationYearQuery; | ||
use Model\Cashbook\Repositories\ICashbookRepository; | ||
use Model\Cashbook\Repositories\IEducationRepository; | ||
use Model\Common\ShouldNotHappen; | ||
|
||
class SkautisEducationYearQueryHandler | ||
{ | ||
public function __construct( | ||
private ICashbookRepository $cashbooks, | ||
private IEducationRepository $educationRepository, | ||
) { | ||
} | ||
|
||
/** | ||
* @throws CashbookNotFound | ||
* @throws UnitNotFound | ||
*/ | ||
public function __invoke(SkautisEducationYearQuery $query): int | ||
{ | ||
$cashbook = $this->cashbooks->find($query->getCashbookId()); | ||
$objectType = $cashbook->getType()->getSkautisObjectType(); | ||
|
||
if (! $objectType->equalsValue(ObjectType::EDUCATION)) { | ||
throw new ShouldNotHappen(); | ||
} | ||
|
||
return $this->educationRepository->findByCashbookId($query->getCashbookId())->getYear(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.