diff --git a/app/Jobs/Entity/CreateEntityPdf.php b/app/Jobs/Entity/CreateEntityPdf.php index 631bf2d35ef5..6ee8b367f301 100644 --- a/app/Jobs/Entity/CreateEntityPdf.php +++ b/app/Jobs/Entity/CreateEntityPdf.php @@ -12,7 +12,7 @@ namespace App\Jobs\Entity; use App\Exceptions\FilePermissionsFailure; -use App\Jobs\Invoice\CreateXInvoice; +use App\Jobs\Invoice\CreateEInvoice; use App\Libraries\MultiDB; use App\Models\Credit; use App\Models\CreditInvitation; @@ -213,7 +213,7 @@ class CreateEntityPdf implements ShouldQueue } } if ($this->entity_string == "invoice" && $this->company->enable_e_invoice){ - (new CreateXInvoice($this->entity, true))->handle(); + (new CreateEInvoice($this->entity, true))->handle(); } $this->invitation = null; $this->entity = null; diff --git a/app/Jobs/Invoice/CreateEInvoice.php b/app/Jobs/Invoice/CreateEInvoice.php new file mode 100644 index 000000000000..1417b4ce73a1 --- /dev/null +++ b/app/Jobs/Invoice/CreateEInvoice.php @@ -0,0 +1,78 @@ +invoice->client->locale()); + + /* Set customized translations _NOW_ */ + $t->replace(Ninja::transformTranslations($this->invoice->client->getMergedSettings())); + + $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": + return (new ZugferdEInvoice($this->invoice, $this->alterPDF, $this->custom_pdf_path))->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(); + break; + + } + + } +} diff --git a/app/Jobs/Invoice/ZipInvoices.php b/app/Jobs/Invoice/ZipInvoices.php index 3eb9bd21823e..22476675c2f4 100644 --- a/app/Jobs/Invoice/ZipInvoices.php +++ b/app/Jobs/Invoice/ZipInvoices.php @@ -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, false))->handle(); + (new CreateEInvoice($invoice, false))->handle(); } }); diff --git a/app/Services/Email/EmailDefaults.php b/app/Services/Email/EmailDefaults.php index 13b8294bb146..0e13943b36c0 100644 --- a/app/Services/Email/EmailDefaults.php +++ b/app/Services/Email/EmailDefaults.php @@ -11,7 +11,7 @@ namespace App\Services\Email; -use App\Jobs\Invoice\CreateXInvoice; +use App\Jobs\Invoice\CreateEInvoice; use App\Services\Invoice\GetInvoiceXInvoice; use App\DataMapper\EmailTemplateDefaults; use App\Jobs\Entity\CreateRawPdf; @@ -301,7 +301,7 @@ class EmailDefaults if ($this->email->email_object->company->enable_e_invoice && $this->email->email_object->entity instanceof Invoice) { $tempfile = tmpfile(); file_put_contents(stream_get_meta_data($tempfile)['uri'], $pdf); - $xinvoice_path = (new CreateXInvoice($this->email->email_object->entity, true, stream_get_meta_data($tempfile)['uri']))->handle(); + $xinvoice_path = (new CreateEInvoice($this->email->email_object->entity, true, stream_get_meta_data($tempfile)['uri']))->handle(); $this->email->email_object->attachments = array_merge($this->email->email_object->attachments, [['file' => base64_encode(file_get_contents(stream_get_meta_data($tempfile)['uri'])), 'name' => $this->email->email_object->entity->numberFormatter().'.pdf']]); $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"]]); } diff --git a/app/Services/Invoice/EInvoice/FacturaEInvoice.php b/app/Services/Invoice/EInvoice/FacturaEInvoice.php index c0d2da79cf49..7505956c74ab 100644 --- a/app/Services/Invoice/EInvoice/FacturaEInvoice.php +++ b/app/Services/Invoice/EInvoice/FacturaEInvoice.php @@ -11,12 +11,12 @@ namespace App\Services\Invoice\EInvoice; -use App\Models\Client; use App\Models\Invoice; use josemmo\Facturae\Facturae; use App\Services\AbstractService; use josemmo\Facturae\FacturaeItem; use josemmo\Facturae\FacturaeParty; +use Illuminate\Support\Facades\Storage; class FacturaEInvoice extends AbstractService { @@ -111,15 +111,16 @@ class FacturaEInvoice extends AbstractService // FacturaeCentre::ROLE_B2B_ISSUER Issuer in FACeB2B - public function __construct(public Invoice $invoice) + public function __construct(public Invoice $invoice, private mixed $profile) { } public function run() { + $this->calc = $this->invoice->calc(); - $this->fac = new Facturae(); + $this->fac = new Facturae($this->profile); $this->fac->setNumber('', $this->invoice->number); $this->fac->setIssueDate($this->invoice->date); $this->fac->setPrecision(Facturae::PRECISION_LINE); @@ -130,12 +131,22 @@ class FacturaEInvoice extends AbstractService ->setDiscount() ->setPoNumber(); - return $this->fac->export(); + + $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())); + } + + $this->fac->export(Storage::disk($disk)->path($this->invoice->client->e_invoice_filepath($this->invoice->invitations->first()) . $this->invoice->getFileName("xsig"))); + + return $this->invoice->client->e_invoice_filepath($this->invoice->invitations->first()) . $this->invoice->getFileName("xsig"); + } private function setPoNumber(): self { - if(strlen($this->invoice->po_number > 1)){ + if(strlen($this->invoice->po_number > 1)) { $this->fac->setReferences($this->invoice->po_number); } @@ -154,8 +165,7 @@ class FacturaEInvoice extends AbstractService private function buildItems(): self { - foreach($this->invoice->line_items as $item) - { + foreach($this->invoice->line_items as $item) { $this->fac->addItem(new FacturaeItem([ 'description' => $item->notes, 'quantity' => $item->quantity, @@ -299,4 +309,4 @@ class FacturaEInvoice extends AbstractService return $this; } -} \ No newline at end of file +} diff --git a/app/Jobs/Invoice/CreateXInvoice.php b/app/Services/Invoice/EInvoice/ZugferdEInvoice.php similarity index 61% rename from app/Jobs/Invoice/CreateXInvoice.php rename to app/Services/Invoice/EInvoice/ZugferdEInvoice.php index 4ce8ff344cca..07e7c4cc25f8 100644 --- a/app/Jobs/Invoice/CreateXInvoice.php +++ b/app/Services/Invoice/EInvoice/ZugferdEInvoice.php @@ -1,44 +1,40 @@ invoice; - $company = $invoice->company; - $client = $invoice->client; - $profile = ""; - switch ($client->getSetting('e_invoice_type')) { + + $company = $this->invoice->company; + $client = $this->invoice->client; + $profile = $client->getSetting('e_invoice_type'); + + switch ($profile) { case "EN16931": $profile = ZugferdProfiles::PROFILE_EN16931; break; @@ -66,33 +62,37 @@ class CreateXInvoice implements ShouldQueue default: $profile = ZugferdProfiles::PROFILE_EN16931; break; - } + + $xrechnung = ZugferdDocumentBuilder::CreateNew($profile); $xrechnung - ->setDocumentInformation($invoice->number, "380", date_create($invoice->date), $invoice->client->getCurrencyCode()) - ->setDocumentSupplyChainEvent(date_create($invoice->date)) + ->setDocumentInformation($this->invoice->number, "380", date_create($this->invoice->date), $this->invoice->client->getCurrencyCode()) + ->setDocumentSupplyChainEvent(date_create($this->invoice->date)) ->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($invoice->user->first_name." ".$invoice->user->last_name, "", $invoice->user->phone, "", $invoice->user->email) + ->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) ->setDocumentBuyerContact($client->primary_contact()->first()->first_name . " " . $client->primary_contact()->first()->last_name, "", $client->primary_contact()->first()->phone, "", $client->primary_contact()->first()->email) ->setDocumentShipToAddress($client->shipping_address1, $client->shipping_address2, "", $client->shipping_postal_code, $client->shipping_city, $client->shipping_country->iso_3166_2, $client->shipping_state) - ->addDocumentPaymentTerm(ctrans("texts.xinvoice_payable", ['payeddue' => date_create($invoice->date)->diff(date_create($invoice->due_date))->format("%d"), 'paydate' => $invoice->due_date])); - if (!empty($invoice->public_notes)) { - $xrechnung->addDocumentNote($invoice->public_notes); + ->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])); + + if (!empty($this->invoice->public_notes)) { + $xrechnung->addDocumentNote($this->invoice->public_notes); } - if (!empty($invoice->po_number)) { - $xrechnung->setDocumentBuyerOrderReferencedDocument($invoice->po_number); + + if (!empty($this->invoice->po_number)) { + $xrechnung->setDocumentBuyerOrderReferencedDocument($this->invoice->po_number); } - if (empty($client->routing_id)){ + + if (empty($client->routing_id)) { $xrechnung->setDocumentBuyerReference(ctrans("texts.xinvoice_no_buyers_reference")); - } - else { + } else { $xrechnung->setDocumentBuyerReference($client->routing_id); } + $xrechnung->addDocumentPaymentMean(68, ctrans("texts.xinvoice_online_payment")); if (str_contains($company->getSetting('vat_number'), "/")) { @@ -101,11 +101,11 @@ class CreateXInvoice implements ShouldQueue $xrechnung->addDocumentSellerTaxRegistration("VA", $company->getSetting('vat_number')); } - $invoicing_data = $invoice->calc(); + $invoicing_data = $this->invoice->calc(); $globaltax = null; //Create line items and calculate taxes - foreach ($invoice->line_items as $index => $item) { + foreach ($this->invoice->line_items as $index => $item) { $xrechnung->addNewPosition($index) ->setDocumentPositionProductDetails($item->notes) ->setDocumentPositionGrossPrice($item->gross_line_total) @@ -116,65 +116,67 @@ class CreateXInvoice implements ShouldQueue $xrechnung->setDocumentPositionQuantity($item->quantity, "H87"); } $linenetamount = $item->line_total; - if ($item->discount > 0){ - if ($invoice->is_amount_discount){ + if ($item->discount > 0) { + if ($this->invoice->is_amount_discount) { $linenetamount -= $item->discount; - } - else { + } else { $linenetamount -= $linenetamount * ($item->discount / 100); } } $xrechnung->setDocumentPositionLineSummation($linenetamount); // According to european law, each line item can only have one tax rate - if (!(empty($item->tax_name1) && empty($item->tax_name2) && empty($item->tax_name3))){ + if (!(empty($item->tax_name1) && empty($item->tax_name2) && empty($item->tax_name3))) { if (!empty($item->tax_name1)) { - $xrechnung->addDocumentPositionTax($this->getTaxType($item->tax_id, $invoice), 'VAT', $item->tax_rate1); + $xrechnung->addDocumentPositionTax($this->getTaxType($item->tax_id), 'VAT', $item->tax_rate1); } elseif (!empty($item->tax_name2)) { - $xrechnung->addDocumentPositionTax($this->getTaxType($item->tax_id, $invoice), 'VAT', $item->tax_rate2); + $xrechnung->addDocumentPositionTax($this->getTaxType($item->tax_id), 'VAT', $item->tax_rate2); } elseif (!empty($item->tax_name3)) { - $xrechnung->addDocumentPositionTax($this->getTaxType($item->tax_id, $invoice), 'VAT', $item->tax_rate3); + $xrechnung->addDocumentPositionTax($this->getTaxType($item->tax_id), 'VAT', $item->tax_rate3); } else { nlog("Can't add correct tax position"); } } else { - if (!empty($invoice->tax_name1)) { - $globaltax = 0; - $xrechnung->addDocumentPositionTax($this->getTaxType($invoice->tax_name1, $invoice), 'VAT', $invoice->tax_rate1); - } elseif (!empty($invoice->tax_name2)) { - $globaltax = 1; - $xrechnung->addDocumentPositionTax($this->getTaxType($invoice->tax_name2, $invoice), 'VAT', $invoice->tax_rate2); - } elseif (!empty($invoice->tax_name3)) { - $globaltax = 2; - $xrechnung->addDocumentPositionTax($this->getTaxType($invoice->tax_name3, $invoice), 'VAT', $item->tax_rate3); - } else { + if (!empty($this->invoice->tax_name1)) { + $globaltax = 0; + $xrechnung->addDocumentPositionTax($this->getTaxType($this->invoice->tax_name1), 'VAT', $this->invoice->tax_rate1); + } elseif (!empty($this->invoice->tax_name2)) { + $globaltax = 1; + $xrechnung->addDocumentPositionTax($this->getTaxType($this->invoice->tax_name2), 'VAT', $this->invoice->tax_rate2); + } elseif (!empty($this->invoice->tax_name3)) { + $globaltax = 2; + $xrechnung->addDocumentPositionTax($this->getTaxType($this->invoice->tax_name3), 'VAT', $item->tax_rate3); + } else { nlog("Can't add correct tax position"); - } + } } } - if ($invoice->isPartial()) { - $xrechnung->setDocumentSummation($invoice->amount, $invoice->balance, $invoicing_data->getSubTotal(), $invoicing_data->getTotalSurcharges(), $invoicing_data->getTotalDiscount(), $invoicing_data->getSubTotal(), $invoicing_data->getItemTotalTaxes(), null, $invoice->partial); + if ($this->invoice->isPartial()) { + $xrechnung->setDocumentSummation($this->invoice->amount, $this->invoice->balance, $invoicing_data->getSubTotal(), $invoicing_data->getTotalSurcharges(), $invoicing_data->getTotalDiscount(), $invoicing_data->getSubTotal(), $invoicing_data->getItemTotalTaxes(), null, $this->invoice->partial); } else { - $xrechnung->setDocumentSummation($invoice->amount, $invoice->balance, $invoicing_data->getSubTotal(), $invoicing_data->getTotalSurcharges(), $invoicing_data->getTotalDiscount(), $invoicing_data->getSubTotal(), $invoicing_data->getItemTotalTaxes(), null, 0.0); + $xrechnung->setDocumentSummation($this->invoice->amount, $this->invoice->balance, $invoicing_data->getSubTotal(), $invoicing_data->getTotalSurcharges(), $invoicing_data->getTotalDiscount(), $invoicing_data->getSubTotal(), $invoicing_data->getItemTotalTaxes(), null, 0.0); } foreach ($invoicing_data->getTaxMap() as $item) { $tax = explode(" ", $item["name"]); - $xrechnung->addDocumentTax($this->getTaxType("", $invoice), "VAT", $item["total"] / (explode("%", end($tax))[0] / 100), $item["total"], explode("%", end($tax))[0]); + $xrechnung->addDocumentTax($this->getTaxType(""), "VAT", $item["total"] / (explode("%", end($tax))[0] / 100), $item["total"], explode("%", end($tax))[0]); // TODO: Add correct tax type within getTaxType } - if (!empty($globaltax && isset($invoicing_data->getTotalTaxMap()[$globaltax]["name"]))){ + + if (!empty($globaltax && isset($invoicing_data->getTotalTaxMap()[$globaltax]["name"]))) { $tax = explode(" ", $invoicing_data->getTotalTaxMap()[$globaltax]["name"]); - $xrechnung->addDocumentTax($this->getTaxType("", $invoice), "VAT", $invoicing_data->getTotalTaxMap()[$globaltax]["total"] / (explode("%", end($tax))[0] / 100), $invoicing_data->getTotalTaxMap()[$globaltax]["total"], explode("%", end($tax))[0]); + $xrechnung->addDocumentTax($this->getTaxType(""), "VAT", $invoicing_data->getTotalTaxMap()[$globaltax]["total"] / (explode("%", end($tax))[0] / 100), $invoicing_data->getTotalTaxMap()[$globaltax]["total"], explode("%", end($tax))[0]); // TODO: Add correct tax type within getTaxType } $disk = config('filesystems.default'); - if (!Storage::exists($client->e_invoice_filepath($invoice->invitations->first()))) { - Storage::makeDirectory($client->e_invoice_filepath($invoice->invitations->first())); + + if (!Storage::disk($disk)->exists($client->e_invoice_filepath($this->invoice->invitations->first()))) { + Storage::makeDirectory($client->e_invoice_filepath($this->invoice->invitations->first())); } - $xrechnung->writeFile(Storage::disk($disk)->path($client->e_invoice_filepath($invoice->invitations->first()) . $invoice->getFileName("xml"))); + + $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 if ($this->alterPDF) { @@ -183,7 +185,7 @@ class CreateXInvoice implements ShouldQueue $pdfBuilder->generateDocument(); $pdfBuilder->saveDocument($this->custom_pdf_path); } else { - $filepath_pdf = $client->invoice_filepath($invoice->invitations->first()) . $invoice->getFileName(); + $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)); @@ -193,10 +195,10 @@ class CreateXInvoice implements ShouldQueue } } - return $client->e_invoice_filepath($invoice->invitations->first()) . $invoice->getFileName("xml"); + return $client->e_invoice_filepath($this->invoice->invitations->first()) . $this->invoice->getFileName("xml"); } - private function getTaxType($name, Invoice $invoice): string + private function getTaxType($name): string { $taxtype = null; switch ($name) { @@ -218,24 +220,21 @@ class CreateXInvoice implements ShouldQueue break; } $eu_states = ["AT", "BE", "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "EL", "GR", "HU", "IE", "IT", "LV", "LT", "LU", "MT", "NL", "PL", "PT", "RO", "SK", "SI", "ES", "SE", "IS", "LI", "NO", "CH"]; - if (empty($taxtype)){ - if (in_array($invoice->company->country()->iso_3166_2, $eu_states) && in_array($invoice->client->country->iso_3166_2, $eu_states)){ + if (empty($taxtype)) { + if (in_array($this->invoice->company->country()->iso_3166_2, $eu_states) && in_array($this->invoice->client->country->iso_3166_2, $eu_states)) { $taxtype = ZugferdDutyTaxFeeCategories::VAT_EXEMPT_FOR_EEA_INTRACOMMUNITY_SUPPLY_OF_GOODS_AND_SERVICES; - } - elseif (!in_array($invoice->client->country->iso_3166_2, $eu_states)){ + } elseif (!in_array($this->invoice->client->country->iso_3166_2, $eu_states)) { $taxtype = ZugferdDutyTaxFeeCategories::SERVICE_OUTSIDE_SCOPE_OF_TAX; - } - elseif ($invoice->client->country->iso_3166_2 == "ES-CN"){ + } elseif ($this->invoice->client->country->iso_3166_2 == "ES-CN") { $taxtype = ZugferdDutyTaxFeeCategories::CANARY_ISLANDS_GENERAL_INDIRECT_TAX; - } - elseif (in_array($invoice->client->country->iso_3166_2, ["ES-CE", "ES-ML"])){ + } elseif (in_array($this->invoice->client->country->iso_3166_2, ["ES-CE", "ES-ML"])) { $taxtype = ZugferdDutyTaxFeeCategories::TAX_FOR_PRODUCTION_SERVICES_AND_IMPORTATION_IN_CEUTA_AND_MELILLA; - } - else { + } else { nlog("Unkown tax case for xinvoice"); $taxtype = ZugferdDutyTaxFeeCategories::STANDARD_RATE; } } return $taxtype; } + } diff --git a/app/Services/Invoice/GetInvoiceXInvoice.php b/app/Services/Invoice/GetInvoiceXInvoice.php index 99881cabc0b5..9fcde4017a1e 100644 --- a/app/Services/Invoice/GetInvoiceXInvoice.php +++ b/app/Services/Invoice/GetInvoiceXInvoice.php @@ -11,7 +11,7 @@ namespace App\Services\Invoice; -use App\Jobs\Invoice\CreateXInvoice; +use App\Jobs\Invoice\CreateEInvoice; use App\Models\ClientContact; use App\Models\Invoice; use App\Services\AbstractService; @@ -43,7 +43,7 @@ class GetInvoiceXInvoice extends AbstractService $file = Storage::disk($disk)->exists($file_path); if (! $file) { - $file_path = (new CreateXInvoice($this->invoice, false))->handle(); + $file_path = (new CreateEInvoice($this->invoice, false))->handle(); } return $file_path; diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index e7bf0d28375d..82693c3a634c 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -14,7 +14,7 @@ namespace App\Services\Invoice; use App\Events\Invoice\InvoiceWasArchived; use App\Jobs\Entity\CreateEntityPdf; use App\Jobs\Inventory\AdjustProductInventory; -use App\Jobs\Invoice\CreateXInvoice; +use App\Jobs\Invoice\CreateEInvoice; use App\Libraries\Currency\Conversion\CurrencyApi; use App\Models\CompanyGateway; use App\Models\Expense; @@ -451,7 +451,7 @@ class InvoiceService (new CreateEntityPdf($invitation))->handle(); if ($invitation instanceof InvoiceInvitation) { - (new CreateXInvoice($invitation->invoice, true))->handle(); + (new CreateEInvoice($invitation->invoice, true))->handle(); } }); @@ -462,7 +462,7 @@ class InvoiceService CreateEntityPdf::dispatch($invitation); if ($invitation instanceof InvoiceInvitation) { - CreateXInvoice::dispatch($invitation->invoice, true); + CreateEInvoice::dispatch($invitation->invoice, true); } }); } catch (\Exception $e) { diff --git a/tests/Feature/EInvoice/FacturaeTest.php b/tests/Feature/EInvoice/FacturaeTest.php index e0002ffba486..9f0f393e0398 100644 --- a/tests/Feature/EInvoice/FacturaeTest.php +++ b/tests/Feature/EInvoice/FacturaeTest.php @@ -40,7 +40,7 @@ class FacturaeTest extends TestCase public function testInvoiceGeneration() { - $f = new FacturaEInvoice($this->invoice); + $f = new FacturaEInvoice($this->invoice, "3.2.2"); $f->run(); $this->assertNotNull($f->run()); diff --git a/tests/Unit/EInvoiceTest.php b/tests/Unit/EInvoiceTest.php index 7f6a3ecb4bd9..6c31974bf3e9 100644 --- a/tests/Unit/EInvoiceTest.php +++ b/tests/Unit/EInvoiceTest.php @@ -12,7 +12,7 @@ use Tests\TestCase; use Tests\MockAccountData; use App\Jobs\Entity\CreateEntityPdf; -use App\Jobs\Invoice\CreateXInvoice; +use App\Jobs\Invoice\CreateEInvoice; use Illuminate\Support\Facades\Storage; use horstoeko\zugferd\ZugferdDocumentReader; use Illuminate\Routing\Middleware\ThrottleRequests; @@ -42,7 +42,7 @@ class EInvoiceTest extends TestCase $this->company->e_invoice_type = "EN16931"; $this->invoice->client->routing_id = 'DE123456789'; $this->invoice->client->save(); - $xinvoice = (new CreateXInvoice($this->invoice, false))->handle(); + $xinvoice = (new CreateEInvoice($this->invoice, false))->handle(); $this->assertNotNull($xinvoice); $this->assertTrue(Storage::exists($xinvoice)); } @@ -56,7 +56,7 @@ class EInvoiceTest extends TestCase $this->invoice->client->routing_id = 'DE123456789'; $this->invoice->client->save(); - $xinvoice = (new CreateXInvoice($this->invoice, false))->handle(); + $xinvoice = (new CreateEInvoice($this->invoice, false))->handle(); nlog(Storage::path($xinvoice)); $document = ZugferdDocumentReader::readAndGuessFromFile(Storage::path($xinvoice)); $document->getDocumentInformation($documentno, $documenttypecode, $documentdate, $documentcurrency, $taxcurrency, $taxname, $documentlangeuage, $rest); @@ -69,7 +69,7 @@ class EInvoiceTest extends TestCase public function checkEmbededPDFFile() { $pdf = (new CreateEntityPdf($this->invoice->invitations()->first()))->handle(); - (new CreateXInvoice($this->invoice, true, $pdf))->handle(); + (new CreateEInvoice($this->invoice, true, $pdf))->handle(); $document = ZugferdDocumentReader::readAndGuessFromFile($pdf); $document->getDocumentInformation($documentno, $documenttypecode, $documentdate, $documentcurrency, $taxcurrency, $taxname, $documentlangeuage, $rest); $this->assertEquals($this->invoice->number, $documentno);