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: 1 addition & 1 deletion phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -8410,7 +8410,7 @@
$ignoreErrors[] = [
'message' => '#^Cannot access property \\$typePersonne on AppBundle\\\\MembershipFee\\\\Entity\\\\Cotisation\\|null\\.$#',
'identifier' => 'property.nonObject',
'count' => 2,
'count' => 3,
'path' => __DIR__ . '/sources/AppBundle/MembershipFee/MembershipFeeMailer.php',
];
$ignoreErrors[] = [
Expand Down
6 changes: 5 additions & 1 deletion sources/AppBundle/Accounting/InvoicingMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ public function sendInvoice(Invoicing $invoicing): bool
{
$invoiceNumber = $invoicing->getInvoiceNumber();

$sujet = "Facture AFUP";
$sujet = 'Facture AFUP';
$company = $invoicing->getCompany();
if ($company !== '') {
$sujet .= ' - ' . $company;
}

$corps = "Bonjour, \n\n";
$corps .= "Veuillez trouver ci-joint la facture correspondant à la participation au forum organisé par l'AFUP.\n";
Expand Down
9 changes: 8 additions & 1 deletion sources/AppBundle/MembershipFee/MembershipFeeMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,14 @@ public function envoyerFacture(int $idCotisation): bool
$numeroFacture = $this->pdfGenerator->genererFacture($idCotisation, $cheminFacture);
$pattern = str_replace(' ', '', $patternPrefix) . '_' . $numeroFacture . '_' . date('dmY', $membership->dateDebut->getTimestamp()) . '.pdf';

$message = new Message('Facture AFUP', null, new MailUser(
$subject = 'Facture AFUP';
if ($membership->typePersonne === MemberType::MemberCompany) {
$subject .= ' - ' . $company->getCompanyName();
} else {
$subject .= ' - ' . $contactPhysique['nom'] . ' ' . $contactPhysique['prenom'];
}

$message = new Message($subject, null, new MailUser(
$contactPhysique['email'],
sprintf('%s %s', $contactPhysique['prenom'], $contactPhysique['nom']),
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Feature: Administration - Trésorerie - Devis/Facture
Then I follow the button of tooltip "Envoyer la facture 2026-3 par mail"
And I should only receive the following emails:
| from | to | subject |
| <bonjour@afup.org> | <martine@ens-en-folie.biz>,<sponsors@afup.org> | Facture AFUP |
| <bonjour@afup.org> | <martine@ens-en-folie.biz>,<sponsors@afup.org> | Facture AFUP - ESN dev en folie |
Then the ".content .message" element should contain "La facture a été envoyée"
And I should see a green label "Envoyé"
# Lien de paiement
Expand Down
4 changes: 2 additions & 2 deletions tests/behat/features/MembersArea/Index.feature
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Feature: Espace membre, accueil
When I follow "Recevoir par mail"
And I should only receive the following emails:
| from | to | subject |
| <bonjour@afup.org> | <userexpire@yahoo.fr> | Facture AFUP |
| <bonjour@afup.org> | <userexpire@yahoo.fr> | Facture AFUP - Maurice Jean |

@reloadDbWithTestData @vat
Scenario: Test d'une facture de cotisation de personne physique avant 2024
Expand Down Expand Up @@ -173,7 +173,7 @@ Feature: Espace membre, accueil
When I follow "Recevoir par mail"
And I should only receive the following emails:
| from | to | subject |
| <bonjour@afup.org> | <raoul.dupont@mycorp.fr> | Facture AFUP |
| <bonjour@afup.org> | <raoul.dupont@mycorp.fr> | Facture AFUP - MyCorp |

@reloadDbWithTestData
Scenario: Si on est pas company manager de la personne morale, on ne peux pas télécharger la facture
Expand Down
23 changes: 23 additions & 0 deletions tests/unit/AppBundle/Accounting/InvoicingMailerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function testSendInvoiceAddsSponsorsCc(): void

$mailer->expects(self::once())->method('send')
->with(self::callback(static function (Message $message): bool {
self::assertSame('Facture AFUP - Société', $message->getSubject());
self::assertSame(1, count($message->getRecipients() ?? []));
$cc = $message->getCc();
self::assertCount(1, $cc);
Expand All @@ -39,4 +40,26 @@ public function testSendInvoiceAddsSponsorsCc(): void
$invoicingMailer = new InvoicingMailer($pdfGenerator, $mailer, sys_get_temp_dir() . '/');
$invoicingMailer->sendInvoice($invoicing);
}

public function testSendInvoiceSubjectWithoutCompany(): void
{
$invoicing = new Invoicing();
$invoicing->setInvoiceNumber('2026-001');
$invoicing->setEmail('contact@exemple.fr');
$invoicing->setLastname('Dupont');

/** @var Mailer&MockObject $mailer */
$mailer = $this->createMock(Mailer::class);
$pdfGenerator = $this->createStub(InvoicingPdfGenerator::class);

$mailer->expects(self::once())->method('send')
->with(self::callback(static function (Message $message): bool {
self::assertSame('Facture AFUP', $message->getSubject());

return true;
}));

$invoicingMailer = new InvoicingMailer($pdfGenerator, $mailer, sys_get_temp_dir() . '/');
$invoicingMailer->sendInvoice($invoicing);
}
}
Loading