Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/config/packages/backoffice_menu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 5 additions & 0 deletions app/config/routing/admin_accounting/journal.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions sources/AppBundle/Accounting/OperationType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace AppBundle\Accounting;

enum OperationType: int
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je n'ai pas compris de suite que c'était pour mapper la query, et vu que ça ne sert qu'à ça, je suis pas sûr que ce soit le bon namespace.

Là on pourrait penser que c'est un enum global à toute la tréso je trouve.

Peut-être le déplacer dans le même namespace que le controller ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai effectivement créer un enum dédié parce qu'il manquait un cas dans \AppBundle\Compta\Importer\OperationType.

Je vais voir si je trouve une solution pour fusionner les deux sinon je déplacerai dans le namespace du controller.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Au final, j'utilise le nouvel enum dans les classes d'import des relevés bancaire.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. Alors je vais faire mon relou mais là ça pose un nouveau problème pour moi.

Avec cette fusion, on se retrouve avec le code de l'import qui pourrait être dans un état invalide (type = all) alors que ce n'est actuellement pas du tout possible grâce à l'enum limité. Et si on doit avoir du code qui ne peut être QUE débit ou crédit, et bien là il faudrait vérifier à chaque fois que la valeur n'est pas all.

Je comprend bien que les notions soient proches, mais elle ne sont pour autant pas les mêmes. Et j'insiste surtout pour avoir déjà fait ce genre de fusion sur des projets boulot et je l'ai regretté après.

En vrai, vu comment l'enum est utilisé dans le controller, tu pourrais même t'en passer et faire un simple assert :

$type = $request->query->getInt('type');
Webmozart\Assert\Assert::inArray($type, [0, 1, 2]);

Vu que de toute façon l'enum est retransformé en int immédiatement après, autant s'éviter la confusion non ?

{
case Debit = 1;
case Credit = 2;
case All = 0;
}
1 change: 1 addition & 0 deletions sources/AppBundle/Compta/Importer/CreditMutuel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace AppBundle\Compta\Importer;

use AppBundle\Accounting\OperationType;
use AppBundle\Model\ComptaCompte;

class CreditMutuel implements Importer
Expand Down
2 changes: 2 additions & 0 deletions sources/AppBundle/Compta/Importer/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace AppBundle\Compta\Importer;

use AppBundle\Accounting\OperationType;

final readonly class Operation
{
public function __construct(
Expand Down
11 changes: 0 additions & 11 deletions sources/AppBundle/Compta/Importer/OperationType.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ public function __invoke(Request $request): Response
if ($form->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', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

declare(strict_types=1);

namespace AppBundle\Controller\Admin\Accounting\Journal;

use AppBundle\Accounting\Entity\Repository\CategoryRepository;
use AppBundle\Accounting\Entity\Repository\EventRepository;
use AppBundle\Accounting\Entity\Repository\PaymentRepository;
use AppBundle\Accounting\Form\InvoicingPeriodType;
use AppBundle\Accounting\Model\Repository\InvoicingPeriodRepository;
use AppBundle\Accounting\Model\Repository\TransactionRepository;
use AppBundle\Accounting\OperationType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class ListAction extends AbstractController
{
public function __construct(
private readonly TransactionRepository $transactionRepository,
private readonly CategoryRepository $categoryRepository,
private readonly EventRepository $eventRepository,
private readonly PaymentRepository $paymentRepository,
private readonly InvoicingPeriodRepository $invoicingPeriodRepository,
) {}

public function __invoke(Request $request): Response
{
$periodId = $request->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,
]);
}
}
2 changes: 1 addition & 1 deletion templates/admin/accounting/invoicing-period.form.html.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="ui green segment">
{{ form_start(form) }}
{{ form_start(form, {'name': 'periodId_selector'}) }}
<div class="ui form">
<div class="inline fields">
<div class="field">
Expand Down
Loading
Loading