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
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
{
case Debit = 1;
case Credit = 2;
case All = 0;
}
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