Passed
Push — main ( a55882...7fcf59 )
by Jacobo
02:39
created
src/Services/AeatClient.php 1 patch
Spacing   +22 added lines, -22 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',
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      */
43 43
     private function fmt2($value): string
44 44
     {
45
-        return sprintf('%.2f', (float) $value);
45
+        return sprintf('%.2f', (float)$value);
46 46
     }
47 47
 
48 48
     /**
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
     {
98 98
         // 1. Obtener datos del emisor desde config
99 99
         $issuer = config('verifactu.issuer');
100
-        $issuerName = $issuer['name'] ?? '';
101
-        $issuerVat = $issuer['vat'] ?? '';
100
+        $issuerName = $issuer[ 'name' ] ?? '';
101
+        $issuerVat = $issuer[ 'vat' ] ?? '';
102 102
 
103 103
         // 2. Mapear Invoice a estructura AEAT
104 104
         $cabecera = [
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
         // 3. Mapear desgloses (Breakdown) con campos requeridos
112 112
         $breakdowns = $invoice->getBreakdowns();
113 113
 
114
-        $detalle = [];
114
+        $detalle = [ ];
115 115
         foreach ($breakdowns as $breakdown) {
116
-            $detalle[] = [
116
+            $detalle[ ] = [
117 117
                 'ClaveRegimen' => $breakdown->getRegimeType(),
118 118
                 'CalificacionOperacion' => $breakdown->getOperationType(),
119
-                'TipoImpositivo' => (float) $breakdown->getTaxRate(),
119
+                'TipoImpositivo' => (float)$breakdown->getTaxRate(),
120 120
                 'BaseImponibleOimporteNoSujeto' => $this->fmt2($breakdown->getBaseAmount()),
121 121
                 'CuotaRepercutida' => $this->fmt2($breakdown->getTaxAmount()),
122 122
             ];
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
         // Si no hay desgloses, crear uno por defecto
126 126
         if (count($detalle) === 0) {
127 127
             $base = $this->fmt2($invoice->getTotalAmount() - $invoice->getTaxAmount());
128
-            $detalle[] = [
128
+            $detalle[ ] = [
129 129
                 'ClaveRegimen' => '01',
130 130
                 'CalificacionOperacion' => 'S1',
131 131
                 'TipoImpositivo' => 0.0,
@@ -136,13 +136,13 @@  discard block
 block discarded – undo
136 136
 
137 137
         // 4. Generar timestamp y preparar datos para huella
138 138
         $ts = \Carbon\Carbon::now('UTC')->format('c');
139
-        $numSerie = (string) $invoice->getInvoiceNumber();
139
+        $numSerie = (string)$invoice->getInvoiceNumber();
140 140
         $fechaExp = $invoice->getIssueDate()->format('d-m-Y');
141 141
         $fechaExpYMD = $invoice->getIssueDate()->format('Y-m-d');
142 142
         $tipoFactura = $invoice->getInvoiceType();
143 143
         $cuotaTotal = $this->fmt2($invoice->getTaxAmount());
144 144
         $importeTotal = $this->fmt2($invoice->getTotalAmount());
145
-        $prevHash = $previous['hash'] ?? $invoice->getPreviousHash() ?? '';
145
+        $prevHash = $previous[ 'hash' ] ?? $invoice->getPreviousHash() ?? '';
146 146
 
147 147
         // 5. Generar huella (hash)
148 148
         $huella = $this->buildFingerprint(
@@ -161,12 +161,12 @@  discard block
 block discarded – undo
161 161
             ? [
162 162
                 'RegistroAnterior' => [
163 163
                     'IDEmisorFactura' => $issuerVat,
164
-                    'NumSerieFactura' => $previous['number'],
165
-                    'FechaExpedicionFactura' => $previous['date'],
166
-                    'Huella' => $previous['hash'],
164
+                    'NumSerieFactura' => $previous[ 'number' ],
165
+                    'FechaExpedicionFactura' => $previous[ 'date' ],
166
+                    'Huella' => $previous[ 'hash' ],
167 167
                 ],
168 168
             ]
169
-            : ['PrimerRegistro' => 'S'];
169
+            : [ 'PrimerRegistro' => 'S' ];
170 170
 
171 171
         // 7. Construir RegistroAlta
172 172
         $registroAlta = [
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
             'NombreRazonEmisor' => $issuerName,
180 180
             'TipoFactura' => $tipoFactura,
181 181
             'DescripcionOperacion' => $invoice->getOperationDescription(),
182
-            'Desglose' => ['DetalleDesglose' => $detalle],
182
+            'Desglose' => [ 'DetalleDesglose' => $detalle ],
183 183
             'CuotaTotal' => $cuotaTotal,
184 184
             'ImporteTotal' => $importeTotal,
185 185
             'Encadenamiento' => $encadenamiento,
@@ -202,22 +202,22 @@  discard block
 block discarded – undo
202 202
         // 8. Mapear destinatarios (opcional, solo si existen)
203 203
         $recipients = $invoice->getRecipients();
204 204
         if ($recipients->count() > 0) {
205
-            $destinatarios = [];
205
+            $destinatarios = [ ];
206 206
             foreach ($recipients as $recipient) {
207
-                $r = ['NombreRazon' => $recipient->getName()];
207
+                $r = [ 'NombreRazon' => $recipient->getName() ];
208 208
                 $taxId = $recipient->getTaxId();
209 209
                 if (!empty($taxId)) {
210
-                    $r['NIF'] = $taxId;
210
+                    $r[ 'NIF' ] = $taxId;
211 211
                 }
212
-                $destinatarios[] = $r;
212
+                $destinatarios[ ] = $r;
213 213
             }
214
-            $registroAlta['Destinatarios'] = ['IDDestinatario' => $destinatarios];
214
+            $registroAlta[ 'Destinatarios' ] = [ 'IDDestinatario' => $destinatarios ];
215 215
         }
216 216
 
217 217
         $body = [
218 218
             'Cabecera' => $cabecera,
219 219
             'RegistroFactura' => [
220
-                ['RegistroAlta' => $registroAlta]
220
+                [ 'RegistroAlta' => $registroAlta ]
221 221
             ],
222 222
         ];
223 223
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         try {
253 253
             $client = new \SoapClient($wsdl, $options);
254 254
             $client->__setLocation($location);
255
-            $response = $client->__soapCall('RegFactuSistemaFacturacion', [$body]);
255
+            $response = $client->__soapCall('RegFactuSistemaFacturacion', [ $body ]);
256 256
             return [
257 257
                 'status' => 'success',
258 258
                 'request' => $client->__getLastRequest(),
Please login to merge, or discard this patch.
src/Models/Breakdown.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -62,16 +62,16 @@
 block discarded – undo
62 62
 
63 63
     public function getTaxRate(): float
64 64
     {
65
-        return (float) $this->tax_rate;
65
+        return (float)$this->tax_rate;
66 66
     }
67 67
 
68 68
     public function getBaseAmount(): float
69 69
     {
70
-        return (float) $this->base_amount;
70
+        return (float)$this->base_amount;
71 71
     }
72 72
 
73 73
     public function getTaxAmount(): float
74 74
     {
75
-        return (float) $this->tax_amount;
75
+        return (float)$this->tax_amount;
76 76
     }
77 77
 }
78 78
\ No newline at end of file
Please login to merge, or discard this patch.
src/Models/Invoice.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -24,20 +24,20 @@  discard block
 block discarded – undo
24 24
 
25 25
     protected static function booted()
26 26
     {
27
-        static::saving(function ($invoice) {
27
+        static::saving(function($invoice) {
28 28
             // Preparar datos para el hash
29 29
             $hashData = [
30 30
                 'issuer_tax_id' => $invoice->issuer_tax_id,
31 31
                 'invoice_number' => $invoice->number,
32 32
                 'issue_date' => $invoice->date instanceof \Illuminate\Support\Carbon ? $invoice->date->format('Y-m-d') : $invoice->date,
33
-                'invoice_type' => $invoice->type instanceof \BackedEnum ? $invoice->type->value : (string) $invoice->type,
34
-                'total_tax' => (string) $invoice->tax,
35
-                'total_amount' => (string) $invoice->total,
33
+                'invoice_type' => $invoice->type instanceof \BackedEnum ? $invoice->type->value : (string)$invoice->type,
34
+                'total_tax' => (string)$invoice->tax,
35
+                'total_amount' => (string)$invoice->total,
36 36
                 'previous_hash' => $invoice->previous_hash ?? '', // Si implementas encadenamiento
37 37
                 'generated_at' => now()->format('c'),
38 38
             ];
39 39
             $hashResult = \Squareetlabs\VeriFactu\Helpers\HashHelper::generateInvoiceHash($hashData);
40
-            $invoice->hash = $hashResult['hash'];
40
+            $invoice->hash = $hashResult[ 'hash' ];
41 41
         });
42 42
     }
43 43
 
@@ -97,17 +97,17 @@  discard block
 block discarded – undo
97 97
 
98 98
     public function getInvoiceType(): string
99 99
     {
100
-        return $this->type->value ?? (string) $this->type;
100
+        return $this->type->value ?? (string)$this->type;
101 101
     }
102 102
 
103 103
     public function getTotalAmount(): float
104 104
     {
105
-        return (float) $this->total;
105
+        return (float)$this->total;
106 106
     }
107 107
 
108 108
     public function getTaxAmount(): float
109 109
     {
110
-        return (float) $this->tax;
110
+        return (float)$this->tax;
111 111
     }
112 112
 
113 113
     public function getCustomerName(): string
Please login to merge, or discard this patch.