From 1b63e7c01895e26b3028ecb80c12b874419395a1 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 26 Sep 2023 08:39:29 +1000 Subject: [PATCH] Remove duplicate e invoice stub --- app/Mail/Engine/PaymentEmailEngine.php | 13 ++++++------- app/Mail/TemplateEmail.php | 4 ---- app/Services/Invoice/EInvoice/ZugferdEInvoice.php | 8 ++++---- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/app/Mail/Engine/PaymentEmailEngine.php b/app/Mail/Engine/PaymentEmailEngine.php index 400bef9b0618..fad158f7214a 100644 --- a/app/Mail/Engine/PaymentEmailEngine.php +++ b/app/Mail/Engine/PaymentEmailEngine.php @@ -107,16 +107,15 @@ class PaymentEmailEngine extends BaseEmailEngine }); } - if($this->client->getSetting('enable_e_invoice')) - { + // if($this->client->getSetting('enable_e_invoice')) + // { - $e_invoice_filepath = $invoice->service()->getEInvoice($this->contact); + // $e_invoice_filepath = $invoice->service()->getEInvoice($this->contact); - if(Storage::disk(config('filesystems.default'))->exists($e_invoice_filepath)) { - $this->setAttachments([['path' => Storage::disk(config('filesystems.default'))->path($e_invoice_filepath), 'name' => $invoice->getFileName("xml"), 'mime' => null]]); - } + // if($e_invoice_filepath && strlen($e_invoice_filepath) > 1) + // $this->setAttachments([['file' => base64_encode($e_invoice_filepath), 'name' => $invoice->getFileName("xml")]]); - } + // } }); } diff --git a/app/Mail/TemplateEmail.php b/app/Mail/TemplateEmail.php index 2fcd68874a81..984029cefe26 100644 --- a/app/Mail/TemplateEmail.php +++ b/app/Mail/TemplateEmail.php @@ -148,8 +148,6 @@ class TemplateEmail extends Mailable if ($this->invitation && $this->invitation->invoice && $settings->ubl_email_attachment && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) { $ubl_string = (new CreateUbl($this->invitation->invoice))->handle(); - nlog("template {$ubl_string}"); - if ($ubl_string) { $this->attachData($ubl_string, $this->invitation->invoice->getFileName('xml')); } @@ -158,8 +156,6 @@ 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); - nlog("template {$xml_string}"); - if($xml_string) { $this->attachData($xml_string, $this->invitation->invoice->getEFileName("xml")); } diff --git a/app/Services/Invoice/EInvoice/ZugferdEInvoice.php b/app/Services/Invoice/EInvoice/ZugferdEInvoice.php index 0410422a4d7e..7bc153c30fd2 100644 --- a/app/Services/Invoice/EInvoice/ZugferdEInvoice.php +++ b/app/Services/Invoice/EInvoice/ZugferdEInvoice.php @@ -49,22 +49,22 @@ class ZugferdEInvoice extends AbstractService $this->xrechnung = ZugferdDocumentBuilder::CreateNew($profile); $this->xrechnung - ->setDocumentSupplyChainEvent(date_create($this->invoice->date)) + ->setDocumentSupplyChainEvent(date_create($this->invoice->date ?? now()->format('Y-m-d'))) ->setDocumentSeller($company->getSetting('name')) ->setDocumentSellerAddress($company->getSetting("address1"), $company->getSetting("address2"), "", $company->getSetting("postal_code"), $company->getSetting("city"), $company->country()->iso_3166_2, $company->getSetting("state")) ->setDocumentSellerContact($this->invoice->user->first_name." ".$this->invoice->user->last_name, "", $this->invoice->user->phone, "", $this->invoice->user->email) ->setDocumentBuyer($client->name, $client->number) ->setDocumentBuyerAddress($client->address1, "", "", $client->postal_code, $client->city, $client->country->iso_3166_2, $client->state) ->setDocumentBuyerContact($client->primary_contact()->first()->first_name . " " . $client->primary_contact()->first()->last_name, "", $client->primary_contact()->first()->phone, "", $client->primary_contact()->first()->email) - ->addDocumentPaymentTerm(ctrans("texts.xinvoice_payable", ['payeddue' => date_create($this->invoice->date)->diff(date_create($this->invoice->due_date))->format("%d"), 'paydate' => $this->invoice->due_date])); + ->addDocumentPaymentTerm(ctrans("texts.xinvoice_payable", ['payeddue' => date_create($this->invoice->date ?? now()->format('Y-m-d'))->diff(date_create($this->invoice->due_date ?? now()->format('Y-m-d')))->format("%d"), 'paydate' => $this->invoice->due_date])); if (!empty($this->invoice->public_notes)) { $this->xrechnung->addDocumentNote($this->invoice->public_notes); } if (empty($this->invoice->number)){ - $this->xrechnung->setDocumentInformation("DRAFT", "380", date_create($this->invoice->date), $this->invoice->client->getCurrencyCode()); + $this->xrechnung->setDocumentInformation("DRAFT", "380", date_create($this->invoice->date ?? now()->format('Y-m-d')), $this->invoice->client->getCurrencyCode()); } else { - $this->xrechnung->setDocumentInformation($this->invoice->number, "380", date_create($this->invoice->date), $this->invoice->client->getCurrencyCode()); + $this->xrechnung->setDocumentInformation($this->invoice->number, "380", date_create($this->invoice->date ?? now()->format('Y-m-d')), $this->invoice->client->getCurrencyCode()); } if (!empty($this->invoice->po_number)) { $this->xrechnung->setDocumentBuyerOrderReferencedDocument($this->invoice->po_number);