diff --git a/sources/AppBundle/Accounting/Entity/Repository/CategoryRepository.php b/sources/AppBundle/Accounting/Entity/Repository/CategoryRepository.php index 9952dbf72..753224948 100644 --- a/sources/AppBundle/Accounting/Entity/Repository/CategoryRepository.php +++ b/sources/AppBundle/Accounting/Entity/Repository/CategoryRepository.php @@ -21,10 +21,15 @@ public function __construct(ManagerRegistry $registry) /** * @return array */ - public function getAllSortedByName(): array + public function getAllSortedByName(bool $usedInAccountingJournal = false): array { - return $this->createQueryBuilder('c') - ->orderBy('c.name', 'asc') + $query = $this->createQueryBuilder('c'); + + if ($usedInAccountingJournal) { + $query->andWhere('c.hideInAccountingJournalAt IS NULL'); + } + + return $query->orderBy('c.name', 'asc') ->getQuery() ->execute(); } diff --git a/sources/AppBundle/Controller/Admin/Accounting/Journal/ListAction.php b/sources/AppBundle/Controller/Admin/Accounting/Journal/ListAction.php index 1561cf6e7..2a7810baa 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Journal/ListAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Journal/ListAction.php @@ -42,8 +42,8 @@ public function __invoke(Request $request): Response 'formPeriod' => $formPeriod->createView(), 'withReconciled' => $withReconciled, 'type' => $type, - 'categories' => $this->categoryRepository->getAllSortedByName(), - 'events' => $this->eventRepository->getAllSortedByName(), + 'categories' => $this->categoryRepository->getAllSortedByName(true), + 'events' => $this->eventRepository->getAllSortedByName(true), 'paymentTypes' => $this->paymentRepository->getAllSortedByName(), 'transactions' => $transactions, ]);