Fix edge case for invalid clien countries

This commit is contained in:
David Bomba 2023-10-30 13:40:35 +11:00
parent e0ae08475b
commit b1969238d8

View File

@ -181,7 +181,7 @@ class PdfConfiguration
$this->entity_design_id = 'invoice_design_id'; $this->entity_design_id = 'invoice_design_id';
$this->settings = $this->client->getMergedSettings(); $this->settings = $this->client->getMergedSettings();
$this->settings_object = $this->client; $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) { } elseif ($this->service->invitation instanceof QuoteInvitation) {
$this->entity = $this->service->invitation->quote; $this->entity = $this->service->invitation->quote;
$this->entity_string = 'quote'; $this->entity_string = 'quote';
@ -191,7 +191,7 @@ class PdfConfiguration
$this->entity_design_id = 'quote_design_id'; $this->entity_design_id = 'quote_design_id';
$this->settings = $this->client->getMergedSettings(); $this->settings = $this->client->getMergedSettings();
$this->settings_object = $this->client; $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) { } elseif ($this->service->invitation instanceof CreditInvitation) {
$this->entity = $this->service->invitation->credit; $this->entity = $this->service->invitation->credit;
$this->entity_string = 'credit'; $this->entity_string = 'credit';
@ -201,7 +201,7 @@ class PdfConfiguration
$this->entity_design_id = 'credit_design_id'; $this->entity_design_id = 'credit_design_id';
$this->settings = $this->client->getMergedSettings(); $this->settings = $this->client->getMergedSettings();
$this->settings_object = $this->client; $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) { } elseif ($this->service->invitation instanceof RecurringInvoiceInvitation) {
$this->entity = $this->service->invitation->recurring_invoice; $this->entity = $this->service->invitation->recurring_invoice;
$this->entity_string = 'recurring_invoice'; $this->entity_string = 'recurring_invoice';
@ -211,7 +211,7 @@ class PdfConfiguration
$this->entity_design_id = 'invoice_design_id'; $this->entity_design_id = 'invoice_design_id';
$this->settings = $this->client->getMergedSettings(); $this->settings = $this->client->getMergedSettings();
$this->settings_object = $this->client; $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) { } elseif ($this->service->invitation instanceof PurchaseOrderInvitation) {
$this->entity = $this->service->invitation->purchase_order; $this->entity = $this->service->invitation->purchase_order;
$this->entity_string = 'purchase_order'; $this->entity_string = 'purchase_order';
@ -223,7 +223,7 @@ class PdfConfiguration
$this->settings = $this->vendor->company->settings; $this->settings = $this->vendor->company->settings;
$this->settings_object = $this->vendor; $this->settings_object = $this->vendor;
$this->client = null; $this->client = null;
$this->country = $this->vendor->country ?: $this->vendor->company->country(); $this->country = $this->vendor->country ?? $this->vendor->company->country();
} else { } else {
throw new \Exception('Unable to resolve entity', 500); throw new \Exception('Unable to resolve entity', 500);
} }