From d4bc9de4723d08f64b003a376b91068e30e032cf Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Mon, 13 Mar 2023 08:07:54 +0100 Subject: [PATCH] Renamed class to respect english convention Added support for saving file --- .../{CreateXRechnung.php => CreateXInvoice.php} | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) rename app/Jobs/Invoice/{CreateXRechnung.php => CreateXInvoice.php} (95%) diff --git a/app/Jobs/Invoice/CreateXRechnung.php b/app/Jobs/Invoice/CreateXInvoice.php similarity index 95% rename from app/Jobs/Invoice/CreateXRechnung.php rename to app/Jobs/Invoice/CreateXInvoice.php index cfe5fec9014d..c012c4cc52e2 100644 --- a/app/Jobs/Invoice/CreateXRechnung.php +++ b/app/Jobs/Invoice/CreateXInvoice.php @@ -3,11 +3,6 @@ namespace App\Jobs\Invoice; use App\Models\Invoice; -use CleverIt\UBL\Invoice\Generator; -use CleverIt\UBL\Invoice\InvoiceLine; -use CleverIt\UBL\Invoice\Item; -use CleverIt\UBL\Invoice\LegalMonetaryTotal; -use CleverIt\UBL\Invoice\TaxTotal; use horstoeko\zugferd\ZugferdDocumentBuilder; use horstoeko\zugferd\ZugferdDocumentPdfBuilder; use horstoeko\zugferd\ZugferdProfiles; @@ -18,7 +13,7 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; -class CreateXRechnung implements ShouldQueue +class CreateXInvoice implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; @@ -133,13 +128,13 @@ class CreateXRechnung implements ShouldQueue } if (strlen($invoice->tax_name3) > 1) { $xrechnung->addDocumentTax("S", "VAT", $taxnet_3, $taxamount_3, $invoice->tax_rate3); - }; - $xrechnung->writeFile(getcwd() . "/factur-x.xml"); + } + $xrechnung->writeFile(explode(".", $client->invoice_filepath($invoice->invitations->first()))[0] . "-xinvoice.xml"); // TODO: Inject XML into PDF - $pdfBuilder = new ZugferdDocumentPdfBuilder($xrechnung, "/tmp/original.pdf"); + $pdfBuilder = new ZugferdDocumentPdfBuilder($xrechnung, $client->invoice_filepath($invoice->invitations->first())); $pdfBuilder->generateDocument(); - $pdfBuilder->saveDocument("/tmp/new.pdf"); + $pdfBuilder->saveDocument($client->invoice_filepath($invoice->invitations->first())); } private function getItemTaxable($item, $invoice_total): float {