@@ -27,7 +27,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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(), |