|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace AppBundle\Controller\Admin\Accounting\Journal; |
| 6 | + |
| 7 | +use AppBundle\Accounting\Entity\Repository\CategoryRepository; |
| 8 | +use AppBundle\Accounting\Entity\Repository\EventRepository; |
| 9 | +use AppBundle\Accounting\Entity\Repository\PaymentRepository; |
| 10 | +use AppBundle\Accounting\Form\InvoicingPeriodType; |
| 11 | +use AppBundle\Accounting\Model\Repository\InvoicingPeriodRepository; |
| 12 | +use AppBundle\Accounting\Model\Repository\TransactionRepository; |
| 13 | +use AppBundle\Accounting\OperationType; |
| 14 | +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
| 15 | +use Symfony\Component\HttpFoundation\Request; |
| 16 | +use Symfony\Component\HttpFoundation\Response; |
| 17 | + |
| 18 | +class ListAction extends AbstractController |
| 19 | +{ |
| 20 | + public function __construct( |
| 21 | + private readonly TransactionRepository $transactionRepository, |
| 22 | + private readonly CategoryRepository $categoryRepository, |
| 23 | + private readonly EventRepository $eventRepository, |
| 24 | + private readonly PaymentRepository $paymentRepository, |
| 25 | + private readonly InvoicingPeriodRepository $invoicingPeriodRepository, |
| 26 | + ) {} |
| 27 | + |
| 28 | + public function __invoke(Request $request): Response |
| 29 | + { |
| 30 | + $periodId = $request->query->has('periodId') ? $request->query->getInt('periodId') : null; |
| 31 | + $period = $this->invoicingPeriodRepository->getCurrentPeriod($periodId); |
| 32 | + $formPeriod = $this->createForm(InvoicingPeriodType::class, $period); |
| 33 | + $periods = $this->invoicingPeriodRepository->getAll(); |
| 34 | + $withReconciled = $request->query->getBoolean('with_reconciled'); |
| 35 | + $type = OperationType::from($request->query->getInt('type')); |
| 36 | + |
| 37 | + $transactions = $this->transactionRepository->getEntriesPerInvoicingPeriod($period, !$withReconciled, $type->value); |
| 38 | + |
| 39 | + return $this->render('admin/accounting/journal/list.html.twig', [ |
| 40 | + 'periods' => $periods, |
| 41 | + 'periodId' => $period->getId(), |
| 42 | + 'formPeriod' => $formPeriod->createView(), |
| 43 | + 'withReconciled' => $withReconciled, |
| 44 | + 'type' => $type, |
| 45 | + 'categories' => $this->categoryRepository->getAllSortedByName(), |
| 46 | + 'events' => $this->eventRepository->getAllSortedByName(), |
| 47 | + 'paymentTypes' => $this->paymentRepository->getAllSortedByName(), |
| 48 | + 'transactions' => $transactions, |
| 49 | + ]); |
| 50 | + } |
| 51 | +} |
0 commit comments