Passed
Branch main (082e8b)
by Jacobo
15:04
created
Category
src/Providers/VeriFactuServiceProvider.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     public function register(): void
15 15
     {
16 16
         // Registrar bindings, singletons, etc.
17
-        $this->mergeConfigFrom(__DIR__.'/../../config/verifactu.php', 'verifactu');
17
+        $this->mergeConfigFrom(__DIR__ . '/../../config/verifactu.php', 'verifactu');
18 18
     }
19 19
 
20 20
     /**
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
     {
25 25
         // Publicar archivos de configuración
26 26
         $this->publishes([
27
-            __DIR__.'/../../config/verifactu.php' => config_path('verifactu.php'),
27
+            __DIR__ . '/../../config/verifactu.php' => config_path('verifactu.php'),
28 28
         ], 'config');
29 29
 
30 30
         // Publicar migraciones
31
-        $this->loadMigrationsFrom(__DIR__.'/../../database/migrations');
31
+        $this->loadMigrationsFrom(__DIR__ . '/../../database/migrations');
32 32
     }
33 33
 } 
34 34
\ No newline at end of file
Please login to merge, or discard this patch.
src/Http/Requests/StoreInvoiceRequest.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -18,23 +18,23 @@
 block discarded – undo
18 18
     public function rules(): array
19 19
     {
20 20
         return [
21
-            'number' => ['required', 'string', 'max:60', 'unique:invoices,number'],
22
-            'date' => ['required', 'date'],
23
-            'customer_name' => ['required', 'string', 'max:120'],
24
-            'customer_tax_id' => ['required', 'string', 'max:20'],
25
-            'customer_country' => ['nullable', 'string', 'size:2'],
26
-            'issuer_name' => ['required', 'string', 'max:120'],
27
-            'issuer_tax_id' => ['required', 'string', 'max:20'],
28
-            'issuer_country' => ['nullable', 'string', 'size:2'],
29
-            'amount' => ['required', 'numeric', 'min:0'],
30
-            'tax' => ['required', 'numeric', 'min:0'],
31
-            'total' => ['required', 'numeric', 'min:0'],
32
-            'type' => ['required', Rule::in(array_column(InvoiceType::cases(), 'value'))],
33
-            'external_reference' => ['nullable', 'string', 'max:60'],
34
-            'description' => ['nullable', 'string', 'max:500'],
35
-            'status' => ['nullable', 'string', 'max:30'],
36
-            'issued_at' => ['nullable', 'date'],
37
-            'cancelled_at' => ['nullable', 'date'],
21
+            'number' => [ 'required', 'string', 'max:60', 'unique:invoices,number' ],
22
+            'date' => [ 'required', 'date' ],
23
+            'customer_name' => [ 'required', 'string', 'max:120' ],
24
+            'customer_tax_id' => [ 'required', 'string', 'max:20' ],
25
+            'customer_country' => [ 'nullable', 'string', 'size:2' ],
26
+            'issuer_name' => [ 'required', 'string', 'max:120' ],
27
+            'issuer_tax_id' => [ 'required', 'string', 'max:20' ],
28
+            'issuer_country' => [ 'nullable', 'string', 'size:2' ],
29
+            'amount' => [ 'required', 'numeric', 'min:0' ],
30
+            'tax' => [ 'required', 'numeric', 'min:0' ],
31
+            'total' => [ 'required', 'numeric', 'min:0' ],
32
+            'type' => [ 'required', Rule::in(array_column(InvoiceType::cases(), 'value')) ],
33
+            'external_reference' => [ 'nullable', 'string', 'max:60' ],
34
+            'description' => [ 'nullable', 'string', 'max:500' ],
35
+            'status' => [ 'nullable', 'string', 'max:30' ],
36
+            'issued_at' => [ 'nullable', 'date' ],
37
+            'cancelled_at' => [ 'nullable', 'date' ],
38 38
         ];
39 39
     }
40 40
 } 
41 41
\ No newline at end of file
Please login to merge, or discard this patch.
src/Http/Requests/StoreRecipientRequest.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,14 +16,14 @@
 block discarded – undo
16 16
     public function rules(): array
17 17
     {
18 18
         return [
19
-            'invoice_id' => ['required', 'exists:invoices,id'],
20
-            'name' => ['required', 'string', 'max:120'],
21
-            'tax_id' => ['required', 'string', 'max:20'],
22
-            'country' => ['nullable', 'string', 'size:2'],
23
-            'address' => ['nullable', 'string', 'max:255'],
24
-            'email' => ['nullable', 'email', 'max:120'],
25
-            'phone' => ['nullable', 'string', 'max:30'],
26
-            'type' => ['nullable', 'string', 'max:10'],
19
+            'invoice_id' => [ 'required', 'exists:invoices,id' ],
20
+            'name' => [ 'required', 'string', 'max:120' ],
21
+            'tax_id' => [ 'required', 'string', 'max:20' ],
22
+            'country' => [ 'nullable', 'string', 'size:2' ],
23
+            'address' => [ 'nullable', 'string', 'max:255' ],
24
+            'email' => [ 'nullable', 'email', 'max:120' ],
25
+            'phone' => [ 'nullable', 'string', 'max:30' ],
26
+            'type' => [ 'nullable', 'string', 'max:10' ],
27 27
         ];
28 28
     }
29 29
 } 
30 30
\ No newline at end of file
Please login to merge, or discard this patch.
src/Http/Requests/StoreBreakdownRequest.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -20,17 +20,17 @@
 block discarded – undo
20 20
     public function rules(): array
21 21
     {
22 22
         return [
23
-            'invoice_id' => ['required', 'exists:invoices,id'],
24
-            'tax_type' => ['required', Rule::in(array_column(TaxType::cases(), 'value'))],
25
-            'regime_type' => ['required', Rule::in(array_column(RegimeType::cases(), 'value'))],
26
-            'operation_type' => ['required', Rule::in(array_column(OperationType::cases(), 'value'))],
27
-            'tax_rate' => ['required', 'numeric', 'min:0'],
28
-            'base_amount' => ['required', 'numeric', 'min:0'],
29
-            'tax_amount' => ['required', 'numeric', 'min:0'],
30
-            'equivalence_surcharge_rate' => ['nullable', 'numeric', 'min:0'],
31
-            'equivalence_surcharge_amount' => ['nullable', 'numeric', 'min:0'],
32
-            'exemption_code' => ['nullable', 'string', 'max:5'],
33
-            'exemption_description' => ['nullable', 'string', 'max:255'],
23
+            'invoice_id' => [ 'required', 'exists:invoices,id' ],
24
+            'tax_type' => [ 'required', Rule::in(array_column(TaxType::cases(), 'value')) ],
25
+            'regime_type' => [ 'required', Rule::in(array_column(RegimeType::cases(), 'value')) ],
26
+            'operation_type' => [ 'required', Rule::in(array_column(OperationType::cases(), 'value')) ],
27
+            'tax_rate' => [ 'required', 'numeric', 'min:0' ],
28
+            'base_amount' => [ 'required', 'numeric', 'min:0' ],
29
+            'tax_amount' => [ 'required', 'numeric', 'min:0' ],
30
+            'equivalence_surcharge_rate' => [ 'nullable', 'numeric', 'min:0' ],
31
+            'equivalence_surcharge_amount' => [ 'nullable', 'numeric', 'min:0' ],
32
+            'exemption_code' => [ 'nullable', 'string', 'max:5' ],
33
+            'exemption_description' => [ 'nullable', 'string', 'max:255' ],
34 34
         ];
35 35
     }
36 36
 } 
37 37
\ No newline at end of file
Please login to merge, or discard this patch.
src/Models/Invoice.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
     protected static function booted()
23 23
     {
24
-        static::saving(function ($invoice) {
24
+        static::saving(function($invoice) {
25 25
             // Preparar datos para el hash
26 26
             $hashData = [
27 27
                 'issuer_tax_id' => $invoice->issuer_tax_id,
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
                 'generated_at' => now()->format('c'),
35 35
             ];
36 36
             $hashResult = \Squareetlabs\VeriFactu\Helpers\HashHelper::generateInvoiceHash($hashData);
37
-            $invoice->hash = $hashResult['hash'];
37
+            $invoice->hash = $hashResult[ 'hash' ];
38 38
         });
39 39
     }
40 40
 
Please login to merge, or discard this patch.
src/Services/AeatClient.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
             ? 'https://www1.aeat.es'
27 27
             : 'https://prewww1.aeat.es';
28 28
         $this->client = new Client([
29
-            'cert' => ($certPassword === null) ? $certPath : [$certPath, $certPassword],
29
+            'cert' => ($certPassword === null) ? $certPath : [ $certPath, $certPassword ],
30 30
             'base_uri' => $this->baseUri,
31 31
             'headers' => [
32 32
                 'User-Agent' => 'LaravelVerifactu/1.0',
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
     {
45 45
         // 1. Obtener datos del emisor desde config
46 46
         $issuer = config('verifactu.issuer');
47
-        $issuerName = $issuer['name'] ?? '';
48
-        $issuerVat = $issuer['vat'] ?? '';
47
+        $issuerName = $issuer[ 'name' ] ?? '';
48
+        $issuerVat = $issuer[ 'vat' ] ?? '';
49 49
 
50 50
         // 2. Mapear Invoice a estructura AEAT (solo campos mínimos para ejemplo)
51 51
         $cabecera = [
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
         ];
57 57
 
58 58
         // 3. Mapear destinatarios
59
-        $destinatarios = [];
59
+        $destinatarios = [ ];
60 60
         foreach ($invoice->recipients as $recipient) {
61
-            $destinatarios[] = [
61
+            $destinatarios[ ] = [
62 62
                 'NombreRazon' => $recipient->name,
63 63
                 'NIF' => $recipient->tax_id,
64 64
                 // 'IDOtro' => ... // Si aplica
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
         }
67 67
 
68 68
         // 4. Mapear desgloses (Breakdown)
69
-        $desgloses = [];
69
+        $desgloses = [ ];
70 70
         foreach ($invoice->breakdowns as $breakdown) {
71
-            $desgloses[] = [
71
+            $desgloses[ ] = [
72 72
                 'TipoImpositivo' => $breakdown->tax_rate,
73 73
                 'CuotaRepercutida' => $breakdown->tax_amount,
74 74
                 'BaseImponibleOimporteNoSujeto' => $breakdown->base_amount,
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
             ],
125 125
             'FechaHoraHusoGenRegistro' => now()->format('c'),
126 126
             'TipoHuella' => '01',
127
-            'Huella' => $hashResult['hash'],
127
+            'Huella' => $hashResult[ 'hash' ],
128 128
         ];
129 129
 
130 130
         $body = [
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         try {
161 161
             $client = new \SoapClient($wsdl, $options);
162 162
             $client->__setLocation($location);
163
-            $response = $client->__soapCall('RegFactuSistemaFacturacion', [$body]);
163
+            $response = $client->__soapCall('RegFactuSistemaFacturacion', [ $body ]);
164 164
             return [
165 165
                 'status' => 'success',
166 166
                 'request' => $client->__getLastRequest(),
Please login to merge, or discard this patch.
src/Helpers/StringHelper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
     public static function sanitize(string $inputString): string
16 16
     {
17 17
         $trimmedString = trim($inputString);
18
-        $sanitizedString = str_replace(['&', '<'], ['&amp;', '&lt;'], $trimmedString);
18
+        $sanitizedString = str_replace([ '&', '<' ], [ '&amp;', '&lt;' ], $trimmedString);
19 19
         return $sanitizedString;
20 20
     }
21 21
 } 
22 22
\ No newline at end of file
Please login to merge, or discard this patch.
src/Helpers/HashHelper.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -26,16 +26,16 @@
 block discarded – undo
26 26
     public static function generateInvoiceHash(array $data): array
27 27
     {
28 28
         self::validateData(self::$invoiceRequiredFields, $data);
29
-        $inputString = self::field('issuer_tax_id', $data['issuer_tax_id']);
30
-        $inputString .= self::field('invoice_number', $data['invoice_number']);
31
-        $inputString .= self::field('issue_date', $data['issue_date']);
32
-        $inputString .= self::field('invoice_type', $data['invoice_type']);
33
-        $inputString .= self::field('total_tax', $data['total_tax']);
34
-        $inputString .= self::field('total_amount', $data['total_amount']);
35
-        $inputString .= self::field('previous_hash', $data['previous_hash']);
36
-        $inputString .= self::field('generated_at', $data['generated_at'], false);
29
+        $inputString = self::field('issuer_tax_id', $data[ 'issuer_tax_id' ]);
30
+        $inputString .= self::field('invoice_number', $data[ 'invoice_number' ]);
31
+        $inputString .= self::field('issue_date', $data[ 'issue_date' ]);
32
+        $inputString .= self::field('invoice_type', $data[ 'invoice_type' ]);
33
+        $inputString .= self::field('total_tax', $data[ 'total_tax' ]);
34
+        $inputString .= self::field('total_amount', $data[ 'total_amount' ]);
35
+        $inputString .= self::field('previous_hash', $data[ 'previous_hash' ]);
36
+        $inputString .= self::field('generated_at', $data[ 'generated_at' ], false);
37 37
         $hash = strtoupper(hash('sha256', $inputString, false));
38
-        return ['hash' => $hash, 'inputString' => $inputString];
38
+        return [ 'hash' => $hash, 'inputString' => $inputString ];
39 39
     }
40 40
 
41 41
     private static function validateData(array $requiredFields, array $data): void
Please login to merge, or discard this patch.
database/migrations/2024_01_01_000001_create_breakdowns_table.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
 return new class extends Migration {
10 10
     public function up(): void
11 11
     {
12
-        Schema::create('breakdowns', function (Blueprint $table) {
12
+        Schema::create('breakdowns', function(Blueprint $table) {
13 13
             $table->id();
14 14
             $table->foreignId('invoice_id')->constrained('invoices')->onDelete('cascade');
15 15
             $table->string('tax_type', 5); // Enum TaxType
Please login to merge, or discard this patch.