Fixes for tests

This commit is contained in:
David Bomba 2024-09-03 18:20:00 +10:00
parent f893a75e9b
commit 12efe721d1
4 changed files with 12 additions and 6 deletions

View File

@ -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);
}

View File

@ -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,
};

View File

@ -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;

View File

@ -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,