Passed
Push — main ( 7fcf59...53a5b5 )
by Jacobo
02:34
created
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.
src/Services/AeatClient.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
             ? 'https://www1.aeat.es'
28 28
             : 'https://prewww1.aeat.es';
29 29
         $this->client = new Client([
30
-            'cert' => ($certPassword === null) ? $certPath : [$certPath, $certPassword],
30
+            'cert' => ($certPassword === null) ? $certPath : [ $certPath, $certPassword ],
31 31
             'base_uri' => $this->baseUri,
32 32
             'headers' => [
33 33
                 'User-Agent' => 'LaravelVerifactu/1.0',
@@ -96,17 +96,17 @@  discard block
 block discarded – undo
96 96
     {
97 97
         // 1. Obtener datos del emisor
98 98
         $issuer = config('verifactu.issuer');
99
-        $issuerName = $issuer['name'] ?? '';
100
-        $issuerVat = $issuer['vat'] ?? '';
99
+        $issuerName = $issuer[ 'name' ] ?? '';
100
+        $issuerVat = $issuer[ 'vat' ] ?? '';
101 101
 
102 102
         // 2. Preparar datos comunes
103 103
         $ts = \Carbon\Carbon::now('UTC')->format('c');
104
-        $numSerie = (string) $invoice->getInvoiceNumber();
104
+        $numSerie = (string)$invoice->getInvoiceNumber();
105 105
         $fechaExp = $invoice->getIssueDate()->format('d-m-Y');
106 106
         $tipoFactura = $invoice->getInvoiceType();
107
-        $cuotaTotal = sprintf('%.2f', (float) $invoice->getTaxAmount());
108
-        $importeTotal = sprintf('%.2f', (float) $invoice->getTotalAmount());
109
-        $prevHash = $previous['hash'] ?? $invoice->getPreviousHash() ?? '';
107
+        $cuotaTotal = sprintf('%.2f', (float)$invoice->getTaxAmount());
108
+        $importeTotal = sprintf('%.2f', (float)$invoice->getTotalAmount());
109
+        $prevHash = $previous[ 'hash' ] ?? $invoice->getPreviousHash() ?? '';
110 110
 
111 111
         // 3. Generar huella
112 112
         $huella = $this->buildFingerprint(
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
         $body = [
147 147
             'Cabecera' => $cabecera,
148 148
             'RegistroFactura' => [
149
-                ['RegistroAlta' => $registroAlta]
149
+                [ 'RegistroAlta' => $registroAlta ]
150 150
             ],
151 151
         ];
152 152
 
@@ -167,21 +167,21 @@  discard block
 block discarded – undo
167 167
     private function buildBreakdowns(VeriFactuInvoice $invoice): array
168 168
     {
169 169
         $breakdowns = $invoice->getBreakdowns();
170
-        $detalle = [];
170
+        $detalle = [ ];
171 171
 
172 172
         foreach ($breakdowns as $breakdown) {
173
-            $detalle[] = [
173
+            $detalle[ ] = [
174 174
                 'ClaveRegimen' => $breakdown->getRegimeType(),
175 175
                 'CalificacionOperacion' => $breakdown->getOperationType(),
176
-                'TipoImpositivo' => (float) $breakdown->getTaxRate(),
177
-                'BaseImponibleOimporteNoSujeto' => sprintf('%.2f', (float) $breakdown->getBaseAmount()),
178
-                'CuotaRepercutida' => sprintf('%.2f', (float) $breakdown->getTaxAmount()),
176
+                'TipoImpositivo' => (float)$breakdown->getTaxRate(),
177
+                'BaseImponibleOimporteNoSujeto' => sprintf('%.2f', (float)$breakdown->getBaseAmount()),
178
+                'CuotaRepercutida' => sprintf('%.2f', (float)$breakdown->getTaxAmount()),
179 179
             ];
180 180
         }
181 181
 
182 182
         if (count($detalle) === 0) {
183
-            $base = sprintf('%.2f', (float) $invoice->getTotalAmount() - $invoice->getTaxAmount());
184
-            $detalle[] = [
183
+            $base = sprintf('%.2f', (float)$invoice->getTotalAmount() - $invoice->getTaxAmount());
184
+            $detalle[ ] = [
185 185
                 'ClaveRegimen' => '01',
186 186
                 'CalificacionOperacion' => 'S1',
187 187
                 'TipoImpositivo' => 0.0,
@@ -199,29 +199,29 @@  discard block
 block discarded – undo
199 199
             return [
200 200
                 'RegistroAnterior' => [
201 201
                     'IDEmisorFactura' => $issuerVat,
202
-                    'NumSerieFactura' => $previous['number'],
203
-                    'FechaExpedicionFactura' => $previous['date'],
204
-                    'Huella' => $previous['hash'],
202
+                    'NumSerieFactura' => $previous[ 'number' ],
203
+                    'FechaExpedicionFactura' => $previous[ 'date' ],
204
+                    'Huella' => $previous[ 'hash' ],
205 205
                 ],
206 206
             ];
207 207
         }
208
-        return ['PrimerRegistro' => 'S'];
208
+        return [ 'PrimerRegistro' => 'S' ];
209 209
     }
210 210
 
211 211
     private function buildRecipients(VeriFactuInvoice $invoice): ?array
212 212
     {
213 213
         $recipients = $invoice->getRecipients();
214 214
         if ($recipients->count() > 0) {
215
-            $destinatarios = [];
215
+            $destinatarios = [ ];
216 216
             foreach ($recipients as $recipient) {
217
-                $r = ['NombreRazon' => $recipient->getName()];
217
+                $r = [ 'NombreRazon' => $recipient->getName() ];
218 218
                 $taxId = $recipient->getTaxId();
219 219
                 if (!empty($taxId)) {
220
-                    $r['NIF'] = $taxId;
220
+                    $r[ 'NIF' ] = $taxId;
221 221
                 }
222
-                $destinatarios[] = $r;
222
+                $destinatarios[ ] = $r;
223 223
             }
224
-            return ['IDDestinatario' => $destinatarios];
224
+            return [ 'IDDestinatario' => $destinatarios ];
225 225
         }
226 226
         return null;
227 227
     }
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
             'NombreRazonEmisor' => $issuerName,
252 252
             'TipoFactura' => $tipoFactura,
253 253
             'DescripcionOperacion' => $invoice->getOperationDescription(),
254
-            'Desglose' => ['DetalleDesglose' => $detalle],
254
+            'Desglose' => [ 'DetalleDesglose' => $detalle ],
255 255
             'CuotaTotal' => $cuotaTotal,
256 256
             'ImporteTotal' => $importeTotal,
257 257
             'Encadenamiento' => $encadenamiento,
@@ -273,26 +273,26 @@  discard block
 block discarded – undo
273 273
 
274 274
         // Campos opcionales nuevos
275 275
         if ($invoice->getOperationDate()) {
276
-            $registroAlta['FechaOperacion'] = $invoice->getOperationDate()->format('d-m-Y');
276
+            $registroAlta[ 'FechaOperacion' ] = $invoice->getOperationDate()->format('d-m-Y');
277 277
         }
278 278
 
279 279
         if ($invoice->getTaxPeriod()) {
280
-            $registroAlta['PeriodoImpositivo'] = [
280
+            $registroAlta[ 'PeriodoImpositivo' ] = [
281 281
                 'Ejercicio' => $invoice->getIssueDate()->format('Y'),
282 282
                 'Periodo' => $invoice->getTaxPeriod(),
283 283
             ];
284 284
         }
285 285
 
286 286
         if ($invoice->getCorrectionType()) {
287
-            $registroAlta['TipoRectificativa'] = $invoice->getCorrectionType();
287
+            $registroAlta[ 'TipoRectificativa' ] = $invoice->getCorrectionType();
288 288
         }
289 289
 
290 290
         if ($invoice->getExternalReference()) {
291
-            $registroAlta['RefExterna'] = $invoice->getExternalReference();
291
+            $registroAlta[ 'RefExterna' ] = $invoice->getExternalReference();
292 292
         }
293 293
 
294 294
         if ($destinatarios) {
295
-            $registroAlta['Destinatarios'] = $destinatarios;
295
+            $registroAlta[ 'Destinatarios' ] = $destinatarios;
296 296
         }
297 297
 
298 298
         return $registroAlta;
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
         try {
338 338
             $client = $this->getSoapClient();
339 339
             $client->__setLocation($location);
340
-            $response = $client->__soapCall('RegFactuSistemaFacturacion', [$body]);
340
+            $response = $client->__soapCall('RegFactuSistemaFacturacion', [ $body ]);
341 341
             return [
342 342
                 'status' => 'success',
343 343
                 'request' => $client->__getLastRequest(),
Please login to merge, or discard this patch.