Skip to content

Commit

Permalink
Fixed cashbook export query not supporting education cashbooks
Browse files Browse the repository at this point in the history
  • Loading branch information
marekdedic committed Sep 29, 2023
1 parent 461f2e7 commit c4cf2b1
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
use Model\Cashbook\ReadModel\Queries\CashbookOfficialUnitQuery;
use Model\Cashbook\Repositories\ICampRepository as ICashbookCampRepository;
use Model\Cashbook\Repositories\ICashbookRepository;
use Model\Cashbook\Repositories\IEducationRepository as ICashbookEducationRepository;
use Model\Cashbook\Repositories\IEventRepository as ICashbookEventRepository;
use Model\Cashbook\Repositories\IUnitRepository;
use Model\Common\ShouldNotHappen;
use Model\Common\UnitId;
use Model\Event\Repositories\ICampRepository;
use Model\Event\Repositories\IEducationRepository;
use Model\Event\Repositories\IEventRepository;
use Model\Payment\IUnitResolver;
use Model\Unit\Repositories\IUnitRepository as ISkautisUnitRepository;
Expand All @@ -28,11 +30,13 @@ public function __construct(
private ICashbookRepository $cashbooks,
private IEventRepository $eventRepository,
private ICampRepository $campRepository,
private IEducationRepository $educationRepository,
private IUnitRepository $unitRepository,
private IUnitResolver $unitResolver,
private ISkautisUnitRepository $skautisUnitRepository,
private ICashbookEventRepository $eventCashbookRepository,
private ICashbookCampRepository $campCashbookRepository,
private ICashbookEducationRepository $educationCashbookRepository,
) {
}

Expand All @@ -59,6 +63,12 @@ private function resolveUnitThatOwnsCashbook(Cashbook $cashbook): UnitId
return $this->campRepository->find($campId)->getUnitId();
}

if ($cashbook->getType()->equalsValue(CashbookType::EDUCATION)) {
$educationId = $this->educationCashbookRepository->findByCashbookId($cashbook->getId())->getSkautisId();

return $this->educationRepository->find($educationId)->getUnitId();
}

if ($cashbook->getType()->isUnit()) {
return $this->unitRepository->findByCashbookId($cashbook->getId())->getId();
}
Expand Down

0 comments on commit c4cf2b1

Please sign in to comment.