mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-10 20:54:37 -04:00
Merge branch 'v5-develop' of https://github.com/LarsK1/invoiceninja into v5-develop
This commit is contained in:
commit
c164ab1970
@ -63,13 +63,13 @@ class CreateEInvoice implements ShouldQueue
|
||||
case "XInvoice-Extended":
|
||||
case "XInvoice-BasicWL":
|
||||
case "XInvoice-Basic":
|
||||
return (new ZugferdEInvoice($this->invoice, $this->alterPDF, $this->custom_pdf_path))->run();
|
||||
return (new ZugferdEInvoice($this->invoice))->run();
|
||||
case "Facturae_3.2":
|
||||
case "Facturae_3.2.1":
|
||||
case "Facturae_3.2.2":
|
||||
return (new FacturaEInvoice($this->invoice, str_replace("Facturae_", "", $e_invoice_type)))->run();
|
||||
default:
|
||||
return (new ZugferdEInvoice($this->invoice, $this->alterPDF, $this->custom_pdf_path))->run();
|
||||
return (new ZugferdEInvoice($this->invoice))->run();
|
||||
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ use horstoeko\zugferd\codelists\ZugferdDutyTaxFeeCategories;
|
||||
class ZugferdEInvoice extends AbstractService
|
||||
{
|
||||
|
||||
public function __construct(public Invoice $invoice, private bool $alterPDF, private string $custom_pdf_path = "", private array $tax_map = [])
|
||||
public function __construct(public Invoice $invoice, private array $tax_map = [])
|
||||
{
|
||||
}
|
||||
|
||||
@ -175,22 +175,6 @@ class ZugferdEInvoice extends AbstractService
|
||||
$xrechnung->writeFile(Storage::disk($disk)->path($client->e_invoice_filepath($this->invoice->invitations->first()) . $this->invoice->getFileName("xml")));
|
||||
// The validity can be checked using https://portal3.gefeg.com/invoice/validation or https://e-rechnung.bayern.de/app/#/upload
|
||||
|
||||
if ($this->alterPDF) {
|
||||
if ($this->custom_pdf_path != "") {
|
||||
$pdfBuilder = new ZugferdDocumentPdfBuilder($xrechnung, $this->custom_pdf_path);
|
||||
$pdfBuilder->generateDocument();
|
||||
$pdfBuilder->saveDocument($this->custom_pdf_path);
|
||||
} else {
|
||||
$filepath_pdf = $client->invoice_filepath($this->invoice->invitations->first()) . $this->invoice->getFileName();
|
||||
$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->e_invoice_filepath($this->invoice->invitations->first()) . $this->invoice->getFileName("xml");
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ use App\Models\Invoice;
|
||||
use App\Services\AbstractService;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class GetInvoiceXInvoice extends AbstractService
|
||||
class GetInvoiceEInvoice extends AbstractService
|
||||
{
|
||||
public function __construct(public Invoice $invoice, public ?ClientContact $contact = null)
|
||||
{
|
@ -194,9 +194,13 @@ class InvoiceService
|
||||
|
||||
public function getEInvoice($contact = null)
|
||||
{
|
||||
return (new GetInvoiceXInvoice($this->invoice, $contact))->run();
|
||||
return (new GetInvoiceEInvoice($this->invoice, $contact))->run();
|
||||
}
|
||||
|
||||
public function mergeEInvoice($contact = null): void
|
||||
{
|
||||
(new MergeEInvoice($this->invoice, $contact))->run();
|
||||
}
|
||||
public function sendEmail($contact = null)
|
||||
{
|
||||
$send_email = new SendEmail($this->invoice, null, $contact);
|
||||
|
61
app/Services/Invoice/MergeEInvoice.php
Normal file
61
app/Services/Invoice/MergeEInvoice.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Invoice;
|
||||
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Invoice;
|
||||
use App\Services\AbstractService;
|
||||
use horstoeko\zugferd\ZugferdDocumentPdfBuilder;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use horstoeko\zugferd\ZugferdDocumentReader;
|
||||
|
||||
class MergeEInvoice extends AbstractService
|
||||
{
|
||||
public function __construct(public Invoice $invoice, public ?ClientContact $contact = null)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$e_invoice_type = $this->invoice->client->getSetting('e_invoice_type');
|
||||
switch ($e_invoice_type) {
|
||||
case "EN16931":
|
||||
case "XInvoice_2_2":
|
||||
case "XInvoice_2_1":
|
||||
case "XInvoice_2_0":
|
||||
case "XInvoice_1_0":
|
||||
case "XInvoice-Extended":
|
||||
case "XInvoice-BasicWL":
|
||||
case "XInvoice-Basic":
|
||||
$this->embedEInvoiceZuGFerD();
|
||||
//case "Facturae_3.2":
|
||||
//case "Facturae_3.2.1":
|
||||
//case "Facturae_3.2.2":
|
||||
//
|
||||
default:
|
||||
$this->embedEInvoiceZuGFerD();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function embedEInvoiceZuGFerD(): void
|
||||
{
|
||||
$filepath_pdf = $this->invoice->client->invoice_filepath($this->invoice->invitations->first()) . $this->invoice->getFileName();
|
||||
$e_invoice_path = $this->invoice->client->e_invoice_filepath($this->invoice->invitations->first()) . $this->invoice->getFileName("xml");
|
||||
$document = ZugferdDocumentReader::readAndGuessFromFile($e_invoice_path);
|
||||
$disk = config('filesystems.default');
|
||||
|
||||
if (!Storage::disk($disk)->exists($this->invoice->client->e_invoice_filepath($this->invoice->invitations->first()))) {
|
||||
Storage::makeDirectory($this->invoice->client->e_invoice_filepath($this->invoice->invitations->first()));
|
||||
}
|
||||
$pdfBuilder = new ZugferdDocumentPdfBuilder($document, Storage::disk($disk)->path($filepath_pdf));
|
||||
$pdfBuilder->generateDocument();
|
||||
$pdfBuilder->saveDocument(Storage::disk($disk)->path($filepath_pdf));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user