1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00

Fixes for the tests

This commit is contained in:
Lars Kusch 2023-04-17 11:55:38 +02:00
parent 3035da6ca5
commit 4ff9da777d
2 changed files with 30 additions and 25 deletions

View File

@ -61,6 +61,7 @@ class CreateXInvoice implements ShouldQueue
case "XInvoice-Basic": case "XInvoice-Basic":
$profile = ZugferdProfiles::PROFILE_BASIC; $profile = ZugferdProfiles::PROFILE_BASIC;
break; break;
} }
$xrechnung = ZugferdDocumentBuilder::CreateNew($profile); $xrechnung = ZugferdDocumentBuilder::CreateNew($profile);
@ -72,7 +73,6 @@ class CreateXInvoice implements ShouldQueue
->setDocumentSellerContact($invoice->user->first_name." ".$invoice->user->last_name, "", $invoice->user->phone, "", $invoice->user->email) ->setDocumentSellerContact($invoice->user->first_name." ".$invoice->user->last_name, "", $invoice->user->phone, "", $invoice->user->email)
->setDocumentBuyer($client->name, $client->number) ->setDocumentBuyer($client->name, $client->number)
->setDocumentBuyerAddress($client->address1, "", "", $client->postal_code, $client->city, $client->country->iso_3166_2) ->setDocumentBuyerAddress($client->address1, "", "", $client->postal_code, $client->city, $client->country->iso_3166_2)
->setDocumentBuyerReference($client->routing_id)
->setDocumentBuyerContact($client->primary_contact()->first()->first_name . " " . $client->primary_contact()->first()->last_name, "", $client->primary_contact()->first()->phone, "", $client->primary_contact()->first()->email) ->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) ->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])); ->addDocumentPaymentTerm(ctrans("texts.xinvoice_payable", ['payeddue' => date_create($invoice->date)->diff(date_create($invoice->due_date))->format("%d"), 'paydate' => $invoice->due_date]));
@ -85,6 +85,9 @@ class CreateXInvoice implements ShouldQueue
if (empty($client->routing_id)){ if (empty($client->routing_id)){
$xrechnung->setDocumentBuyerReference(ctrans("texts.xinvoice_no_buyers_reference")); $xrechnung->setDocumentBuyerReference(ctrans("texts.xinvoice_no_buyers_reference"));
} }
else {
$xrechnung->setDocumentBuyerReference($client->routing_id);
}
$xrechnung->addDocumentPaymentMean(68, ctrans("texts.xinvoice_online_payment")); $xrechnung->addDocumentPaymentMean(68, ctrans("texts.xinvoice_online_payment"));
if (str_contains($company->getSetting('vat_number'), "/")) { if (str_contains($company->getSetting('vat_number'), "/")) {

View File

@ -39,6 +39,7 @@ class EInvoiceTest extends TestCase
public function testEInvoiceGenerates() public function testEInvoiceGenerates()
{ {
$this->company->e_invoice_type = "EN16931";
$this->invoice->client->routing_id = 'DE123456789'; $this->invoice->client->routing_id = 'DE123456789';
$this->invoice->client->save(); $this->invoice->client->save();
$xinvoice = (new CreateXInvoice($this->invoice, false))->handle(); $xinvoice = (new CreateXInvoice($this->invoice, false))->handle();
@ -46,30 +47,31 @@ class EInvoiceTest extends TestCase
$this->assertTrue(Storage::exists($xinvoice)); $this->assertTrue(Storage::exists($xinvoice));
} }
// /** /**
// * @throws Exception * @throws Exception
// */ */
// public function testValidityofXMLFile() public function testValidityofXMLFile()
// { {
// $this->invoice->client->routing_id = 'DE123456789'; $this->company->e_invoice_type = "EN16931";
// $this->invoice->client->save(); $this->invoice->client->routing_id = 'DE123456789';
$this->invoice->client->save();
// $xinvoice = (new CreateXInvoice($this->invoice, false))->handle(); $xinvoice = (new CreateXInvoice($this->invoice, false))->handle();
// nlog(Storage::path($xinvoice)); nlog(Storage::path($xinvoice));
// $document = ZugferdDocumentReader::readAndGuessFromFile(Storage::path($xinvoice)); $document = ZugferdDocumentReader::readAndGuessFromFile(Storage::path($xinvoice));
// $document->getDocumentInformation($documentno); $document->getDocumentInformation($documentno, $documenttypecode, $documentdate, $documentcurrency, $taxcurrency, $taxname, $documentlangeuage, $rest);
// $this->assertEquals($this->invoice->number, $documentno); $this->assertEquals($this->invoice->number, $documentno);
// } }
// /** /**
// * @throws Exception * @throws Exception
// */ */
// public function checkEmbededPDFFile() public function checkEmbededPDFFile()
// { {
// $pdf = (new CreateEntityPdf($this->invoice->invitations()->first()))->handle(); $pdf = (new CreateEntityPdf($this->invoice->invitations()->first()))->handle();
// (new CreateXInvoice($this->invoice, true, $pdf))->handle(); (new CreateXInvoice($this->invoice, true, $pdf))->handle();
// $document = ZugferdDocumentReader::readAndGuessFromFile($pdf); $document = ZugferdDocumentReader::readAndGuessFromFile($pdf);
// $document->getDocumentInformation($documentno); $document->getDocumentInformation($documentno, $documenttypecode, $documentdate, $documentcurrency, $taxcurrency, $taxname, $documentlangeuage, $rest);
// $this->assertEquals($this->invoice->number, $documentno); $this->assertEquals($this->invoice->number, $documentno);
// } }
} }