diff --git a/sources/AppBundle/Accounting/InvoicingPdfGenerator.php b/sources/AppBundle/Accounting/InvoicingPdfGenerator.php index 398cb45ce..c77c7e144 100644 --- a/sources/AppBundle/Accounting/InvoicingPdfGenerator.php +++ b/sources/AppBundle/Accounting/InvoicingPdfGenerator.php @@ -10,6 +10,7 @@ use AppBundle\Accounting\Model\Invoicing; use AppBundle\Accounting\Model\InvoicingDetail; use AppBundle\Compta\BankAccount\BankAccountFactory; +use Symfony\Component\String\Slugger\AsciiSlugger; class InvoicingPdfGenerator { @@ -105,12 +106,16 @@ public function generateQuotation(Invoicing $invoicing, ?string $path = null): s public function getInvoiceFilename(Invoicing $invoicing): string { - return 'Facture - ' . $invoicing->getCompany() . ' - ' . ($invoicing->getInvoiceDate() ? $invoicing->getInvoiceDate()->format('Y-m-d') : '') . '.pdf'; + $slugger = new AsciiSlugger(); + + return 'Facture - ' . $slugger->slug($invoicing->getCompany()) . ' - ' . ($invoicing->getInvoiceDate() ? $invoicing->getInvoiceDate()->format('Y-m-d') : '') . '.pdf'; } public function getQuotationFilename(Invoicing $invoicing): string { - return 'Devis - ' . $invoicing->getCompany() . ' - ' . ($invoicing->getQuotationDate() ? $invoicing->getQuotationDate()->format('Y-m-d') : '') . '.pdf'; + $slugger = new AsciiSlugger(); + + return 'Devis - ' . $slugger->slug($invoicing->getCompany()) . ' - ' . ($invoicing->getQuotationDate() ? $invoicing->getQuotationDate()->format('Y-m-d') : '') . '.pdf'; } private function buildPdf(\DateTimeImmutable $date, bool $isSubjectedToVat): PDF_Facture diff --git a/tests/behat/features/Admin/Tresorerie/DevisFactures.feature b/tests/behat/features/Admin/Tresorerie/DevisFactures.feature index af7c22e0d..d63e6fba4 100644 --- a/tests/behat/features/Admin/Tresorerie/DevisFactures.feature +++ b/tests/behat/features/Admin/Tresorerie/DevisFactures.feature @@ -143,14 +143,14 @@ Feature: Administration - Trésorerie - Devis/Facture When I follow "Devis" # Téléchargement du devis And I follow the button of tooltip "Télécharger le devis ESN dev en folie" - Then the response header "Content-disposition" should match '#attachment; filename="Devis - ESN dev en folie - (.*).pdf"#' + Then the response header "Content-disposition" should match '#attachment; filename="Devis - ESN-dev-en-folie - (.*).pdf"#' When I parse the pdf downloaded content Then The page "1" of the PDF should contain "ESN dev en folie" # Téléchargement de la facture When I go to "/admin/" And I follow "Factures" And I follow the button of tooltip "Télécharger la facture 2026-3" - Then the response header "Content-disposition" should match '#attachment; filename="Facture - ESN dev en folie - (.*).pdf"#' + Then the response header "Content-disposition" should match '#attachment; filename="Facture - ESN-dev-en-folie - (.*).pdf"#' When I parse the pdf downloaded content Then The page "1" of the PDF should contain "N° TVA Intracommunautaire : FR7612345" @@ -163,7 +163,7 @@ Feature: Administration - Trésorerie - Devis/Facture Then the ".content h2" element should contain "Liste des devis" And I should see "My company Ltd" And I follow the button of tooltip "Télécharger le devis My company Ltd" - Then the response header "Content-disposition" should match '#attachment; filename="Devis - My company Ltd - (.*).pdf"#' + Then the response header "Content-disposition" should match '#attachment; filename="Devis - My-company-Ltd - (.*).pdf"#' When I parse the pdf downloaded content Then The page "1" of the PDF should contain "0,00 €"