Add support for adding new standards to email

This commit is contained in:
Lars Kusch 2024-03-10 16:41:34 +01:00
parent 86039c2aed
commit d8d70f0227
2 changed files with 39 additions and 6 deletions

View File

@ -158,15 +158,46 @@ class TemplateEmail extends Mailable
}
}
if ($this->invitation && $this->invitation->invoice && $this->invitation->invoice->client->getSetting('enable_e_invoice') && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
$xml_string = $this->invitation->invoice->service()->getEInvoice($this->invitation->contact);
if ($this->invitation->invoice) {
if ($this->invitation && $this->invitation->invoice && $this->invitation->invoice->client->getSetting('enable_e_invoice') && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
$xml_string = $this->invitation->invoice->service()->getEInvoice($this->invitation->contact);
if ($xml_string) {
$this->attachData($xml_string, $this->invitation->invoice->getEFileName("xml"));
}
if($xml_string) {
$this->attachData($xml_string, $this->invitation->invoice->getEFileName("xml"));
}
}
elseif ($this->invitation->credit){
if ($this->invitation && $this->invitation->credit && $this->invitation->credit->client->getSetting('enable_e_invoice') && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
$xml_string = $this->invitation->credit->service()->getECredit($this->invitation->contact);
if ($xml_string) {
$this->attachData($xml_string, $this->invitation->credit->getEFileName("xml"));
}
}
}
elseif ($this->invitation->quote){
if ($this->invitation && $this->invitation->quote && $this->invitation->quote->client->getSetting('enable_e_invoice') && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
$xml_string = $this->invitation->quote->service()->getEQuote($this->invitation->contact);
if ($xml_string) {
$this->attachData($xml_string, $this->invitation->quote->getEFileName("xml"));
}
}
}
elseif ($this->invitation->purchase_order){
if ($this->invitation && $this->invitation->purchase_order && $this->invitation->purchase_order->client->getSetting('enable_e_invoice') && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
$xml_string = $this->invitation->purchase_order->service()->getEPurchaseOrder($this->invitation->contact);
if ($xml_string) {
$this->attachData($xml_string, $this->invitation->purchase_order->getEFileName("xml"));
}
}
}
return $this;
}
}

View File

@ -17,6 +17,8 @@ use App\Jobs\Invoice\CreateUbl;
use App\Models\Account;
use App\Models\Expense;
use App\Models\Invoice;
use App\Models\PurchaseOrder;
use App\Models\Quote;
use App\Models\Task;
use App\Utils\Ninja;
use App\Utils\Traits\MakesHash;
@ -318,7 +320,7 @@ class EmailDefaults
}
}
/** E-Invoice xml file */
if ($this->email->email_object->settings->enable_e_invoice && $this->email->email_object->entity instanceof Invoice) {
if ($this->email->email_object->settings->enable_e_invoice && ! $this->email->email_object->entity instanceof PurchaseOrder) {
$xml_string = $this->email->email_object->entity->service()->getEInvoice();
if($xml_string) {