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
2 changes: 2 additions & 0 deletions sources/AppBundle/Accounting/Model/Invoicing.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use CCMBenchmark\Ting\Entity\NotifyProperty;
use CCMBenchmark\Ting\Entity\NotifyPropertyInterface;
use DateTime;
use Symfony\Component\Validator\Constraints as Assert;

class Invoicing implements NotifyPropertyInterface
{
Expand Down Expand Up @@ -39,6 +40,7 @@ class Invoicing implements NotifyPropertyInterface
private ?DateTime $paymentDate = null;
private ?InvoicingCurrency $currency = null;
/** @var InvoicingDetail[] */
#[Assert\Valid]
private array $details = [];

private ?float $price = null;
Expand Down
13 changes: 13 additions & 0 deletions sources/AppBundle/Accounting/Model/InvoicingDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,30 @@

use CCMBenchmark\Ting\Entity\NotifyProperty;
use CCMBenchmark\Ting\Entity\NotifyPropertyInterface;
use Symfony\Component\Validator\Constraints as Assert;

class InvoicingDetail implements NotifyPropertyInterface
{
use NotifyProperty;

private ?int $id = null;
private ?int $invoicingId = null;

#[Assert\NotBlank]
#[Assert\Length(max: 20)]
private ?string $reference = null;

#[Assert\NotBlank]
#[Assert\Length(max: 100)]
private ?string $designation = null;

#[Assert\NotBlank]
private ?float $quantity = null;

#[Assert\NotBlank]
private ?float $unitPrice = null;

#[Assert\NotBlank]
private ?float $tva = null;

public function getId(): ?int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use AppBundle\Accounting\Model\InvoicingDetail;
use AppBundle\Accounting\Model\Repository\InvoicingDetailRepository;
use AppBundle\Accounting\Model\Repository\InvoicingRepository;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -22,6 +23,7 @@ public function __construct(
private readonly InvoicingNumberGenerator $numberGenerator,
private readonly InvoicingDetailRepository $invoicingDetailRepository,
private readonly ProduitRepository $produitRepository,
private readonly LoggerInterface $logger,
) {}

public function __invoke(Request $request): Response
Expand All @@ -41,8 +43,9 @@ public function __invoke(Request $request): Response
$this->invoicingRepository->commit();
$this->addFlash('success', 'L\'écriture a été ajoutée');
return $this->redirectToRoute('admin_accounting_quotations_list');
} catch (\Exception) {
} catch (\Exception $e) {
$this->invoicingRepository->rollback();
$this->logger->error('Échec de l\'ajout d\'un devis : ' . $e->getMessage(), ['exception' => $e]);
$this->addFlash('error', 'L\'écriture n\'a pas pu être enregistrée');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use AppBundle\Accounting\Form\QuotationType;
use AppBundle\Accounting\Model\Repository\InvoicingDetailRepository;
use AppBundle\Accounting\Model\Repository\InvoicingRepository;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -18,6 +19,7 @@ public function __construct(
private readonly InvoicingRepository $invoicingRepository,
private readonly InvoicingDetailRepository $invoicingDetailRepository,
private readonly ProduitRepository $produitRepository,
private readonly LoggerInterface $logger,
) {}

public function __invoke(Request $request): Response
Expand Down Expand Up @@ -51,8 +53,9 @@ public function __invoke(Request $request): Response
$this->invoicingRepository->commit();
$this->addFlash('success', 'L\'écriture a été modifiée');
return $this->redirectToRoute('admin_accounting_quotations_list');
} catch (\Exception) {
} catch (\Exception $e) {
$this->invoicingRepository->rollback();
$this->logger->error('Échec de la modification d\'un devis : ' . $e->getMessage(), ['exception' => $e]);
$this->addFlash('error', 'L\'écriture n\'a pas pu être enregistrée');
}
}
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/accounting/quotation/form.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% form_theme form 'form_theme_admin.html.twig' %}
{% form_theme form 'admin/accounting/quotation/_form_theme.html.twig' %}

{{ form_start(form) }}
{{ form_errors(form) }}
Expand Down
Loading