From b1969238d8fe6676cd5106573869755912c3217b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 30 Oct 2023 13:40:35 +1100 Subject: [PATCH] Fix edge case for invalid clien countries --- app/Services/Pdf/PdfConfiguration.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Services/Pdf/PdfConfiguration.php b/app/Services/Pdf/PdfConfiguration.php index fcca21481996..febe6d7d3ffe 100644 --- a/app/Services/Pdf/PdfConfiguration.php +++ b/app/Services/Pdf/PdfConfiguration.php @@ -181,7 +181,7 @@ class PdfConfiguration $this->entity_design_id = 'invoice_design_id'; $this->settings = $this->client->getMergedSettings(); $this->settings_object = $this->client; - $this->country = $this->client->country; + $this->country = $this->client->country ?? $this->client->company->country(); } elseif ($this->service->invitation instanceof QuoteInvitation) { $this->entity = $this->service->invitation->quote; $this->entity_string = 'quote'; @@ -191,7 +191,7 @@ class PdfConfiguration $this->entity_design_id = 'quote_design_id'; $this->settings = $this->client->getMergedSettings(); $this->settings_object = $this->client; - $this->country = $this->client->country; + $this->country = $this->client->country ?? $this->client->company->country(); } elseif ($this->service->invitation instanceof CreditInvitation) { $this->entity = $this->service->invitation->credit; $this->entity_string = 'credit'; @@ -201,7 +201,7 @@ class PdfConfiguration $this->entity_design_id = 'credit_design_id'; $this->settings = $this->client->getMergedSettings(); $this->settings_object = $this->client; - $this->country = $this->client->country; + $this->country = $this->client->country ?? $this->client->company->country(); } elseif ($this->service->invitation instanceof RecurringInvoiceInvitation) { $this->entity = $this->service->invitation->recurring_invoice; $this->entity_string = 'recurring_invoice'; @@ -211,7 +211,7 @@ class PdfConfiguration $this->entity_design_id = 'invoice_design_id'; $this->settings = $this->client->getMergedSettings(); $this->settings_object = $this->client; - $this->country = $this->client->country; + $this->country = $this->client->country ?? $this->client->company->country(); } elseif ($this->service->invitation instanceof PurchaseOrderInvitation) { $this->entity = $this->service->invitation->purchase_order; $this->entity_string = 'purchase_order'; @@ -223,7 +223,7 @@ class PdfConfiguration $this->settings = $this->vendor->company->settings; $this->settings_object = $this->vendor; $this->client = null; - $this->country = $this->vendor->country ?: $this->vendor->company->country(); + $this->country = $this->vendor->country ?? $this->vendor->company->country(); } else { throw new \Exception('Unable to resolve entity', 500); }