From f794a56f9864855509ed003a5163957afdab99ae Mon Sep 17 00:00:00 2001 From: vgreb Date: Sat, 17 Jan 2026 23:07:43 +0100 Subject: [PATCH] =?UTF-8?q?Refonte=20-=20Tr=C3=A9sorerie=20-=20Journal=20-?= =?UTF-8?q?=20List?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/config/packages/backoffice_menu.yaml | 3 + .../routing/admin_accounting/journal.yml | 5 + .../AppBundle/Accounting/OperationType.php | 12 + .../Journal/AddTransactionAction.php | 6 +- .../Accounting/Journal/AllocateAction.php | 4 +- .../Admin/Accounting/Journal/DeleteAction.php | 8 +- .../Journal/EditTransactionAction.php | 2 +- .../Admin/Accounting/Journal/ImportAction.php | 6 +- .../Admin/Accounting/Journal/ListAction.php | 51 +++ .../invoicing-period.form.html.twig | 2 +- .../admin/accounting/journal/list.html.twig | 402 ++++++++++++++++++ .../features/Admin/Tresorerie/Journal.feature | 2 +- .../Admin/Tresorerie/JournalImport.feature | 24 +- 13 files changed, 494 insertions(+), 33 deletions(-) create mode 100644 sources/AppBundle/Accounting/OperationType.php create mode 100644 sources/AppBundle/Controller/Admin/Accounting/Journal/ListAction.php create mode 100644 templates/admin/accounting/journal/list.html.twig diff --git a/app/config/packages/backoffice_menu.yaml b/app/config/packages/backoffice_menu.yaml index 86a668798..2f03f1fee 100644 --- a/app/config/packages/backoffice_menu.yaml +++ b/app/config/packages/backoffice_menu.yaml @@ -226,10 +226,13 @@ parameters: - admin_accounting_invoices_list compta_journal: nom: 'Journal' + url: '/admin/accounting/journal/list' niveau: 'ROLE_ADMIN' extra_routes: + - admin_accounting_journal_list - admin_accounting_journal_add - admin_accounting_journal_edit + - admin_accounting_journal_import compta_conf_evenement: nom: 'Configuration' niveau: 'ROLE_ADMIN' diff --git a/app/config/routing/admin_accounting/journal.yml b/app/config/routing/admin_accounting/journal.yml index fee0ba74c..061668a38 100644 --- a/app/config/routing/admin_accounting/journal.yml +++ b/app/config/routing/admin_accounting/journal.yml @@ -1,3 +1,8 @@ +admin_accounting_journal_list: + path: /list + defaults: + _controller: AppBundle\Controller\Admin\Accounting\Journal\ListAction + admin_accounting_journal_delete: path: /delete/{id} defaults: diff --git a/sources/AppBundle/Accounting/OperationType.php b/sources/AppBundle/Accounting/OperationType.php new file mode 100644 index 000000000..349230b55 --- /dev/null +++ b/sources/AppBundle/Accounting/OperationType.php @@ -0,0 +1,12 @@ +isSubmitted() && $form->isValid()) { $this->transactionRepository->save($transaction); $this->audit->log("Ajout d'une écriture"); - $_SESSION['flash']['message'] = "l'écriture a été ajoutée"; - $_SESSION['flash']['error'] = false; - $this->addFlash('notice', "l'écriture a été ajoutée"); - return $this->redirect('/pages/administration/index.php?page=compta_journal&action=lister#L' . $transaction->getId()); + $this->addFlash('notice', "L'écriture a été ajoutée"); + return $this->redirect('/admin/accounting/journal/list#L' . $transaction->getId()); } return $this->render('admin/accounting/journal/add.html.twig', [ diff --git a/sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php b/sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php index 1706eb129..c14ba1828 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Journal/AllocateAction.php @@ -50,9 +50,7 @@ public function __invoke(Request $request, int $id): RedirectResponse $transaction->setAmount($transaction->getAmount() - $totalAmount); $this->transactionRepository->save($transaction); - $_SESSION['flash'] = "L'écriture a été ventilée"; - $_SESSION['erreur'] = false; $this->addFlash('notice', "L'écriture a été ventilée"); - return $this->redirect('/pages/administration/index.php?page=compta_journal#journal-ligne-' . $lastId); + return $this->redirect('/admin/accounting/journal/list#journal-ligne-' . $lastId); } } diff --git a/sources/AppBundle/Controller/Admin/Accounting/Journal/DeleteAction.php b/sources/AppBundle/Controller/Admin/Accounting/Journal/DeleteAction.php index d2bbc9a7d..65ab0014a 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Journal/DeleteAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Journal/DeleteAction.php @@ -22,17 +22,13 @@ public function __invoke(Request $request, int $id): Response { $accounting = $this->transactionRepository->get($id); if (!$accounting instanceof Transaction) { - $_SESSION['flash'] = "Une erreur est survenue lors de la suppression de l'écriture"; - $_SESSION['erreur'] = true; $this->addFlash('error', "Une erreur est survenue lors de la suppression de l'écriture"); - return $this->redirect('/pages/administration/index.php?page=compta_journal'); + return $this->redirectToRoute('admin_accounting_journal_list'); } $this->transactionRepository->delete($accounting); $this->audit->log("Suppression de l'écriture {$id}"); - $_SESSION['flash'] = "L'écriture a été supprimée"; - $_SESSION['erreur'] = false; $this->addFlash('notice', "L'écriture a été supprimée"); - return $this->redirect('/pages/administration/index.php?page=compta_journal'); + return $this->redirectToRoute('admin_accounting_journal_list'); } } diff --git a/sources/AppBundle/Controller/Admin/Accounting/Journal/EditTransactionAction.php b/sources/AppBundle/Controller/Admin/Accounting/Journal/EditTransactionAction.php index 4ef3889fd..c32e52a56 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Journal/EditTransactionAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Journal/EditTransactionAction.php @@ -46,7 +46,7 @@ public function __invoke(Request $request, int $id): Response if ($submitAndPassButton instanceof SubmitButton && $submitAndPassButton->isClicked()) { return $this->redirectToRoute('admin_accounting_journal_edit', ['id' => $nextTransaction->getId()]); } else { - return $this->redirect('/pages/administration/index.php?page=compta_journal&action=lister#L' . $transaction->getId()); + return $this->redirect('/admin/accounting/journal/list#L' . $transaction->getId()); } } return $this->render('admin/accounting/journal/edit.html.twig', [ diff --git a/sources/AppBundle/Controller/Admin/Accounting/Journal/ImportAction.php b/sources/AppBundle/Controller/Admin/Accounting/Journal/ImportAction.php index c99983be5..db81f3aac 100644 --- a/sources/AppBundle/Controller/Admin/Accounting/Journal/ImportAction.php +++ b/sources/AppBundle/Controller/Admin/Accounting/Journal/ImportAction.php @@ -36,16 +36,12 @@ public function __invoke(Request $request): Response $importer = $this->importerFactory->create($this->uploadDir . 'banque.csv', $form->get('bankAccount')->getData()); if ($this->compta->extraireComptaDepuisCSVBanque($importer)) { $this->audit->log('Chargement fichier banque'); - $_SESSION['flash'] = "Le fichier a été importé"; - $_SESSION['erreur'] = false; $this->addFlash('notice', "Le fichier a été importé"); } else { - $_SESSION['flash'] = "Le fichier n'a pas été importé. Le format est-il valide ?"; - $_SESSION['erreur'] = true; $this->addFlash('error', "Le fichier n'a pas été importé. Le format est-il valide ?"); } unlink($this->uploadDir . 'banque.csv'); - return $this->redirect('/pages/administration/index.php?page=compta_journal&&action=lister'); + return $this->redirectToRoute('admin_accounting_journal_list'); } } diff --git a/sources/AppBundle/Controller/Admin/Accounting/Journal/ListAction.php b/sources/AppBundle/Controller/Admin/Accounting/Journal/ListAction.php new file mode 100644 index 000000000..1933428af --- /dev/null +++ b/sources/AppBundle/Controller/Admin/Accounting/Journal/ListAction.php @@ -0,0 +1,51 @@ +query->has('periodId') ? $request->query->getInt('periodId') : null; + $period = $this->invoicingPeriodRepository->getCurrentPeriod($periodId); + $formPeriod = $this->createForm(InvoicingPeriodType::class, $period); + $periods = $this->invoicingPeriodRepository->getAll(); + $withReconciled = $request->query->getBoolean('with_reconciled'); + $type = OperationType::from($request->query->getInt('type')); + + $transactions = $this->transactionRepository->getEntriesPerInvoicingPeriod($period, !$withReconciled, $type->value); + + return $this->render('admin/accounting/journal/list.html.twig', [ + 'periods' => $periods, + 'periodId' => $period->getId(), + 'formPeriod' => $formPeriod->createView(), + 'withReconciled' => $withReconciled, + 'type' => $type, + 'categories' => $this->categoryRepository->getAllSortedByName(), + 'events' => $this->eventRepository->getAllSortedByName(), + 'paymentTypes' => $this->paymentRepository->getAllSortedByName(), + 'transactions' => $transactions, + ]); + } +} diff --git a/templates/admin/accounting/invoicing-period.form.html.twig b/templates/admin/accounting/invoicing-period.form.html.twig index 71d447bfb..20925f975 100644 --- a/templates/admin/accounting/invoicing-period.form.html.twig +++ b/templates/admin/accounting/invoicing-period.form.html.twig @@ -1,5 +1,5 @@
-{{ form_start(form) }} +{{ form_start(form, {'name': 'periodId_selector'}) }}
diff --git a/templates/admin/accounting/journal/list.html.twig b/templates/admin/accounting/journal/list.html.twig new file mode 100644 index 000000000..b64316529 --- /dev/null +++ b/templates/admin/accounting/journal/list.html.twig @@ -0,0 +1,402 @@ +{% extends 'admin/base_with_header.html.twig' %} + +{#{% form_theme form 'form_theme_admin.html.twig' %}#} + +{% block content %} +

Journal

+ + + + {% include 'admin/accounting/invoicing-period.form.html.twig' with {form: formPeriod, url: path('admin_accounting_quotations_list')} %} + +
+ +
+ + + + + +
+ {% if transactions.count > 0 %} + + + + + + + + + + + + + + + + + {% for line in transactions %} + + + + + + + {% if line.idoperation == 1 %} + + + {% else %} + + + {% endif %} + + + + + + {% endfor %} + +
DateCompteEvenementCatégorieDescriptionDebitCréditReglementJustif ? 
{{ line.date_ecriture|format_date('short') }}{{ line.nom_compte }} + {% if line.evenement == 'A déterminer' %} +
+ +
+ {% else %} + {{ line.evenement }} + {% endif %} +
+ {% if line.categorie == 'A déterminer' %} +
+ +
+ {% else %} + {{ line.categorie }} + {% endif %} +
+ {{ line.description }} + -{{ line.montant|number_format(2, ',', ' ') }}+{{ line.montant|number_format(2, ',', ' ') }} + {% if line.reglement == 'A déterminer'%} +
+ +
+ {% else %} + {{ line.reglement }} + {% endif %} +
+ + + + +
+ +
+
+ + + + + + + + + + + + + + + + +
+ {% else %} +
+
+ + Aucune ecriture +
+
+ {% if withReconciled == false %} + Afficher aussi les entrées pointées + {% endif %} + +
+
+
+ {% endif %} + + + + + + + + +{% endblock %} + +{% block javascript %} +{{ parent() }} + +{% endblock %} diff --git a/tests/behat/features/Admin/Tresorerie/Journal.feature b/tests/behat/features/Admin/Tresorerie/Journal.feature index 4e1d8548b..d9902a629 100644 --- a/tests/behat/features/Admin/Tresorerie/Journal.feature +++ b/tests/behat/features/Admin/Tresorerie/Journal.feature @@ -105,7 +105,7 @@ Feature: Administration - Trésorerie - Journal @reloadDbWithTestData Scenario: Compte journal Suppression d'une transaction Given I am logged in as admin and on the Administration - When I am on "/pages/administration/index.php?page=compta_journal&id_periode=15" + When I am on "/admin/accounting/journal/list?periodId=15" And I follow the button of tooltip "Supprimer la fiche de PRLV SEPA ONLINE SAS SCW SCALEWAY " Then I should see "L'écriture a été supprimée" diff --git a/tests/behat/features/Admin/Tresorerie/JournalImport.feature b/tests/behat/features/Admin/Tresorerie/JournalImport.feature index 802857094..ad759c912 100644 --- a/tests/behat/features/Admin/Tresorerie/JournalImport.feature +++ b/tests/behat/features/Admin/Tresorerie/JournalImport.feature @@ -6,13 +6,13 @@ Feature: Administration - Trésorerie - Journal import When I follow "Journal" Then the ".content h2" element should contain "Journal" # On vérifie qu'on a aucune entrée pour la période - When I select "2019-01-01 - 2019-12-31" from "id_periode" - And I submit the form with name "forum" - Then the current URL should match "/id_periode=13/" - When I check "also_display_classifed_entries" + When I select "01/01/2019 - 31/12/2019" from "periodId" + And I submit the form with name "periodId_selector" + Then the current URL should match "/periodId=13/" + When I check "with_reconciled" And I press "Filtrer" - Then the current URL should match "/id_periode=13/" - And the current URL should match "/also_display_classifed_entries=on/" + Then the current URL should match "/periodId=13/" + And the current URL should match "/with_reconciled=on/" And I should see " Aucune ecriture" # On importe le fichier sur le crédit mutuel When I follow "Importer un fichier CSV" @@ -22,13 +22,13 @@ Feature: Administration - Trésorerie - Journal import And I press "Soumettre" Then I should see "Le fichier a été importé" # On vérifie que l'import s'est bien passé - When I select "2019-01-01 - 2019-12-31" from "id_periode" - And I submit the form with name "forum" - Then the current URL should match "/id_periode=13/" - When I check "also_display_classifed_entries" + When I select "01/01/2019 - 31/12/2019" from "periodId" + And I submit the form with name "periodId_selector" + Then the current URL should match "/periodId=13/" + When I check "with_reconciled" And I press "Filtrer" - Then the current URL should match "/id_periode=13/" - And the current URL should match "/also_display_classifed_entries=on/" + Then the current URL should match "/periodId=13/" + And the current URL should match "/with_reconciled=on/" And I should not see " Aucune ecriture" # Test meetup When I follow the button of tooltip "Modifier la ligne CB MEETUP ORG SUB FACT 190323 DONT FRAIS DE COMM. 1,89 EUR"