@@ -299,17 +299,20 @@ discard block |
||
299 | 299 | // Objetos de Firma y Folios |
300 | 300 | $Firma = new \sasco\LibreDTE\FirmaElectronica($config['firma']); |
301 | 301 | $Folios = []; |
302 | -foreach ($folios as $tipo => $cantidad) |
|
302 | +foreach ($folios as $tipo => $cantidad) { |
|
303 | 303 | $Folios[$tipo] = new \sasco\LibreDTE\Sii\Folios(file_get_contents('xml/folios/'.$tipo.'.xml')); |
304 | +} |
|
304 | 305 | |
305 | 306 | // generar cada DTE, timbrar, firmar y agregar al sobre de EnvioBOLETA |
306 | 307 | $EnvioDTE = new \sasco\LibreDTE\Sii\EnvioDte(); |
307 | 308 | foreach ($set_pruebas as $documento) { |
308 | 309 | $DTE = new \sasco\LibreDTE\Sii\Dte($documento); |
309 | - if (!$DTE->timbrar($Folios[$DTE->getTipo()])) |
|
310 | - break; |
|
311 | - if (!$DTE->firmar($Firma)) |
|
312 | - break; |
|
310 | + if (!$DTE->timbrar($Folios[$DTE->getTipo()])) { |
|
311 | + break; |
|
312 | + } |
|
313 | + if (!$DTE->firmar($Firma)) { |
|
314 | + break; |
|
315 | + } |
|
313 | 316 | $EnvioDTE->agregar($DTE); |
314 | 317 | } |
315 | 318 | $EnvioDTE->setFirma($Firma); |
@@ -320,5 +323,6 @@ discard block |
||
320 | 323 | } |
321 | 324 | |
322 | 325 | // si hubo errores mostrar |
323 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
326 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
324 | 327 | echo $error,"\n"; |
328 | +} |
@@ -66,4 +66,4 @@ |
||
66 | 66 | |
67 | 67 | // si hubo errores mostrar |
68 | 68 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
69 | - echo $error,"\n"; |
|
69 | + echo $error, "\n"; |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | $Signatures->item($Signatures->length-1)->getElementsByTagName('Modulus')->item(0)->nodeValue, |
54 | 54 | $Signatures->item($Signatures->length-1)->getElementsByTagName('Exponent')->item(0)->nodeValue |
55 | 55 | );*/ |
56 | -$valid = openssl_verify($SignedInfo->C14N(), base64_decode($SignatureValue), $X509Certificate) === 1 ? true : false; |
|
57 | -echo 'Verificando SetDTE:',"\n"; |
|
58 | -echo ' Digest SetDTE: ',base64_encode(sha1($SetDTE, true)),"\n"; |
|
59 | -echo ' Digest SignedInfo: ',base64_encode(sha1($SignedInfo->C14N(), true)),"\n"; |
|
60 | -echo ' Digest SignedInfo: ',bin2hex(sha1($SignedInfo->C14N(), true)),"\n"; |
|
61 | -echo ' Digest SetDTE valido: ',($DigestValue===base64_encode(sha1($SetDTE, true))?'si':'no'),"\n"; |
|
62 | -echo ' Digest SignedInfo valido: ',($valid?'si':'no'),"\n\n"; |
|
56 | +$valid = openssl_verify($SignedInfo->C14N(), base64_decode($SignatureValue), $X509Certificate)===1 ? true : false; |
|
57 | +echo 'Verificando SetDTE:', "\n"; |
|
58 | +echo ' Digest SetDTE: ', base64_encode(sha1($SetDTE, true)), "\n"; |
|
59 | +echo ' Digest SignedInfo: ', base64_encode(sha1($SignedInfo->C14N(), true)), "\n"; |
|
60 | +echo ' Digest SignedInfo: ', bin2hex(sha1($SignedInfo->C14N(), true)), "\n"; |
|
61 | +echo ' Digest SetDTE valido: ', ($DigestValue===base64_encode(sha1($SetDTE, true)) ? 'si' : 'no'), "\n"; |
|
62 | +echo ' Digest SignedInfo valido: ', ($valid ? 'si' : 'no'), "\n\n"; |
|
63 | 63 | |
64 | 64 | // verificar firma de documentos |
65 | 65 | $i = 0; |
@@ -81,18 +81,18 @@ discard block |
||
81 | 81 | $Signatures->item($i)->getElementsByTagName('Modulus')->item(0)->nodeValue, |
82 | 82 | $Signatures->item($i)->getElementsByTagName('Exponent')->item(0)->nodeValue |
83 | 83 | );*/ |
84 | - $valid = openssl_verify($SignedInfo->C14N(), base64_decode($SignatureValue), $X509Certificate) === 1 ? true : false; |
|
85 | - echo 'Verificando Documento:',"\n"; |
|
86 | - echo ' Digest Documento: ',base64_encode(sha1($Documento->C14N(), true)),"\n"; |
|
87 | - echo ' Digest SignedInfo: ',base64_encode(sha1($SignedInfo->C14N(), true)),"\n"; |
|
88 | - echo ' Digest Documento valido: ',($DigestValue===base64_encode(sha1($Documento->C14N(), true))?'si':'no'),"\n"; |
|
89 | - echo ' Digest SignedInfo valido: ',($valid?'si':'no'),"\n\n"; |
|
84 | + $valid = openssl_verify($SignedInfo->C14N(), base64_decode($SignatureValue), $X509Certificate)===1 ? true : false; |
|
85 | + echo 'Verificando Documento:', "\n"; |
|
86 | + echo ' Digest Documento: ', base64_encode(sha1($Documento->C14N(), true)), "\n"; |
|
87 | + echo ' Digest SignedInfo: ', base64_encode(sha1($SignedInfo->C14N(), true)), "\n"; |
|
88 | + echo ' Digest Documento valido: ', ($DigestValue===base64_encode(sha1($Documento->C14N(), true)) ? 'si' : 'no'), "\n"; |
|
89 | + echo ' Digest SignedInfo valido: ', ($valid ? 'si' : 'no'), "\n\n"; |
|
90 | 90 | $i++; |
91 | 91 | } |
92 | 92 | |
93 | 93 | // si hubo errores mostrar |
94 | 94 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
95 | - echo $error,"\n"; |
|
95 | + echo $error, "\n"; |
|
96 | 96 | |
97 | 97 | // para el XML de ejemplo del SII la clave pública obtenida desde el certificado |
98 | 98 | // no sirvió para validar las firmas del documento, se probó obteniendo la clave |
@@ -91,8 +91,9 @@ |
||
91 | 91 | } |
92 | 92 | |
93 | 93 | // si hubo errores mostrar |
94 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
94 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
95 | 95 | echo $error,"\n"; |
96 | +} |
|
96 | 97 | |
97 | 98 | // para el XML de ejemplo del SII la clave pública obtenida desde el certificado |
98 | 99 | // no sirvió para validar las firmas del documento, se probó obteniendo la clave |
@@ -411,17 +411,20 @@ discard block |
||
411 | 411 | // Objetos de Firma, Folios y EnvioDTE |
412 | 412 | $Firma = new \sasco\LibreDTE\FirmaElectronica($config['firma']); |
413 | 413 | $Folios = []; |
414 | -foreach ($folios as $tipo => $cantidad) |
|
414 | +foreach ($folios as $tipo => $cantidad) { |
|
415 | 415 | $Folios[$tipo] = new \sasco\LibreDTE\Sii\Folios(file_get_contents('xml/folios/'.$tipo.'.xml')); |
416 | +} |
|
416 | 417 | $EnvioDTE = new \sasco\LibreDTE\Sii\EnvioDte(); |
417 | 418 | |
418 | 419 | // generar cada DTE, timbrar, firmar y agregar al sobre de EnvioDTE |
419 | 420 | foreach ($set_pruebas as $documento) { |
420 | 421 | $DTE = new \sasco\LibreDTE\Sii\Dte($documento); |
421 | - if (!$DTE->timbrar($Folios[$DTE->getTipo()])) |
|
422 | - break; |
|
423 | - if (!$DTE->firmar($Firma)) |
|
424 | - break; |
|
422 | + if (!$DTE->timbrar($Folios[$DTE->getTipo()])) { |
|
423 | + break; |
|
424 | + } |
|
425 | + if (!$DTE->firmar($Firma)) { |
|
426 | + break; |
|
427 | + } |
|
425 | 428 | $EnvioDTE->agregar($DTE); |
426 | 429 | } |
427 | 430 | |
@@ -433,5 +436,6 @@ discard block |
||
433 | 436 | var_dump($track_id); |
434 | 437 | |
435 | 438 | // si hubo errores mostrar |
436 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
439 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
437 | 440 | echo $error,"\n"; |
441 | +} |
@@ -66,4 +66,4 @@ |
||
66 | 66 | |
67 | 67 | // si hubo errores mostrar |
68 | 68 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
69 | - echo $error,"\n"; |
|
69 | + echo $error, "\n"; |
@@ -82,5 +82,6 @@ |
||
82 | 82 | //echo $AEC->enviar(); |
83 | 83 | |
84 | 84 | // si hubo errores mostrar |
85 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
85 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
86 | 86 | echo $error, "\n"; |
87 | +} |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | ], |
421 | 421 | 'Detalle' => [ |
422 | 422 | [ |
423 | - 'QtyItem' => $set_pruebas[6]['Detalle'][0]['QtyItem']*0.4, |
|
423 | + 'QtyItem' => $set_pruebas[6]['Detalle'][0]['QtyItem'] * 0.4, |
|
424 | 424 | ] |
425 | 425 | ], |
426 | 426 | 'Referencia' => [ |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | ], |
448 | 448 | 'Detalle' => [ |
449 | 449 | [ |
450 | - 'QtyItem' => $set_pruebas[9]['Detalle'][0]['QtyItem']*0.4, |
|
450 | + 'QtyItem' => $set_pruebas[9]['Detalle'][0]['QtyItem'] * 0.4, |
|
451 | 451 | ] |
452 | 452 | ], |
453 | 453 | 'Referencia' => [ |
@@ -480,4 +480,4 @@ discard block |
||
480 | 480 | |
481 | 481 | // si hubo errores mostrar |
482 | 482 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
483 | - echo $error,"\n"; |
|
483 | + echo $error, "\n"; |
@@ -313,25 +313,30 @@ discard block |
||
313 | 313 | // Objetos de Firma y Folios |
314 | 314 | $Firma = new \sasco\LibreDTE\FirmaElectronica($config['firma']); |
315 | 315 | $Folios = []; |
316 | -foreach ($folios as $tipo => $cantidad) |
|
316 | +foreach ($folios as $tipo => $cantidad) { |
|
317 | 317 | $Folios[$tipo] = new \sasco\LibreDTE\Sii\Folios(file_get_contents('xml/folios/'.$tipo.'.xml')); |
318 | +} |
|
318 | 319 | |
319 | 320 | // generar cada DTE, timbrar, firmar y agregar al sobre de EnvioBOLETA |
320 | 321 | $EnvioDTE = new \sasco\LibreDTE\Sii\EnvioDte(); |
321 | 322 | foreach ($set_pruebas as $documento) { |
322 | 323 | $DTE = new \sasco\LibreDTE\Sii\Dte($documento); |
323 | - if (!$DTE->timbrar($Folios[$DTE->getTipo()])) |
|
324 | - break; |
|
325 | - if (!$DTE->firmar($Firma)) |
|
326 | - break; |
|
324 | + if (!$DTE->timbrar($Folios[$DTE->getTipo()])) { |
|
325 | + break; |
|
326 | + } |
|
327 | + if (!$DTE->firmar($Firma)) { |
|
328 | + break; |
|
329 | + } |
|
327 | 330 | $EnvioDTE->agregar($DTE); |
328 | 331 | } |
329 | 332 | $EnvioDTE->setFirma($Firma); |
330 | 333 | $EnvioDTE->setCaratula($caratula); |
331 | 334 | $EnvioDTE->generar(); |
332 | 335 | if ($EnvioDTE->schemaValidate()) { |
333 | - if (is_writable('xml/EnvioBOLETA.xml')) |
|
334 | - file_put_contents('xml/EnvioBOLETA.xml', $EnvioDTE->generar()); // guardar XML en sistema de archivos |
|
336 | + if (is_writable('xml/EnvioBOLETA.xml')) { |
|
337 | + file_put_contents('xml/EnvioBOLETA.xml', $EnvioDTE->generar()); |
|
338 | + } |
|
339 | + // guardar XML en sistema de archivos |
|
335 | 340 | echo $EnvioDTE->generar(); |
336 | 341 | } |
337 | 342 | |
@@ -463,21 +468,26 @@ discard block |
||
463 | 468 | $EnvioDTE = new \sasco\LibreDTE\Sii\EnvioDte(); |
464 | 469 | foreach ($notas_credito as $documento) { |
465 | 470 | $DTE = new \sasco\LibreDTE\Sii\Dte($documento); |
466 | - if (!$DTE->timbrar($Folios[$DTE->getTipo()])) |
|
467 | - break; |
|
468 | - if (!$DTE->firmar($Firma)) |
|
469 | - break; |
|
471 | + if (!$DTE->timbrar($Folios[$DTE->getTipo()])) { |
|
472 | + break; |
|
473 | + } |
|
474 | + if (!$DTE->firmar($Firma)) { |
|
475 | + break; |
|
476 | + } |
|
470 | 477 | $EnvioDTE->agregar($DTE); |
471 | 478 | } |
472 | 479 | $EnvioDTE->setFirma($Firma); |
473 | 480 | $EnvioDTE->setCaratula($caratula); |
474 | 481 | $EnvioDTE->generar(); |
475 | 482 | if ($EnvioDTE->schemaValidate()) { |
476 | - if (is_writable('xml/EnvioDTE.xml')) |
|
477 | - file_put_contents('xml/EnvioDTE.xml', $EnvioDTE->generar()); // guardar XML en sistema de archivos |
|
483 | + if (is_writable('xml/EnvioDTE.xml')) { |
|
484 | + file_put_contents('xml/EnvioDTE.xml', $EnvioDTE->generar()); |
|
485 | + } |
|
486 | + // guardar XML en sistema de archivos |
|
478 | 487 | echo $EnvioDTE->generar(); |
479 | 488 | } |
480 | 489 | |
481 | 490 | // si hubo errores mostrar |
482 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
491 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
483 | 492 | echo $error,"\n"; |
493 | +} |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $token = \sasco\LibreDTE\Sii\Autenticacion::getToken($config['firma']); |
44 | 44 | if (!$token) { |
45 | 45 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
46 | - echo $error,"\n"; |
|
46 | + echo $error, "\n"; |
|
47 | 47 | exit; |
48 | 48 | } |
49 | 49 | |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | // si hubo algún error al enviar al servidor mostrar |
54 | 54 | if ($result===false) { |
55 | 55 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
56 | - echo $error,"\n"; |
|
56 | + echo $error, "\n"; |
|
57 | 57 | exit; |
58 | 58 | } |
59 | 59 | |
60 | 60 | // Mostrar resultado del envío |
61 | 61 | if ($result->STATUS!='0') { |
62 | 62 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
63 | - echo $error,"\n"; |
|
63 | + echo $error, "\n"; |
|
64 | 64 | exit; |
65 | 65 | } |
66 | -echo 'DTE envíado. Track ID '.$result->TRACKID,"\n"; |
|
66 | +echo 'DTE envíado. Track ID '.$result->TRACKID, "\n"; |
@@ -42,8 +42,9 @@ discard block |
||
42 | 42 | // solicitar token |
43 | 43 | $token = \sasco\LibreDTE\Sii\Autenticacion::getToken($config['firma']); |
44 | 44 | if (!$token) { |
45 | - foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
46 | - echo $error,"\n"; |
|
45 | + foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
46 | + echo $error,"\n"; |
|
47 | + } |
|
47 | 48 | exit; |
48 | 49 | } |
49 | 50 | |
@@ -52,15 +53,17 @@ discard block |
||
52 | 53 | |
53 | 54 | // si hubo algún error al enviar al servidor mostrar |
54 | 55 | if ($result===false) { |
55 | - foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
56 | - echo $error,"\n"; |
|
56 | + foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
57 | + echo $error,"\n"; |
|
58 | + } |
|
57 | 59 | exit; |
58 | 60 | } |
59 | 61 | |
60 | 62 | // Mostrar resultado del envío |
61 | 63 | if ($result->STATUS!='0') { |
62 | - foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
63 | - echo $error,"\n"; |
|
64 | + foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
65 | + echo $error,"\n"; |
|
66 | + } |
|
64 | 67 | exit; |
65 | 68 | } |
66 | 69 | echo 'DTE envíado. Track ID '.$result->TRACKID,"\n"; |
@@ -98,8 +98,9 @@ discard block |
||
98 | 98 | public function generar() |
99 | 99 | { |
100 | 100 | // si ya se había generado se entrega directamente |
101 | - if ($this->xml_data) |
|
102 | - return $this->xml_data; |
|
101 | + if ($this->xml_data) { |
|
102 | + return $this->xml_data; |
|
103 | + } |
|
103 | 104 | // si no hay respuestas para generar entregar falso |
104 | 105 | if (!isset($this->recibos[0])) { |
105 | 106 | \sasco\LibreDTE\Log::write( |
@@ -173,8 +174,9 @@ discard block |
||
173 | 174 | } |
174 | 175 | // crear recibos a partir del arreglo |
175 | 176 | $Recibos = $this->arreglo['EnvioRecibos']['SetRecibos']['Recibo']; |
176 | - if (!isset($Recibos[0])) |
|
177 | - $Recibos = [$Recibos]; |
|
177 | + if (!isset($Recibos[0])) { |
|
178 | + $Recibos = [$Recibos]; |
|
179 | + } |
|
178 | 180 | foreach ($Recibos as $Recibo) { |
179 | 181 | $this->recibos[] = $Recibo; |
180 | 182 | } |
@@ -40,8 +40,9 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function agregar(array $detalle, $normalizar = true) |
42 | 42 | { |
43 | - if ($normalizar) |
|
44 | - $this->normalizarDetalle($detalle); |
|
43 | + if ($normalizar) { |
|
44 | + $this->normalizarDetalle($detalle); |
|
45 | + } |
|
45 | 46 | $this->detalles[] = $detalle; |
46 | 47 | return true; |
47 | 48 | } |
@@ -138,8 +139,9 @@ discard block |
||
138 | 139 | 'TipoEnvio' => 'TOTAL', |
139 | 140 | 'FolioNotificacion' => null, |
140 | 141 | ], $caratula); |
141 | - if ($this->caratula['TipoEnvio']=='ESPECIAL') |
|
142 | - $this->caratula['FolioNotificacion'] = null; |
|
142 | + if ($this->caratula['TipoEnvio']=='ESPECIAL') { |
|
143 | + $this->caratula['FolioNotificacion'] = null; |
|
144 | + } |
|
143 | 145 | $this->id = 'LibreDTE_LIBRO_GUIA_'.str_replace('-', '', $this->caratula['RutEmisorLibro']).'_'.str_replace('-', '', $this->caratula['PeriodoTributario']).'_'.date('U'); |
144 | 146 | } |
145 | 147 | |
@@ -153,8 +155,9 @@ discard block |
||
153 | 155 | public function generar($incluirDetalle = true) |
154 | 156 | { |
155 | 157 | // si ya se había generado se entrega directamente |
156 | - if ($this->xml_data) |
|
157 | - return $this->xml_data; |
|
158 | + if ($this->xml_data) { |
|
159 | + return $this->xml_data; |
|
160 | + } |
|
158 | 161 | // generar XML del envío |
159 | 162 | $xmlEnvio = (new \sasco\LibreDTE\XML())->generate([ |
160 | 163 | 'LibroGuia' => [ |
@@ -79,11 +79,11 @@ discard block |
||
79 | 79 | } |
80 | 80 | // calcular valores que no se hayan entregado |
81 | 81 | if (!$detalle['IVA'] and $detalle['TasaImp'] and $detalle['MntNeto']) { |
82 | - $detalle['IVA'] = round($detalle['MntNeto'] * ($detalle['TasaImp']/100)); |
|
82 | + $detalle['IVA'] = round($detalle['MntNeto'] * ($detalle['TasaImp'] / 100)); |
|
83 | 83 | } |
84 | 84 | // calcular monto total si no se especificó |
85 | 85 | if ($detalle['MntTotal']===false) { |
86 | - $detalle['MntTotal'] = $detalle['MntNeto'] + $detalle['IVA']; |
|
86 | + $detalle['MntTotal'] = $detalle['MntNeto']+$detalle['IVA']; |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $data = \sasco\LibreDTE\CSV::read($archivo); |
101 | 101 | $n_data = count($data); |
102 | 102 | $detalles = []; |
103 | - for ($i=1; $i<$n_data; $i++) { |
|
103 | + for ($i = 1; $i<$n_data; $i++) { |
|
104 | 104 | // detalle genérico |
105 | 105 | $detalle = [ |
106 | 106 | 'Folio' => $data[$i][0], |
@@ -203,17 +203,17 @@ discard block |
||
203 | 203 | // se contabiliza si la guía está anulada |
204 | 204 | if ($d['Anulado']==1 or $d['Anulado']==2) { |
205 | 205 | if ($d['Anulado']==1) { |
206 | - $ResumenPeriodo['TotFolAnulado'] = (int)$ResumenPeriodo['TotFolAnulado'] + 1; |
|
206 | + $ResumenPeriodo['TotFolAnulado'] = (int)$ResumenPeriodo['TotFolAnulado']+1; |
|
207 | 207 | } else { |
208 | - $ResumenPeriodo['TotGuiaAnulada'] = (int)$ResumenPeriodo['TotGuiaAnulada'] + 1; |
|
208 | + $ResumenPeriodo['TotGuiaAnulada'] = (int)$ResumenPeriodo['TotGuiaAnulada']+1; |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | // si no está anulado |
212 | 212 | else { |
213 | 213 | // si es de venta |
214 | 214 | if ($d['TpoOper']==1) { |
215 | - $ResumenPeriodo['TotGuiaVenta'] = (int)$ResumenPeriodo['TotGuiaVenta'] + 1; |
|
216 | - $ResumenPeriodo['TotMntGuiaVta'] = (int)$ResumenPeriodo['TotMntGuiaVta'] + $d['MntTotal']; |
|
215 | + $ResumenPeriodo['TotGuiaVenta'] = (int)$ResumenPeriodo['TotGuiaVenta']+1; |
|
216 | + $ResumenPeriodo['TotMntGuiaVta'] = (int)$ResumenPeriodo['TotMntGuiaVta']+$d['MntTotal']; |
|
217 | 217 | } |
218 | 218 | // si no es de venta |
219 | 219 | else { |
@@ -73,10 +73,12 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function agregarRespuestaEnvio(array $datos) |
75 | 75 | { |
76 | - if (isset($this->respuesta_documentos[0])) |
|
77 | - return false; |
|
78 | - if (isset($this->respuesta_envios[$this->config['respuesta_envios_max']-1])) |
|
79 | - return false; |
|
76 | + if (isset($this->respuesta_documentos[0])) { |
|
77 | + return false; |
|
78 | + } |
|
79 | + if (isset($this->respuesta_envios[$this->config['respuesta_envios_max']-1])) { |
|
80 | + return false; |
|
81 | + } |
|
80 | 82 | $this->respuesta_envios[] = array_merge([ |
81 | 83 | 'NmbEnvio' => false, |
82 | 84 | 'FchRecep' => date('Y-m-d\TH:i:s'), |
@@ -102,10 +104,12 @@ discard block |
||
102 | 104 | */ |
103 | 105 | public function agregarRespuestaDocumento(array $datos) |
104 | 106 | { |
105 | - if (isset($this->respuesta_envios[0])) |
|
106 | - return false; |
|
107 | - if (isset($this->respuesta_documentos[$this->config['respuesta_documentos_max']-1])) |
|
108 | - return false; |
|
107 | + if (isset($this->respuesta_envios[0])) { |
|
108 | + return false; |
|
109 | + } |
|
110 | + if (isset($this->respuesta_documentos[$this->config['respuesta_documentos_max']-1])) { |
|
111 | + return false; |
|
112 | + } |
|
109 | 113 | $this->respuesta_documentos[] = array_merge([ |
110 | 114 | 'TipoDTE' => false, |
111 | 115 | 'Folio' => false, |
@@ -156,8 +160,9 @@ discard block |
||
156 | 160 | public function generar() |
157 | 161 | { |
158 | 162 | // si ya se había generado se entrega directamente |
159 | - if ($this->xml_data) |
|
160 | - return $this->xml_data; |
|
163 | + if ($this->xml_data) { |
|
164 | + return $this->xml_data; |
|
165 | + } |
|
161 | 166 | // si no hay respuestas para generar entregar falso |
162 | 167 | if (!isset($this->respuesta_envios[0]) and !isset($this->respuesta_documentos[0])) { |
163 | 168 | \sasco\LibreDTE\Log::write( |
@@ -230,8 +235,9 @@ discard block |
||
230 | 235 | */ |
231 | 236 | public function getRecepciones() |
232 | 237 | { |
233 | - if (!$this->esRecepcionEnvio()) |
|
234 | - return false; |
|
238 | + if (!$this->esRecepcionEnvio()) { |
|
239 | + return false; |
|
240 | + } |
|
235 | 241 | // si no hay respustas se deben crear |
236 | 242 | if (!$this->respuesta_envios) { |
237 | 243 | // si no está creado el arrelgo con los datos error |
@@ -242,8 +248,9 @@ discard block |
||
242 | 248 | if (isset($this->arreglo['RespuestaDTE']['Resultado']['RecepcionEnvio']['RecepcionDTE'])) { |
243 | 249 | // crear repuestas a partir del arreglo |
244 | 250 | $Recepciones = $this->arreglo['RespuestaDTE']['Resultado']['RecepcionEnvio']['RecepcionDTE']; |
245 | - if (!isset($Recepciones[0])) |
|
246 | - $Recepciones = [$Recepciones]; |
|
251 | + if (!isset($Recepciones[0])) { |
|
252 | + $Recepciones = [$Recepciones]; |
|
253 | + } |
|
247 | 254 | foreach ($Recepciones as $Recepcion) { |
248 | 255 | $this->respuesta_envios[] = $Recepcion; |
249 | 256 | } |
@@ -260,8 +267,9 @@ discard block |
||
260 | 267 | */ |
261 | 268 | public function getResultados() |
262 | 269 | { |
263 | - if (!$this->esResultadoDTE()) |
|
264 | - return false; |
|
270 | + if (!$this->esResultadoDTE()) { |
|
271 | + return false; |
|
272 | + } |
|
265 | 273 | // si no hay respustas se deben crear |
266 | 274 | if (!$this->respuesta_documentos) { |
267 | 275 | // si no está creado el arrelgo con los datos error |
@@ -270,8 +278,9 @@ discard block |
||
270 | 278 | } |
271 | 279 | // crear repuestas a partir del arreglo |
272 | 280 | $Resultados = $this->arreglo['RespuestaDTE']['Resultado']['ResultadoDTE']; |
273 | - if (!isset($Resultados[0])) |
|
274 | - $Resultados = [$Resultados]; |
|
281 | + if (!isset($Resultados[0])) { |
|
282 | + $Resultados = [$Resultados]; |
|
283 | + } |
|
275 | 284 | foreach ($Resultados as $Resultado) { |
276 | 285 | $this->respuesta_documentos[] = $Resultado; |
277 | 286 | } |