diff --git a/app/Services/EDocument/Standards/Validation/Verifactu/EntityLevel.php b/app/Services/EDocument/Standards/Validation/Verifactu/EntityLevel.php index baacc034cc..10c054283e 100644 --- a/app/Services/EDocument/Standards/Validation/Verifactu/EntityLevel.php +++ b/app/Services/EDocument/Standards/Validation/Verifactu/EntityLevel.php @@ -62,6 +62,7 @@ class EntityLevel implements EntityLevelInterface { $this->init($client->locale()); + $this->errors['client'] = $this->testClientState($client); $this->errors['passes'] = count($this->errors['client']) == 0; @@ -89,6 +90,7 @@ class EntityLevel implements EntityLevelInterface $this->errors['client'] = $this->testClientState($invoice->client); $this->errors['company'] = $this->testCompanyState($invoice->client); // uses client level settings which is what we want + if (count($this->errors['client']) > 0) { $this->errors['passes'] = false; @@ -96,6 +98,13 @@ class EntityLevel implements EntityLevelInterface } + // $this->errors['invoice'][] = 'test error'; + + $this->errors['passes'] = count($this->errors['invoice']) === 0 && count($this->errors['company']) === 0; //no need to check client as we are using client level settings + + return $this->errors; + + // $p = new Peppol($invoice); @@ -137,9 +146,6 @@ class EntityLevel implements EntityLevelInterface // $this->checkNexus($invoice->client); - $this->errors['passes'] = count($this->errors['invoice']) == 0 && count($this->errors['client']) == 0 && count($this->errors['company']) == 0; - - return $this->errors; } @@ -166,14 +172,27 @@ class EntityLevel implements EntityLevelInterface } - //If not an individual, you MUST have a VAT number if you are in the EU - if ($client->classification != 'individual' && !$this->validString($client->vat_number)) { - $errors[] = ['field' => 'vat_number', 'label' => ctrans("texts.vat_number")]; - } - //Primary contact email is present. - if ($client->present()->email() == 'No Email Set') { - $errors[] = ['field' => 'email', 'label' => ctrans("texts.email")]; + if ($client->country_id == 724) { + + if (in_array($client->classification, ['','individual']) && strlen($client->id_number ?? '') == 0) { + $errors[] = ['field' => 'id_number', 'label' => ctrans("texts.id_number")]; + } elseif (strlen($client->vat_number ?? '')) { + $errors[] = ['field' => 'vat_number', 'label' => ctrans("texts.vat_number")]; + } + + } + else{ + //If not an individual, you MUST have a VAT number if you are in the EU + if (!in_array($client->classification,['','individual']) && !$this->validString($client->vat_number)) { + $errors[] = ['field' => 'vat_number', 'label' => ctrans("texts.vat_number")]; + } + + // //Primary contact email is present. + // if ($client->present()->email() == 'No Email Set') { + // $errors[] = ['field' => 'email', 'label' => ctrans("texts.email")]; + // } + } return $errors; diff --git a/app/Services/EDocument/Standards/Verifactu/RegistroAlta.php b/app/Services/EDocument/Standards/Verifactu/RegistroAlta.php index a5d9edbd58..14e9d6ac6f 100644 --- a/app/Services/EDocument/Standards/Verifactu/RegistroAlta.php +++ b/app/Services/EDocument/Standards/Verifactu/RegistroAlta.php @@ -138,11 +138,20 @@ class RegistroAlta $destinatarios = []; $destinatario = new PersonaFisicaJuridica(); - if($this->invoice->client->country_id == 724) { + if($this->invoice->client->country_id == 724 && strlen($this->invoice->client->vat_number ?? '') > 5) { $destinatario ->setNif($this->invoice->client->vat_number) ->setNombreRazon($this->invoice->client->present()->name()); } + elseif($this->invoice->client->country_id == 724) { + + $destinatario = new IDOtro(); + $destinatario->setNombreRazon($this->invoice->client->present()->name()); + $destinatario->setCodigoPais('ES') + ->setIdType('06') + ->setId($this->invoice->client->id_number); + + } else { $locationData = $this->invoice->service()->location(); diff --git a/composer.lock b/composer.lock index fd6d22a260..d54f35a3fb 100644 --- a/composer.lock +++ b/composer.lock @@ -17906,16 +17906,16 @@ }, { "name": "fidry/cpu-core-counter", - "version": "1.2.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/theofidry/cpu-core-counter.git", - "reference": "8520451a140d3f46ac33042715115e290cf5785f" + "reference": "db9508f7b1474469d9d3c53b86f817e344732678" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/8520451a140d3f46ac33042715115e290cf5785f", - "reference": "8520451a140d3f46ac33042715115e290cf5785f", + "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/db9508f7b1474469d9d3c53b86f817e344732678", + "reference": "db9508f7b1474469d9d3c53b86f817e344732678", "shasum": "" }, "require": { @@ -17925,10 +17925,10 @@ "fidry/makefile": "^0.2.0", "fidry/php-cs-fixer-config": "^1.1.2", "phpstan/extension-installer": "^1.2.0", - "phpstan/phpstan": "^1.9.2", - "phpstan/phpstan-deprecation-rules": "^1.0.0", - "phpstan/phpstan-phpunit": "^1.2.2", - "phpstan/phpstan-strict-rules": "^1.4.4", + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-deprecation-rules": "^2.0.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", "phpunit/phpunit": "^8.5.31 || ^9.5.26", "webmozarts/strict-phpunit": "^7.5" }, @@ -17955,7 +17955,7 @@ ], "support": { "issues": "https://github.com/theofidry/cpu-core-counter/issues", - "source": "https://github.com/theofidry/cpu-core-counter/tree/1.2.0" + "source": "https://github.com/theofidry/cpu-core-counter/tree/1.3.0" }, "funding": [ { @@ -17963,7 +17963,7 @@ "type": "github" } ], - "time": "2024-08-06T10:04:20+00:00" + "time": "2025-08-14T07:29:31+00:00" }, { "name": "filp/whoops", @@ -18383,16 +18383,16 @@ }, { "name": "laravel/boost", - "version": "v1.0.9", + "version": "v1.0.17", "source": { "type": "git", "url": "https://github.com/laravel/boost.git", - "reference": "ad025a2f2325ccdc5f52e926dab4e0c1d2c6def9" + "reference": "3d1121561f793d027b76cb02b4ef9e654f8870fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/boost/zipball/ad025a2f2325ccdc5f52e926dab4e0c1d2c6def9", - "reference": "ad025a2f2325ccdc5f52e926dab4e0c1d2c6def9", + "url": "https://api.github.com/repos/laravel/boost/zipball/3d1121561f793d027b76cb02b4ef9e654f8870fb", + "reference": "3d1121561f793d027b76cb02b4ef9e654f8870fb", "shasum": "" }, "require": { @@ -18444,7 +18444,7 @@ "issues": "https://github.com/laravel/boost/issues", "source": "https://github.com/laravel/boost" }, - "time": "2025-08-13T19:51:44+00:00" + "time": "2025-08-14T17:31:57+00:00" }, { "name": "laravel/mcp",