diff --git a/src/Service/Pdf/InvoiceRenderer.php b/src/Service/Pdf/InvoiceRenderer.php index e9614ea..5051001 100644 --- a/src/Service/Pdf/InvoiceRenderer.php +++ b/src/Service/Pdf/InvoiceRenderer.php @@ -37,7 +37,9 @@ class InvoiceRenderer extends AbstractPdfRenderer // Invoice number $pdf->SetFont('Arial', '', 12); - $number = $assignment->getEffectivePeriod()->start->format('d/m/Y'); + $date = $assignment->getEffectivePeriod()->start->format('d/m/Y'); + $suffix = $assignment->getId(); + $number = sprintf('%s-%05d', $date, $suffix); $pdf->Text(85, 116, $number); $pdf->SetFont('Arial', '', 10); diff --git a/tests/Service/Pdf/InvoiceRendererTest.php b/tests/Service/Pdf/InvoiceRendererTest.php index 66269f1..0f79c6d 100644 --- a/tests/Service/Pdf/InvoiceRendererTest.php +++ b/tests/Service/Pdf/InvoiceRendererTest.php @@ -16,6 +16,7 @@ use App\Entity\User; use App\Service\Pdf\InvoiceApprover; use App\Service\Pdf\InvoiceRenderer; use App\Service\Pdf\Pdf; +use Carbon\CarbonPeriod; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Contracts\Translation\TranslatorInterface; @@ -81,12 +82,12 @@ class InvoiceRendererTest extends WebTestCase ->setEmail('carmen.baer@ep-reisen.de') ; - $assignment = new Assignment(); - $assignment - ->setDestination($destination) - ->setJobProfile($jobProfile) - ->setContact($contact) - ; + $assignment = $this->createMock(Assignment::class); + $assignment->method('getEffectivePeriod')->willReturn(CarbonPeriod::create('2025-02-01', '2025-02-08')); + $assignment->method('getId')->willReturn(1234); + $assignment->method('getDestination')->willReturn($destination); + $assignment->method('getJobProfile')->willReturn($jobProfile); + $assignment->method('getContact')->willReturn($contact); $application = new Application($assignment, $teamer); $disposition = new Disposition($application);