merge ubl_email_attachment for einvoicing

This commit is contained in:
David Bomba 2024-07-17 11:12:33 +10:00
parent 42a68979b6
commit 092c3bfbce
2 changed files with 11 additions and 6 deletions

View File

@ -24,12 +24,17 @@ class TemplateEmail extends Mailable
{ {
private $build_email; private $build_email;
private $client;
/** @var \App\Models\Client $client */
private $client;
/** @var \App\Models\ClientContact | \App\Models\VendorContact $contact */
private $contact; private $contact;
/** @var \App\Models\Company $company */
private $company; private $company;
/** @var \App\Models\InvoiceInvitation | \App\Models\QuoteInvitation | \App\Models\CreditInvitation | \App\Models\PurchaseOrderInvitation | \App\Models\RecurringInvoiceInvitation | null $invitation */
private $invitation; private $invitation;
public function __construct($build_email, ClientContact $contact, $invitation = null) public function __construct($build_email, ClientContact $contact, $invitation = null)
@ -167,7 +172,7 @@ class TemplateEmail extends Mailable
} }
if ($this->invitation->invoice) { if ($this->invitation->invoice) { //@phpstan-ignore-line
if ($this->invitation->invoice->client->getSetting('enable_e_invoice') && $this->invitation->invoice->client->getSetting('ubl_email_attachment') && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) { if ($this->invitation->invoice->client->getSetting('enable_e_invoice') && $this->invitation->invoice->client->getSetting('ubl_email_attachment') && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
$xml_string = $this->invitation->invoice->service()->getEInvoice($this->invitation->contact); $xml_string = $this->invitation->invoice->service()->getEInvoice($this->invitation->contact);
@ -176,7 +181,7 @@ class TemplateEmail extends Mailable
} }
} }
} elseif ($this->invitation->credit) { } elseif ($this->invitation->credit) {//@phpstan-ignore-line
if ($this->invitation->credit->client->getSetting('enable_e_invoice') && $this->invitation->invoice->client->getSetting('ubl_email_attachment') && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) { if ($this->invitation->credit->client->getSetting('enable_e_invoice') && $this->invitation->invoice->client->getSetting('ubl_email_attachment') && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
$xml_string = $this->invitation->credit->service()->getECredit($this->invitation->contact); $xml_string = $this->invitation->credit->service()->getECredit($this->invitation->contact);
@ -185,7 +190,7 @@ class TemplateEmail extends Mailable
} }
} }
} elseif ($this->invitation->quote) { } elseif ($this->invitation->quote) {//@phpstan-ignore-line
if ($this->invitation->quote->client->getSetting('enable_e_invoice') && $this->invitation->invoice->client->getSetting('ubl_email_attachment') && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) { if ($this->invitation->quote->client->getSetting('enable_e_invoice') && $this->invitation->invoice->client->getSetting('ubl_email_attachment') && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
$xml_string = $this->invitation->quote->service()->getEQuote($this->invitation->contact); $xml_string = $this->invitation->quote->service()->getEQuote($this->invitation->contact);

View File

@ -431,11 +431,11 @@ class Activity extends StaticModel
} }
if($this->client) { if($this->client) {
$replacements['client'] = ['label' => $this?->client?->present()->name() ?? '', 'hashed_id' => $this->client->hashed_id ?? '']; $replacements['client'] = ['label' => $this->client?->present()->name() ?? '', 'hashed_id' => $this->client->hashed_id ?? ''];
} }
if($this->vendor) { if($this->vendor) {
$replacements['vendor'] = ['label' => $this?->vendor?->present()->name() ?? '', 'hashed_id' => $this->vendor->hashed_id ?? '']; $replacements['vendor'] = ['label' => $this->vendor?->present()->name() ?? '', 'hashed_id' => $this->vendor->hashed_id ?? ''];
} }
if($this->activity_type_id == 4 && $this->recurring_invoice) { if($this->activity_type_id == 4 && $this->recurring_invoice) {