diff --git a/app/Services/EDocument/Standards/Validation/Verifactu/EntityLevel.php b/app/Services/EDocument/Standards/Validation/Verifactu/EntityLevel.php index 10c054283e..79cf3f2e66 100644 --- a/app/Services/EDocument/Standards/Validation/Verifactu/EntityLevel.php +++ b/app/Services/EDocument/Standards/Validation/Verifactu/EntityLevel.php @@ -31,7 +31,7 @@ class EntityLevel implements EntityLevelInterface // 'city', // 'state', // 'postal_code', - 'vat_number', + // 'vat_number', 'country_id', ]; @@ -164,36 +164,32 @@ class EntityLevel implements EntityLevelInterface continue; } - if($field == 'vat_number' && $client->classification == 'individual') { - continue; - } + // if($field == 'vat_number' && $client->classification == 'individual') { + // continue; + // } $errors[] = ['field' => $field, 'label' => ctrans("texts.{$field}")]; } - + /** Spanish Client Validation requirements */ if ($client->country_id == 724) { - if (in_array($client->classification, ['','individual']) && strlen($client->id_number ?? '') == 0) { + if (in_array($client->classification, ['','individual']) && strlen($client->id_number ?? '') == 0 && strlen($client->vat_number ?? '') == 0) { $errors[] = ['field' => 'id_number', 'label' => ctrans("texts.id_number")]; - } elseif (strlen($client->vat_number ?? '')) { + } elseif (!in_array($client->classification, ['','individual']) && 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")]; - // } + // 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")]; + // } - } + // } return $errors; diff --git a/app/Services/EDocument/Standards/Verifactu/RegistroAlta.php b/app/Services/EDocument/Standards/Verifactu/RegistroAlta.php index 14e9d6ac6f..19727ba8b4 100644 --- a/app/Services/EDocument/Standards/Verifactu/RegistroAlta.php +++ b/app/Services/EDocument/Standards/Verifactu/RegistroAlta.php @@ -138,17 +138,18 @@ class RegistroAlta $destinatarios = []; $destinatario = new PersonaFisicaJuridica(); + //Spanish NIF/VAT 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) { + elseif($this->invoice->client->country_id == 724) { // Spanish Passport $destinatario = new IDOtro(); $destinatario->setNombreRazon($this->invoice->client->present()->name()); $destinatario->setCodigoPais('ES') - ->setIdType('06') + ->setIdType('03') ->setId($this->invoice->client->id_number); } @@ -197,7 +198,7 @@ class RegistroAlta }; if(count($taxes) == 0) { - nlog("tax count = 0"); + $client_country_code = $this->invoice->client->country->iso_3166_2; $impuesto = 'S2'; @@ -216,9 +217,9 @@ class RegistroAlta $clave_regimen = '05'; $calificacion = 'N2'; } - else{ - $impuesto = '08'; - $clave_regimen = '01'; + else{ //Non-EU + $impuesto = '05'; + $clave_regimen = '05'; $calificacion = 'N2'; } @@ -227,7 +228,6 @@ class RegistroAlta 'ClaveRegimen' => $clave_regimen, //tax regime classification code 'CalificacionOperacion' => $calificacion, //operation classification code 'BaseImponible' => $this->calc->getNetSubtotal(), // taxable base amount - fixed: key matches DetalleDesglose::toXml() - ]; $detalle_desglose = new DetalleDesglose();