Skip to content

Commit 2c01ac2

Browse files
committed
Refonte - Trésorerie - Journal - List
1 parent 4b6d326 commit 2c01ac2

14 files changed

Lines changed: 478 additions & 33 deletions

File tree

app/config/packages/backoffice_menu.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,13 @@ parameters:
226226
- admin_accounting_invoices_list
227227
compta_journal:
228228
nom: 'Journal'
229+
url: '/admin/accounting/journal/list'
229230
niveau: 'ROLE_ADMIN'
230231
extra_routes:
232+
- admin_accounting_journal_list
231233
- admin_accounting_journal_add
232234
- admin_accounting_journal_edit
235+
- admin_accounting_journal_import
233236
compta_conf_evenement:
234237
nom: 'Configuration'
235238
niveau: 'ROLE_ADMIN'

app/config/routing/admin_accounting/journal.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
admin_accounting_journal_list:
2+
path: /list
3+
defaults:
4+
_controller: AppBundle\Controller\Admin\Accounting\Journal\ListAction
5+
16
admin_accounting_journal_delete:
27
path: /delete/{id}
38
defaults:
2.49 KB
Loading
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace AppBundle\Accounting;
6+
7+
enum OperationType: int
8+
{
9+
case Debit = 1;
10+
case Credit = 2;
11+
case All = 0;
12+
}

sources/AppBundle/Controller/Admin/Accounting/Journal/AddTransactionAction.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ public function __invoke(Request $request): Response
2828
if ($form->isSubmitted() && $form->isValid()) {
2929
$this->transactionRepository->save($transaction);
3030
$this->audit->log("Ajout d'une écriture");
31-
$_SESSION['flash']['message'] = "l'écriture a été ajoutée";
32-
$_SESSION['flash']['error'] = false;
33-
$this->addFlash('notice', "l'écriture a été ajoutée");
34-
return $this->redirect('/pages/administration/index.php?page=compta_journal&action=lister#L' . $transaction->getId());
31+
$this->addFlash('notice', "L'écriture a été ajoutée");
32+
return $this->redirect('/admin/accounting/journal/list#L' . $transaction->getId());
3533
}
3634

3735
return $this->render('admin/accounting/journal/add.html.twig', [

sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ public function __invoke(Request $request, int $id): RedirectResponse
5050
$transaction->setAmount($transaction->getAmount() - $totalAmount);
5151
$this->transactionRepository->save($transaction);
5252

53-
$_SESSION['flash'] = "L'écriture a été ventilée";
54-
$_SESSION['erreur'] = false;
5553
$this->addFlash('notice', "L'écriture a été ventilée");
56-
return $this->redirect('/pages/administration/index.php?page=compta_journal#journal-ligne-' . $lastId);
54+
return $this->redirect('/admin/accounting/journal/list#journal-ligne-' . $lastId);
5755
}
5856
}

sources/AppBundle/Controller/Admin/Accounting/Journal/DeleteAction.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,13 @@ public function __invoke(Request $request, int $id): Response
2222
{
2323
$accounting = $this->transactionRepository->get($id);
2424
if (!$accounting instanceof Transaction) {
25-
$_SESSION['flash'] = "Une erreur est survenue lors de la suppression de l'écriture";
26-
$_SESSION['erreur'] = true;
2725
$this->addFlash('error', "Une erreur est survenue lors de la suppression de l'écriture");
28-
return $this->redirect('/pages/administration/index.php?page=compta_journal');
26+
return $this->redirectToRoute('admin_accounting_journal_list');
2927
}
3028

3129
$this->transactionRepository->delete($accounting);
3230
$this->audit->log("Suppression de l'écriture {$id}");
33-
$_SESSION['flash'] = "L'écriture a été supprimée";
34-
$_SESSION['erreur'] = false;
3531
$this->addFlash('notice', "L'écriture a été supprimée");
36-
return $this->redirect('/pages/administration/index.php?page=compta_journal');
32+
return $this->redirectToRoute('admin_accounting_journal_list');
3733
}
3834
}

sources/AppBundle/Controller/Admin/Accounting/Journal/EditTransactionAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __invoke(Request $request, int $id): Response
4646
if ($submitAndPassButton instanceof SubmitButton && $submitAndPassButton->isClicked()) {
4747
return $this->redirectToRoute('admin_accounting_journal_edit', ['id' => $nextTransaction->getId()]);
4848
} else {
49-
return $this->redirect('/pages/administration/index.php?page=compta_journal&action=lister#L' . $transaction->getId());
49+
return $this->redirect('/admin/accounting/journal/list#L' . $transaction->getId());
5050
}
5151
}
5252
return $this->render('admin/accounting/journal/edit.html.twig', [

sources/AppBundle/Controller/Admin/Accounting/Journal/ImportAction.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,12 @@ public function __invoke(Request $request): Response
3636
$importer = $this->importerFactory->create($this->uploadDir . 'banque.csv', $form->get('bankAccount')->getData());
3737
if ($this->compta->extraireComptaDepuisCSVBanque($importer)) {
3838
$this->audit->log('Chargement fichier banque');
39-
$_SESSION['flash'] = "Le fichier a été importé";
40-
$_SESSION['erreur'] = false;
4139
$this->addFlash('notice', "Le fichier a été importé");
4240
} else {
43-
$_SESSION['flash'] = "Le fichier n'a pas été importé. Le format est-il valide ?";
44-
$_SESSION['erreur'] = true;
4541
$this->addFlash('error', "Le fichier n'a pas été importé. Le format est-il valide ?");
4642
}
4743
unlink($this->uploadDir . 'banque.csv');
48-
return $this->redirect('/pages/administration/index.php?page=compta_journal&&action=lister');
44+
return $this->redirectToRoute('admin_accounting_journal_list');
4945
}
5046
}
5147

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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

Comments
 (0)