Skip to content
Merged
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
28 changes: 28 additions & 0 deletions templates/admin/accounting/quotation/_form_theme.html.twig

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Est-ce qu'il y a une raison pour ne pas avoir mis ça dans le thème global ?

Il y a d'autres formulaires maintenant avec des ajouts en js comme ça (les interviews et les produits par exemple).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

c'était pour réduire l'impact dans un premier temps. Par la suite je comptais passer la correction du rendu des erreur sur le form theme global

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ça me va :)

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% use 'form_theme_admin.html.twig' %}

{%- block form_row -%}
<div class="inline fields ui grid">
{{ form_label(form) }}
<div class="field nine wide column" style="flex-wrap: wrap;">
<div class="ui input" style="max-width: none; width: 100%;">
{{ form_widget(form) }}
</div>
{{ form_errors(form) }}
{% if help is not empty %}
<div style="flex-basis: 100%;">
<i>{{ form_help(form) }}</i>
</div>
{% endif %}
</div>
</div>
{%- endblock form_row -%}

{%- block form_errors -%}
{%- if errors|length > 0 -%}
<div class="ui pointing red basic label" style="flex-basis: 100%; margin-top: 0.5em;">
{%- for error in errors -%}
{{ error.message }}{% if not loop.last %}<br>{% endif %}
{%- endfor -%}
</div>
{%- endif -%}
{%- endblock form_errors -%}
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