mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 15:44:33 -04:00
Add Xinvoice to E-Mail
This commit is contained in:
parent
55bb506d4e
commit
f2c38bb948
1
.gitignore
vendored
1
.gitignore
vendored
@ -38,3 +38,4 @@ public/storage/test.pdf
|
||||
/Modules
|
||||
_ide_helper_models.php
|
||||
_ide_helper.php
|
||||
/composer.phar
|
||||
|
@ -21,9 +21,10 @@ class CreateXInvoice implements ShouldQueue
|
||||
|
||||
public Invoice $invoice;
|
||||
|
||||
public function __construct(Invoice $invoice)
|
||||
public function __construct(Invoice $invoice, bool $alterPDF)
|
||||
{
|
||||
$this->invoice = $invoice;
|
||||
$this->alterpdf = $alterPDF;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -294,13 +295,14 @@ class CreateXInvoice implements ShouldQueue
|
||||
$xrechnung->writeFile(Storage::disk($disk)->path($client->xinvoice_filepath($invoice->invitations->first()) . $invoice->getFileName("xml")));
|
||||
$filepath_pdf = $client->invoice_filepath($invoice->invitations->first()).$invoice->getFileName();
|
||||
|
||||
|
||||
if ($this->alterpdf){
|
||||
$file = Storage::disk($disk)->exists($filepath_pdf);
|
||||
if ($file) {
|
||||
$pdfBuilder = new ZugferdDocumentPdfBuilder($xrechnung, Storage::disk($disk)->path($filepath_pdf));
|
||||
$pdfBuilder->generateDocument();
|
||||
$pdfBuilder->saveDocument(Storage::disk($disk)->path($filepath_pdf));
|
||||
}
|
||||
}
|
||||
return $client->invoice_filepath($invoice->invitations->first()).$invoice->getFileName("xml");
|
||||
}
|
||||
private function getItemTaxable($item, $invoice_total): float
|
||||
|
@ -79,7 +79,7 @@ class ZipInvoices implements ShouldQueue
|
||||
$this->invoices->each(function ($invoice) {
|
||||
(new CreateEntityPdf($invoice->invitations()->first()))->handle();
|
||||
if ($this->company->use_xinvoice){
|
||||
(new CreateXInvoice($invoice))->handle();
|
||||
(new CreateXInvoice($invoice, false))->handle();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Services\Email;
|
||||
|
||||
use App\Jobs\Invoice\CreateXInvoice;
|
||||
use App\Models\Task;
|
||||
use App\Utils\Ninja;
|
||||
use App\Models\Quote;
|
||||
@ -289,6 +290,7 @@ class EmailDefaults
|
||||
$this->email->email_object->entity instanceof Quote ||
|
||||
$this->email->email_object->entity instanceof Credit)) {
|
||||
|
||||
// TODO: Alter this to include XInvoice
|
||||
$pdf = ((new CreateRawPdf($this->email->email_object->invitation, $this->email->company->db))->handle());
|
||||
|
||||
$this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode($pdf), 'name' => $this->email->email_object->entity->numberFormatter().'.pdf']]);
|
||||
@ -303,6 +305,11 @@ class EmailDefaults
|
||||
$this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode($ubl_string), 'name' => $this->email->email_object->entity->getFileName('xml')]]);
|
||||
}
|
||||
}
|
||||
/** XInvoice xml file */
|
||||
if ($this->email->email_object->company->use_xinvoice && $this->email->email_object->entity instanceof Invoice) {
|
||||
$xinvoice_path = (new CreateXInvoice($this->email->email_object->entity, false))->handle();
|
||||
$this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode(file_get_contents($xinvoice_path)), 'name' => explode(".", $this->email->email_object->entity->getFileName('xml'))[0]."-xinvoice.xml"]]);
|
||||
}
|
||||
|
||||
if(!$this->email->email_object->settings->document_email_attachment)
|
||||
return $this;
|
||||
|
@ -46,7 +46,7 @@ class GetInvoiceXInvoice extends AbstractService
|
||||
$file = Storage::disk($disk)->exists($file_path);
|
||||
|
||||
if (! $file) {
|
||||
$file_path = (new CreateXInvoice($this->invoice))->handle();
|
||||
$file_path = (new CreateXInvoice($this->invoice, false))->handle();
|
||||
}
|
||||
|
||||
return $file_path;
|
||||
|
@ -451,7 +451,7 @@ class InvoiceService
|
||||
(new CreateEntityPdf($invitation))->handle();
|
||||
if ($invitation instanceof InvoiceInvitation)
|
||||
{
|
||||
(new CreateXInvoice($invitation->invoice))->handle();
|
||||
(new CreateXInvoice($invitation->invoice, true))->handle();
|
||||
}
|
||||
});
|
||||
|
||||
@ -462,7 +462,7 @@ class InvoiceService
|
||||
CreateEntityPdf::dispatch($invitation);
|
||||
if ($invitation instanceof InvoiceInvitation)
|
||||
{
|
||||
CreateXInvoice::dispatch($invitation->invoice);
|
||||
CreateXInvoice::dispatch($invitation->invoice, true);
|
||||
}
|
||||
});
|
||||
} catch (\Exception $e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user