Remove duplicate e invoice stub

This commit is contained in:
David Bomba 2023-09-26 08:39:29 +10:00
parent c9917e78ed
commit 1b63e7c018
3 changed files with 10 additions and 15 deletions

View File

@ -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")]]);
}
// }
});
}

View File

@ -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"));
}

View File

@ -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);