From bd49aa1a159b9cb3e5cd5a8bbcb43df192160712 Mon Sep 17 00:00:00 2001 From: Dave Shoreman Date: Wed, 29 May 2024 17:06:44 +0100 Subject: [PATCH] Ensure correct pattern for non-invoice entities A simple `in_array` check would work here, except there are a lot of valid keys for the number pattern settings so it's easier this way. --- app/Services/Pdf/PdfMock.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/Services/Pdf/PdfMock.php b/app/Services/Pdf/PdfMock.php index 503472d2accf..495a7e6a812b 100644 --- a/app/Services/Pdf/PdfMock.php +++ b/app/Services/Pdf/PdfMock.php @@ -208,13 +208,19 @@ class PdfMock */ public function getStubVariables(): array { - // Although $this->mock is the Invoice/etc entity, we need the invitation to get company details. - $entity_number = $this->getFormattedEntityNumber( - $this->mock->invitation, - 29, - $this->settings->counter_padding, - $this->settings->invoice_number_pattern - ); + $entity_pattern = $this->entity_string.'_number_pattern'; + $entity_number = '0029'; + + if (!empty($this->settings->{$entity_pattern})) { + // Although $this->mock is the Invoice/etc entity, + // we need the invitation to get company details. + $entity_number = $this->getFormattedEntityNumber( + $this->mock->invitation, + (int) $entity_number, + $this->settings->counter_padding, + $this->settings->{$entity_pattern}, + ); + } return ['values' => [