From 12efe721d1131a55b47fe10b7d935960f90fb02d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 3 Sep 2024 18:20:00 +1000 Subject: [PATCH] Fixes for tests --- app/Http/Controllers/EInvoiceController.php | 2 +- app/Http/Requests/EInvoice/ValidateEInvoiceRequest.php | 4 ++-- .../EDocument/Standards/Validation/Peppol/EntityLevel.php | 6 +++--- .../Einvoice/Storecove/EInvoiceValidationTest.php | 6 ++++++ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/EInvoiceController.php b/app/Http/Controllers/EInvoiceController.php index aee7d0836b4d..eee3eb57f77b 100644 --- a/app/Http/Controllers/EInvoiceController.php +++ b/app/Http/Controllers/EInvoiceController.php @@ -33,7 +33,7 @@ class EInvoiceController extends BaseController 'companies' => $data = $el->checkCompany($request->getEntity()), default => $data['passes'] = false, }; - +nlog($data); return response()->json($data, $data['passes'] ? 200 : 400); } diff --git a/app/Http/Requests/EInvoice/ValidateEInvoiceRequest.php b/app/Http/Requests/EInvoice/ValidateEInvoiceRequest.php index fdf192250a40..b40aa92c3dcd 100644 --- a/app/Http/Requests/EInvoice/ValidateEInvoiceRequest.php +++ b/app/Http/Requests/EInvoice/ValidateEInvoiceRequest.php @@ -78,8 +78,8 @@ class ValidateEInvoiceRequest extends Request $class = Invoice::class; match ($this->entity) { - 'invoice' => $class = Invoice::class, - 'client' => $class = Client::class, + 'invoices' => $class = Invoice::class, + 'clients' => $class = Client::class, 'companies' => $class = Company::class, default => $class = Invoice::class, }; diff --git a/app/Services/EDocument/Standards/Validation/Peppol/EntityLevel.php b/app/Services/EDocument/Standards/Validation/Peppol/EntityLevel.php index 074de8f070da..48a92af35077 100644 --- a/app/Services/EDocument/Standards/Validation/Peppol/EntityLevel.php +++ b/app/Services/EDocument/Standards/Validation/Peppol/EntityLevel.php @@ -92,8 +92,8 @@ class EntityLevel $this->init($invoice->client->locale()); $this->errors['invoice'] = []; - $this->testClientState($invoice->client); - $this->testCompanyState($invoice->client); // uses client level settings which is what we want + $this->errors['client'] = $this->testClientState($invoice->client); + $this->errors['company'] = $this->testCompanyState($invoice->client); // uses client level settings which is what we want $p = new Peppol($invoice); @@ -106,7 +106,7 @@ class EntityLevel }; - $this->errors['status'] = count($this->errors['invoice']) == 0 && count($this->errors['client']) == 0 && count($this->errors['company']) == 0; + $this->errors['passes'] = count($this->errors['invoice']) == 0 && count($this->errors['client']) == 0 && count($this->errors['company']) == 0; return $this->errors; diff --git a/tests/Integration/Einvoice/Storecove/EInvoiceValidationTest.php b/tests/Integration/Einvoice/Storecove/EInvoiceValidationTest.php index a084957e38c8..9c5687fe5ffd 100644 --- a/tests/Integration/Einvoice/Storecove/EInvoiceValidationTest.php +++ b/tests/Integration/Einvoice/Storecove/EInvoiceValidationTest.php @@ -44,6 +44,9 @@ class EInvoiceValidationTest extends TestCase public function testEinvoiceValidationEndpointInvoice() { + $this->company->legal_entity_id = 123432; + $this->company->save(); + $data =[ 'entity' => 'invoices', 'entity_id' => $this->invoice->hashed_id, @@ -63,6 +66,9 @@ class EInvoiceValidationTest extends TestCase public function testEinvoiceValidationEndpoint() { + $this->company->legal_entity_id = 123432; + $this->company->save(); + $data =[ 'entity' => 'companies', 'entity_id' => $this->company->hashed_id,