From 5eaea3ad594fdcfbc4d50ac78e80060d56a23ced Mon Sep 17 00:00:00 2001 From: gohil jayvirsinh Date: Mon, 28 Jun 2021 07:49:27 +0000 Subject: [PATCH] solve empty address issue on pdf --- app/Models/Estimate.php | 12 ++++++++++++ app/Models/Invoice.php | 12 ++++++++++++ app/Models/Payment.php | 8 ++++++++ 3 files changed, 32 insertions(+) diff --git a/app/Models/Estimate.php b/app/Models/Estimate.php index e05716d6..fade55e5 100644 --- a/app/Models/Estimate.php +++ b/app/Models/Estimate.php @@ -449,6 +449,10 @@ class Estimate extends Model implements HasMedia public function getCompanyAddress() { + if ($this->company && (! $this->company->address()->exists())) { + return false; + } + $format = CompanySetting::getSetting('estimate_company_address_format', $this->company_id); return $this->getFormattedString($format); @@ -456,6 +460,10 @@ class Estimate extends Model implements HasMedia public function getCustomerShippingAddress() { + if ($this->user && (! $this->user->shippingAddress()->exists())) { + return false; + } + $format = CompanySetting::getSetting('estimate_shipping_address_format', $this->company_id); return $this->getFormattedString($format); @@ -463,6 +471,10 @@ class Estimate extends Model implements HasMedia public function getCustomerBillingAddress() { + if ($this->user && (! $this->user->billingAddress()->exists())) { + return false; + } + $format = CompanySetting::getSetting('estimate_billing_address_format', $this->company_id); return $this->getFormattedString($format); diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 9a69b321..0f8c339d 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -541,6 +541,10 @@ class Invoice extends Model implements HasMedia public function getCompanyAddress() { + if ($this->company && (! $this->company->address()->exists())) { + return false; + } + $format = CompanySetting::getSetting('invoice_company_address_format', $this->company_id); return $this->getFormattedString($format); @@ -548,6 +552,10 @@ class Invoice extends Model implements HasMedia public function getCustomerShippingAddress() { + if ($this->user && (! $this->user->shippingAddress()->exists())) { + return false; + } + $format = CompanySetting::getSetting('invoice_shipping_address_format', $this->company_id); return $this->getFormattedString($format); @@ -555,6 +563,10 @@ class Invoice extends Model implements HasMedia public function getCustomerBillingAddress() { + if ($this->user && (! $this->user->billingAddress()->exists())) { + return false; + } + $format = CompanySetting::getSetting('invoice_billing_address_format', $this->company_id); return $this->getFormattedString($format); diff --git a/app/Models/Payment.php b/app/Models/Payment.php index 645238d1..29326221 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -399,6 +399,10 @@ class Payment extends Model implements HasMedia public function getCompanyAddress() { + if ($this->company && (! $this->company->address()->exists())) { + return false; + } + $format = CompanySetting::getSetting('payment_company_address_format', $this->company_id); return $this->getFormattedString($format); @@ -406,6 +410,10 @@ class Payment extends Model implements HasMedia public function getCustomerBillingAddress() { + if ($this->user && (! $this->user->billingAddress()->exists())) { + return false; + } + $format = CompanySetting::getSetting('payment_from_customer_address_format', $this->company_id); return $this->getFormattedString($format);