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.
This commit is contained in:
Dave Shoreman 2024-05-29 17:06:44 +01:00
parent e1d08d34bf
commit bd49aa1a15
No known key found for this signature in database
GPG Key ID: C920D1D63709F443

View File

@ -208,13 +208,19 @@ class PdfMock
*/ */
public function getStubVariables(): array public function getStubVariables(): array
{ {
// Although $this->mock is the Invoice/etc entity, we need the invitation to get company details. $entity_pattern = $this->entity_string.'_number_pattern';
$entity_number = $this->getFormattedEntityNumber( $entity_number = '0029';
$this->mock->invitation,
29, if (!empty($this->settings->{$entity_pattern})) {
$this->settings->counter_padding, // Although $this->mock is the Invoice/etc entity,
$this->settings->invoice_number_pattern // 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' => return ['values' =>
[ [