@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | /** |
101 | 101 | * Método para generar un error usando una excepción de SowerPHP o terminar |
102 | 102 | * el script si no se está usando el framework |
103 | - * @param msg Mensaje del error |
|
103 | + * @param msg string del error |
|
104 | 104 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
105 | 105 | * @version 2017-08-04 |
106 | 106 | */ |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | |
189 | 189 | /** |
190 | 190 | * Método que entrega desde cuando es válida la firma |
191 | - * @return validFrom_time_t |
|
191 | + * @return string |
|
192 | 192 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
193 | 193 | * @version 2015-09-22 |
194 | 194 | */ |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | |
200 | 200 | /** |
201 | 201 | * Método que entrega hasta cuando es válida la firma |
202 | - * @return validTo_time_t |
|
202 | + * @return string |
|
203 | 203 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
204 | 204 | * @version 2015-09-22 |
205 | 205 | */ |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | |
233 | 233 | /** |
234 | 234 | * Método que obtiene el módulo de la clave privada |
235 | - * @return Módulo en base64 |
|
235 | + * @return string en base64 |
|
236 | 236 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
237 | 237 | * @version 2014-12-07 |
238 | 238 | */ |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | |
245 | 245 | /** |
246 | 246 | * Método que obtiene el exponente público de la clave privada |
247 | - * @return Exponente público en base64 |
|
247 | + * @return string público en base64 |
|
248 | 248 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
249 | 249 | * @version 2014-12-06 |
250 | 250 | */ |
@@ -294,9 +294,9 @@ discard block |
||
294 | 294 | |
295 | 295 | /** |
296 | 296 | * Método para realizar la firma de datos |
297 | - * @param data Datos que se desean firmar |
|
297 | + * @param data string que se desean firmar |
|
298 | 298 | * @param signature_alg Algoritmo que se utilizará para firmar (por defect SHA1) |
299 | - * @return Firma digital de los datos en base64 o =false si no se pudo firmar |
|
299 | + * @return boolean|string digital de los datos en base64 o =false si no se pudo firmar |
|
300 | 300 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
301 | 301 | * @version 2014-12-08 |
302 | 302 | */ |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | |
312 | 312 | /** |
313 | 313 | * Método que verifica la firma digital de datos |
314 | - * @param data Datos que se desean verificar |
|
314 | + * @param data string que se desean verificar |
|
315 | 315 | * @param signature Firma digital de los datos en base64 |
316 | 316 | * @param pub_key Certificado digital, clave pública, de la firma |
317 | 317 | * @param signature_alg Algoritmo que se usó para firmar (por defect SHA1) |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | * |
335 | 335 | * @param xml Datos XML que se desean firmar |
336 | 336 | * @param reference Referencia a la que hace la firma |
337 | - * @return XML firmado o =false si no se pudo fimar |
|
337 | + * @return boolean|string firmado o =false si no se pudo fimar |
|
338 | 338 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
339 | 339 | * @version 2017-10-22 |
340 | 340 | */ |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | |
155 | 155 | /** |
156 | 156 | * Método para realizar una solicitud al servicio web del SII |
157 | - * @param wsdl Nombre del WSDL que se usará |
|
158 | - * @param request Nombre de la función que se ejecutará en el servicio web |
|
157 | + * @param wsdl string del WSDL que se usará |
|
158 | + * @param request string de la función que se ejecutará en el servicio web |
|
159 | 159 | * @param args Argumentos que se pasarán al servicio web |
160 | 160 | * @param retry Intentos que se realizarán como máximo para obtener respuesta |
161 | 161 | * @return Objeto SimpleXMLElement con la espuesta del servicio web consultado |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @param usuario RUN del usuario que envía el DTE |
250 | 250 | * @param empresa RUT de la empresa emisora del DTE |
251 | 251 | * @param dte Documento XML con el DTE que se desea enviar a SII |
252 | - * @param token Token de autenticación automática ante el SII |
|
252 | + * @param token string de autenticación automática ante el SII |
|
253 | 253 | * @param gzip Permite enviar el archivo XML comprimido al servidor |
254 | 254 | * @param retry Intentos que se realizarán como máximo para obtener respuesta |
255 | 255 | * @return Respuesta XML desde SII o bien null si no se pudo obtener respuesta |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | * \endcode |
358 | 358 | * |
359 | 359 | * @param idk IDK de la clave pública del SII. Si no se indica se tratará de determinar con el ambiente que se esté usando |
360 | - * @return Contenido del certificado |
|
360 | + * @return string|false del certificado |
|
361 | 361 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
362 | 362 | * @version 2015-09-16 |
363 | 363 | */ |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | /** |
383 | 383 | * Método que asigna el ambiente que se usará por defecto (si no está |
384 | 384 | * asignado con la constante _LibreDTE_CERTIFICACION_) |
385 | - * @param ambiente Ambiente a usar: Sii::PRODUCCION o Sii::CERTIFICACION |
|
385 | + * @param ambiente integer a usar: Sii::PRODUCCION o Sii::CERTIFICACION |
|
386 | 386 | * @warning No se está verificando SSL en ambiente de certificación |
387 | 387 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
388 | 388 | * @version 2016-08-28 |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | |
418 | 418 | /** |
419 | 419 | * Método que entrega la tasa de IVA vigente |
420 | - * @return Tasa de IVA vigente |
|
420 | + * @return integer de IVA vigente |
|
421 | 421 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
422 | 422 | * @version 2015-09-03 |
423 | 423 | */ |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | /** |
494 | 494 | * Método que entrega la dirección regional según la comuna que se esté |
495 | 495 | * consultando |
496 | - * @param comuna de la sucursal del emior o bien código de la sucursal del SII |
|
496 | + * @param comuna Sii\PDF\Código|null la sucursal del emior o bien código de la sucursal del SII |
|
497 | 497 | * @return Dirección regional del SII |
498 | 498 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
499 | 499 | * @version 2017-11-07 |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | \sasco\LibreDTE\Log::write(Estado::REQUEST_ERROR_SOAP, Estado::get(Estado::REQUEST_ERROR_SOAP, $msg)); |
198 | 198 | return false; |
199 | 199 | } |
200 | - for ($i=0; $i<$retry; $i++) { |
|
200 | + for ($i = 0; $i<$retry; $i++) { |
|
201 | 201 | try { |
202 | 202 | if ($args) { |
203 | 203 | $body = call_user_func_array([$soap, $request], $args); |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | $dte = '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n".$dte; |
266 | 266 | } |
267 | 267 | do { |
268 | - $file = sys_get_temp_dir().'/dte_'.md5(microtime().$token.$dte).'.'.($gzip?'gz':'xml'); |
|
268 | + $file = sys_get_temp_dir().'/dte_'.md5(microtime().$token.$dte).'.'.($gzip ? 'gz' : 'xml'); |
|
269 | 269 | } while (file_exists($file)); |
270 | 270 | if ($gzip) { |
271 | 271 | $dte = gzencode($dte); |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); |
315 | 315 | } |
316 | 316 | // enviar XML al SII |
317 | - for ($i=0; $i<$retry; $i++) { |
|
317 | + for ($i = 0; $i<$retry; $i++) { |
|
318 | 318 | $response = curl_exec($curl); |
319 | 319 | if ($response and $response!='Error 500') { |
320 | 320 | break; |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | if ($xml->STATUS!=0) { |
344 | 344 | \sasco\LibreDTE\Log::write( |
345 | 345 | $xml->STATUS, |
346 | - Estado::get($xml->STATUS).(isset($xml->DETAIL)?'. '.implode("\n", (array)$xml->DETAIL->ERROR):'') |
|
346 | + Estado::get($xml->STATUS).(isset($xml->DETAIL) ? '. '.implode("\n", (array)$xml->DETAIL->ERROR) : '') |
|
347 | 347 | ); |
348 | 348 | } |
349 | 349 | return $xml; |
@@ -475,12 +475,12 @@ discard block |
||
475 | 475 | $lines = explode("\n", $response); |
476 | 476 | $n_lines = count($lines); |
477 | 477 | $data = []; |
478 | - for ($i=1; $i<$n_lines; $i++) { |
|
478 | + for ($i = 1; $i<$n_lines; $i++) { |
|
479 | 479 | $row = str_getcsv($lines[$i], ';', ''); |
480 | 480 | unset($lines[$i]); |
481 | 481 | if (!isset($row[5])) |
482 | 482 | continue; |
483 | - for ($j=0; $j<6; $j++) |
|
483 | + for ($j = 0; $j<6; $j++) |
|
484 | 484 | $row[$j] = trim($row[$j]); |
485 | 485 | $row[1] = utf8_decode($row[1]); |
486 | 486 | $row[4] = strtolower($row[4]); |
@@ -138,8 +138,9 @@ discard block |
||
138 | 138 | // entregar WSDL local (modificados para ambiente de certificación) |
139 | 139 | if ($ambiente==self::CERTIFICACION) { |
140 | 140 | $wsdl = dirname(dirname(__FILE__)).'/wsdl/'.self::$config['servidor'][$ambiente].'/'.$servicio.'.jws'; |
141 | - if (is_readable($wsdl)) |
|
142 | - return $wsdl; |
|
141 | + if (is_readable($wsdl)) { |
|
142 | + return $wsdl; |
|
143 | + } |
|
143 | 144 | } |
144 | 145 | // entregar WSDL oficial desde SII |
145 | 146 | $location = isset(self::$config['wsdl'][$servicio]) ? self::$config['wsdl'][$servicio] : self::$config['wsdl']['*']; |
@@ -168,10 +169,12 @@ discard block |
||
168 | 169 | $retry = (int)$args; |
169 | 170 | $args = null; |
170 | 171 | } |
171 | - if (!$retry) |
|
172 | - $retry = self::$retry; |
|
173 | - if ($args and !is_array($args)) |
|
174 | - $args = [$args]; |
|
172 | + if (!$retry) { |
|
173 | + $retry = self::$retry; |
|
174 | + } |
|
175 | + if ($args and !is_array($args)) { |
|
176 | + $args = [$args]; |
|
177 | + } |
|
175 | 178 | if (!self::$verificar_ssl) { |
176 | 179 | if (self::getAmbiente()==self::PRODUCCION) { |
177 | 180 | $msg = Estado::get(Estado::ENVIO_SSL_SIN_VERIFICAR); |
@@ -366,8 +369,9 @@ discard block |
||
366 | 369 | // si se pasó un idk y existe el archivo asociado se entrega |
367 | 370 | if ($idk) { |
368 | 371 | $cert = dirname(dirname(__FILE__)).'/certs/'.$idk.'.cer'; |
369 | - if (is_readable($cert)) |
|
370 | - return file_get_contents($cert); |
|
372 | + if (is_readable($cert)) { |
|
373 | + return file_get_contents($cert); |
|
374 | + } |
|
371 | 375 | } |
372 | 376 | // buscar certificado y entregar si existe o =false si no |
373 | 377 | $ambiente = self::getAmbiente(); |
@@ -407,10 +411,11 @@ discard block |
||
407 | 411 | public static function getAmbiente($ambiente = null) |
408 | 412 | { |
409 | 413 | if ($ambiente===null) { |
410 | - if (defined('_LibreDTE_CERTIFICACION_')) |
|
411 | - $ambiente = (int)_LibreDTE_CERTIFICACION_; |
|
412 | - else |
|
413 | - $ambiente = self::$ambiente; |
|
414 | + if (defined('_LibreDTE_CERTIFICACION_')) { |
|
415 | + $ambiente = (int)_LibreDTE_CERTIFICACION_; |
|
416 | + } else { |
|
417 | + $ambiente = self::$ambiente; |
|
418 | + } |
|
414 | 419 | } |
415 | 420 | return $ambiente; |
416 | 421 | } |
@@ -436,8 +441,9 @@ discard block |
||
436 | 441 | { |
437 | 442 | // solicitar token |
438 | 443 | $token = \sasco\LibreDTE\Sii\Autenticacion::getToken($Firma); |
439 | - if (!$token) |
|
440 | - return false; |
|
444 | + if (!$token) { |
|
445 | + return false; |
|
446 | + } |
|
441 | 447 | // definir ambiente y servidor |
442 | 448 | $ambiente = self::getAmbiente($ambiente); |
443 | 449 | $servidor = self::$config['servidor'][$ambiente]; |
@@ -466,8 +472,9 @@ discard block |
||
466 | 472 | } |
467 | 473 | // realizar consulta curl |
468 | 474 | $response = curl_exec($curl); |
469 | - if (!$response) |
|
470 | - return false; |
|
475 | + if (!$response) { |
|
476 | + return false; |
|
477 | + } |
|
471 | 478 | // cerrar sesión curl |
472 | 479 | curl_close($curl); |
473 | 480 | // entregar datos del archivo CSV |
@@ -478,10 +485,12 @@ discard block |
||
478 | 485 | for ($i=1; $i<$n_lines; $i++) { |
479 | 486 | $row = str_getcsv($lines[$i], ';', ''); |
480 | 487 | unset($lines[$i]); |
481 | - if (!isset($row[5])) |
|
482 | - continue; |
|
483 | - for ($j=0; $j<6; $j++) |
|
484 | - $row[$j] = trim($row[$j]); |
|
488 | + if (!isset($row[5])) { |
|
489 | + continue; |
|
490 | + } |
|
491 | + for ($j=0; $j<6; $j++) { |
|
492 | + $row[$j] = trim($row[$j]); |
|
493 | + } |
|
485 | 494 | $row[1] = utf8_decode($row[1]); |
486 | 495 | $row[4] = strtolower($row[4]); |
487 | 496 | $row[5] = strtolower($row[5]); |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | |
238 | 238 | /** |
239 | 239 | * Método que entrega el tipo de DTE |
240 | - * @return Tipo de dte, ej: 33 (factura electrónica) |
|
240 | + * @return string de dte, ej: 33 (factura electrónica) |
|
241 | 241 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
242 | 242 | * @version 2015-09-02 |
243 | 243 | */ |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | |
249 | 249 | /** |
250 | 250 | * Método que entrega el folio del DTE |
251 | - * @return Folio del DTE |
|
251 | + * @return string del DTE |
|
252 | 252 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
253 | 253 | * @version 2015-09-02 |
254 | 254 | */ |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | |
260 | 260 | /** |
261 | 261 | * Método que entrega rut del emisor del DTE |
262 | - * @return RUT del emiro |
|
262 | + * @return string del emiro |
|
263 | 263 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
264 | 264 | * @version 2015-09-07 |
265 | 265 | */ |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | |
276 | 276 | /** |
277 | 277 | * Método que entrega rut del receptor del DTE |
278 | - * @return RUT del emiro |
|
278 | + * @return string del emiro |
|
279 | 279 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
280 | 280 | * @version 2015-09-07 |
281 | 281 | */ |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | |
292 | 292 | /** |
293 | 293 | * Método que entrega fecha de emisión del DTE |
294 | - * @return Fecha de emisión en formato AAAA-MM-DD |
|
294 | + * @return string de emisión en formato AAAA-MM-DD |
|
295 | 295 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
296 | 296 | * @version 2015-09-07 |
297 | 297 | */ |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | |
401 | 401 | /** |
402 | 402 | * Método que realiza el timbrado del DTE |
403 | - * @param Folios Objeto de los Folios con los que se desea timbrar |
|
403 | + * @param Folios Folios de los Folios con los que se desea timbrar |
|
404 | 404 | * @return =true si se pudo timbrar o =false en caso de error |
405 | 405 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
406 | 406 | * @version 2016-09-01 |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | |
487 | 487 | /** |
488 | 488 | * Método que realiza la firma del DTE |
489 | - * @param Firma objeto que representa la Firma Electrónca |
|
489 | + * @param Firma \sasco\LibreDTE\FirmaElectronica que representa la Firma Electrónca |
|
490 | 490 | * @return =true si el DTE pudo ser fimado o =false si no se pudo firmar |
491 | 491 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
492 | 492 | * @version 2017-10-22 |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | |
510 | 510 | /** |
511 | 511 | * Método que entrega el DTE en XML |
512 | - * @return XML con el DTE (podría: con o sin timbre y con o sin firma) |
|
512 | + * @return string con el DTE (podría: con o sin timbre y con o sin firma) |
|
513 | 513 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
514 | 514 | * @version 2015-08-20 |
515 | 515 | */ |
@@ -1750,7 +1750,7 @@ discard block |
||
1750 | 1750 | * - Firma del DTE |
1751 | 1751 | * - RUT del emisor (si se pasó uno para comparar) |
1752 | 1752 | * - RUT del receptor (si se pasó uno para comparar) |
1753 | - * @return Código del estado de la validación |
|
1753 | + * @return integer del estado de la validación |
|
1754 | 1754 | * @warning No se está validando la firma |
1755 | 1755 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
1756 | 1756 | * @version 2015-09-08 |
@@ -1861,7 +1861,7 @@ discard block |
||
1861 | 1861 | |
1862 | 1862 | /** |
1863 | 1863 | * Método que obtiene el estado del DTE |
1864 | - * @param Firma objeto que representa la Firma Electrónca |
|
1864 | + * @param Firma \sasco\LibreDTE\FirmaElectronica que representa la Firma Electrónca |
|
1865 | 1865 | * @return Arreglo con el estado del DTE |
1866 | 1866 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
1867 | 1867 | * @version 2015-10-24 |
@@ -1902,7 +1902,7 @@ discard block |
||
1902 | 1902 | |
1903 | 1903 | /** |
1904 | 1904 | * Método que obtiene el estado avanzado del DTE |
1905 | - * @param Firma objeto que representa la Firma Electrónca |
|
1905 | + * @param Firma \sasco\LibreDTE\FirmaElectronica que representa la Firma Electrónca |
|
1906 | 1906 | * @return Arreglo con el estado del DTE |
1907 | 1907 | * @todo Corregir warning y también definir que se retornará (sobre todo en caso de error) |
1908 | 1908 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | ] |
140 | 140 | ]); |
141 | 141 | $parent = $this->xml->getElementsByTagName($this->tipo_general)->item(0); |
142 | - $this->xml->generate($datos + ['TED' => null], null, $parent); |
|
142 | + $this->xml->generate($datos+['TED' => null], null, $parent); |
|
143 | 143 | $this->datos = $datos; |
144 | 144 | if ($normalizar and !$this->verificarDatos()) { |
145 | 145 | return false; |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | $xml->documentElement->removeAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi'); |
383 | 383 | $xml->documentElement->removeAttributeNS('http://www.sii.cl/SiiDte', ''); |
384 | 384 | $TED = $xml->getFlattened('/'); |
385 | - return mb_detect_encoding($TED, ['UTF-8', 'ISO-8859-1']) != 'ISO-8859-1' ? utf8_decode($TED) : $TED; |
|
385 | + return mb_detect_encoding($TED, ['UTF-8', 'ISO-8859-1'])!='ISO-8859-1' ? utf8_decode($TED) : $TED; |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | /** |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | { |
396 | 396 | $datos = $this->getDatos(); |
397 | 397 | $idk = !empty($datos['TED']['DD']['CAF']['DA']['IDK']) ? (int)$datos['TED']['DD']['CAF']['DA']['IDK'] : null; |
398 | - return $idk ? $idk === 100 : null; |
|
398 | + return $idk ? $idk===100 : null; |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | /** |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | { |
530 | 530 | $this->getDatos(); |
531 | 531 | // generar resumen |
532 | - $resumen = [ |
|
532 | + $resumen = [ |
|
533 | 533 | 'TpoDoc' => (int)$this->datos['Encabezado']['IdDoc']['TipoDTE'], |
534 | 534 | 'NroDoc' => (int)$this->datos['Encabezado']['IdDoc']['Folio'], |
535 | 535 | 'TasaImp' => 0, |
@@ -574,17 +574,17 @@ discard block |
||
574 | 574 | */ |
575 | 575 | private function calcularNetoIVA($total, $tasa = null) |
576 | 576 | { |
577 | - if ($tasa === 0 or $tasa === false) |
|
577 | + if ($tasa===0 or $tasa===false) |
|
578 | 578 | return [0, 0]; |
579 | - if ($tasa === null) |
|
579 | + if ($tasa===null) |
|
580 | 580 | $tasa = \sasco\LibreDTE\Sii::getIVA(); |
581 | 581 | // WARNING: el IVA obtenido puede no ser el NETO*(TASA/100) |
582 | 582 | // se calcula el monto neto y luego se obtiene el IVA haciendo la resta |
583 | 583 | // entre el total y el neto, ya que hay casos de borde como: |
584 | 584 | // - BRUTO: 680 => NETO: 571 e IVA: 108 => TOTAL: 679 |
585 | 585 | // - BRUTO: 86710 => NETO: 72866 e IVA: 13845 => TOTAL: 86711 |
586 | - $neto = round($total / (1+($tasa/100))); |
|
587 | - $iva = $total - $neto; |
|
586 | + $neto = round($total / (1+($tasa / 100))); |
|
587 | + $iva = $total-$neto; |
|
588 | 588 | return [$neto, $iva]; |
589 | 589 | } |
590 | 590 | |
@@ -1418,12 +1418,12 @@ discard block |
||
1418 | 1418 | ); |
1419 | 1419 | // aplicar descuento |
1420 | 1420 | if ($d['DescuentoPct']) { |
1421 | - $d['DescuentoMonto'] = round($d['MontoItem'] * (int)$d['DescuentoPct']/100); |
|
1421 | + $d['DescuentoMonto'] = round($d['MontoItem'] * (int)$d['DescuentoPct'] / 100); |
|
1422 | 1422 | } |
1423 | 1423 | $d['MontoItem'] -= $d['DescuentoMonto']; |
1424 | 1424 | // aplicar recargo |
1425 | 1425 | if ($d['RecargoPct']) { |
1426 | - $d['RecargoMonto'] = round($d['MontoItem'] * (int)$d['RecargoPct']/100); |
|
1426 | + $d['RecargoMonto'] = round($d['MontoItem'] * (int)$d['RecargoPct'] / 100); |
|
1427 | 1427 | } |
1428 | 1428 | $d['MontoItem'] += $d['RecargoMonto']; |
1429 | 1429 | // aproximar monto del item |
@@ -1509,7 +1509,7 @@ discard block |
||
1509 | 1509 | } |
1510 | 1510 | $valor = |
1511 | 1511 | $dr['TpoValor']=='%' |
1512 | - ? $this->round(($dr['ValorDR']/100)*$datos['Encabezado']['Totales'][$monto], $datos['Encabezado']['Totales']['TpoMoneda']) |
|
1512 | + ? $this->round(($dr['ValorDR'] / 100) * $datos['Encabezado']['Totales'][$monto], $datos['Encabezado']['Totales']['TpoMoneda']) |
|
1513 | 1513 | : $dr['ValorDR'] |
1514 | 1514 | ; |
1515 | 1515 | // aplicar descuento |
@@ -1582,7 +1582,7 @@ discard block |
||
1582 | 1582 | // si el monto no existe se asigna |
1583 | 1583 | if ($datos['Encabezado']['Totales']['ImptoReten'][$i]['MontoImp']===null) { |
1584 | 1584 | $datos['Encabezado']['Totales']['ImptoReten'][$i]['MontoImp'] = round( |
1585 | - $neto * $datos['Encabezado']['Totales']['ImptoReten'][$i]['TasaImp']/100 |
|
1585 | + $neto * $datos['Encabezado']['Totales']['ImptoReten'][$i]['TasaImp'] / 100 |
|
1586 | 1586 | ); |
1587 | 1587 | } |
1588 | 1588 | } |
@@ -1590,7 +1590,7 @@ discard block |
||
1590 | 1590 | if (isset($datos['Encabezado']['Totales']['ImptoReten']) and is_array($datos['Encabezado']['Totales']['ImptoReten'])) { |
1591 | 1591 | $codigos = array_keys($montos); |
1592 | 1592 | $n_impuestos = count($datos['Encabezado']['Totales']['ImptoReten']); |
1593 | - for ($i=0; $i<$n_impuestos; $i++) { |
|
1593 | + for ($i = 0; $i<$n_impuestos; $i++) { |
|
1594 | 1594 | if (!in_array($datos['Encabezado']['Totales']['ImptoReten'][$i]['TipoImp'], $codigos)) { |
1595 | 1595 | unset($datos['Encabezado']['Totales']['ImptoReten'][$i]); |
1596 | 1596 | } |
@@ -1618,7 +1618,7 @@ discard block |
||
1618 | 1618 | } else { |
1619 | 1619 | if (empty($datos['Encabezado']['Totales']['IVA']) and !empty($datos['Encabezado']['Totales']['TasaIVA'])) { |
1620 | 1620 | $datos['Encabezado']['Totales']['IVA'] = round( |
1621 | - $datos['Encabezado']['Totales']['MntNeto']*($datos['Encabezado']['Totales']['TasaIVA']/100) |
|
1621 | + $datos['Encabezado']['Totales']['MntNeto'] * ($datos['Encabezado']['Totales']['TasaIVA'] / 100) |
|
1622 | 1622 | ); |
1623 | 1623 | } |
1624 | 1624 | } |
@@ -1642,7 +1642,7 @@ discard block |
||
1642 | 1642 | if (ImpuestosAdicionales::getTipo($ImptoReten['TipoImp'])=='R') { |
1643 | 1643 | $datos['Encabezado']['Totales']['MntTotal'] -= $ImptoReten['MontoImp']; |
1644 | 1644 | if ($ImptoReten['MontoImp']!=$datos['Encabezado']['Totales']['IVA']) { |
1645 | - $datos['Encabezado']['Totales']['IVANoRet'] = $datos['Encabezado']['Totales']['IVA'] - $ImptoReten['MontoImp']; |
|
1645 | + $datos['Encabezado']['Totales']['IVANoRet'] = $datos['Encabezado']['Totales']['IVA']-$ImptoReten['MontoImp']; |
|
1646 | 1646 | } |
1647 | 1647 | } |
1648 | 1648 | // si es adicional se suma al total |
@@ -1794,7 +1794,7 @@ discard block |
||
1794 | 1794 | $SignatureValue = $Signature->getElementsByTagName('SignatureValue')->item(0)->nodeValue; |
1795 | 1795 | $X509Certificate = $Signature->getElementsByTagName('X509Certificate')->item(0)->nodeValue; |
1796 | 1796 | $X509Certificate = '-----BEGIN CERTIFICATE-----'."\n".wordwrap(trim($X509Certificate), 64, "\n", true)."\n".'-----END CERTIFICATE----- '; |
1797 | - $valid = openssl_verify($SignedInfo->C14N(), base64_decode($SignatureValue), $X509Certificate) === 1 ? true : false; |
|
1797 | + $valid = openssl_verify($SignedInfo->C14N(), base64_decode($SignatureValue), $X509Certificate)===1 ? true : false; |
|
1798 | 1798 | return $valid; |
1799 | 1799 | //return $valid and $DigestValue===base64_encode(sha1($Documento->C14N(), true)); |
1800 | 1800 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | /** |
178 | 178 | * Método que asigna la ubicación del logo de la empresa |
179 | 179 | * @param logo URI del logo (puede ser local o en una URL) |
180 | - * @param posicion Posición respecto a datos del emisor (=0 izq, =1 arriba) |
|
180 | + * @param posicion integer respecto a datos del emisor (=0 izq, =1 arriba) |
|
181 | 181 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
182 | 182 | * @version 2016-08-04 |
183 | 183 | */ |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * contínuo |
357 | 357 | * @param dte Arreglo con los datos del XML (tag Documento) |
358 | 358 | * @param timbre String XML con el tag TED del DTE |
359 | - * @param width Ancho del papel contínuo en mm |
|
359 | + * @param width boolean del papel contínuo en mm |
|
360 | 360 | * @author Pablo Reyes (https://github.com/pabloxp) |
361 | 361 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
362 | 362 | * @version 2017-10-24 |
@@ -512,10 +512,11 @@ discard block |
||
512 | 512 | * - Dirección casa central del emisor |
513 | 513 | * - Dirección sucursales |
514 | 514 | * @param emisor Arreglo con los datos del emisor (tag Emisor del XML) |
515 | - * @param x Posición horizontal de inicio en el PDF |
|
516 | - * @param y Posición vertical de inicio en el PDF |
|
517 | - * @param w Ancho de la información del emisor |
|
518 | - * @param w_img Ancho máximo de la imagen |
|
515 | + * @param x integer horizontal de inicio en el PDF |
|
516 | + * @param y integer vertical de inicio en el PDF |
|
517 | + * @param w integer de la información del emisor |
|
518 | + * @param w_img integer máximo de la imagen |
|
519 | + * @param integer $font_size |
|
519 | 520 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
520 | 521 | * @version 2016-12-02 |
521 | 522 | */ |
@@ -586,11 +587,13 @@ discard block |
||
586 | 587 | * @param rut RUT del emisor |
587 | 588 | * @param tipo Código o glosa del tipo de documento |
588 | 589 | * @param sucursal_sii Código o glosa de la sucursal del SII del Emisor |
589 | - * @param x Posición horizontal de inicio en el PDF |
|
590 | - * @param y Posición vertical de inicio en el PDF |
|
591 | - * @param w Ancho de la información del emisor |
|
590 | + * @param x integer horizontal de inicio en el PDF |
|
591 | + * @param y integer vertical de inicio en el PDF |
|
592 | + * @param w integer de la información del emisor |
|
593 | + * @param integer $font_size |
|
592 | 594 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
593 | 595 | * @version 2016-12-02 |
596 | + * @return integer |
|
594 | 597 | */ |
595 | 598 | private function agregarFolio($rut, $tipo, $folio, $sucursal_sii = null, $x = 130, $y = 15, $w = 70, $font_size = null, array $color = null) |
596 | 599 | { |
@@ -636,7 +639,7 @@ discard block |
||
636 | 639 | * Método que agrega los datos de la emisión del DTE que no son los dato del |
637 | 640 | * receptor |
638 | 641 | * @param IdDoc Información general del documento |
639 | - * @param x Posición horizontal de inicio en el PDF |
|
642 | + * @param x integer horizontal de inicio en el PDF |
|
640 | 643 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
641 | 644 | * @version 2017-06-15 |
642 | 645 | */ |
@@ -724,7 +727,7 @@ discard block |
||
724 | 727 | /** |
725 | 728 | * Método que agrega los datos del receptor |
726 | 729 | * @param receptor Arreglo con los datos del receptor (tag Receptor del XML) |
727 | - * @param x Posición horizontal de inicio en el PDF |
|
730 | + * @param x integer horizontal de inicio en el PDF |
|
728 | 731 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
729 | 732 | * @version 2017-06-15 |
730 | 733 | */ |
@@ -811,7 +814,7 @@ discard block |
||
811 | 814 | * Método que agrega los datos del traslado |
812 | 815 | * @param IndTraslado |
813 | 816 | * @param Transporte |
814 | - * @param x Posición horizontal de inicio en el PDF |
|
817 | + * @param x integer horizontal de inicio en el PDF |
|
815 | 818 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
816 | 819 | * @version 2016-08-03 |
817 | 820 | */ |
@@ -882,7 +885,7 @@ discard block |
||
882 | 885 | /** |
883 | 886 | * Método que agrega las referencias del documento |
884 | 887 | * @param referencias Arreglo con las referencias del documento (tag Referencia del XML) |
885 | - * @param x Posición horizontal de inicio en el PDF |
|
888 | + * @param x integer horizontal de inicio en el PDF |
|
886 | 889 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
887 | 890 | * @version 2017-09-25 |
888 | 891 | */ |
@@ -919,7 +922,7 @@ discard block |
||
919 | 922 | /** |
920 | 923 | * Método que agrega el detalle del documento |
921 | 924 | * @param detalle Arreglo con el detalle del documento (tag Detalle del XML) |
922 | - * @param x Posición horizontal de inicio en el PDF |
|
925 | + * @param x integer horizontal de inicio en el PDF |
|
923 | 926 | * @param y Posición vertical de inicio en el PDF |
924 | 927 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
925 | 928 | * @version 2016-08-05 |
@@ -986,7 +989,7 @@ discard block |
||
986 | 989 | /** |
987 | 990 | * Método que agrega el detalle del documento |
988 | 991 | * @param detalle Arreglo con el detalle del documento (tag Detalle del XML) |
989 | - * @param x Posición horizontal de inicio en el PDF |
|
992 | + * @param x integer horizontal de inicio en el PDF |
|
990 | 993 | * @param y Posición vertical de inicio en el PDF |
991 | 994 | * @author Pablo Reyes (https://github.com/pabloxp) |
992 | 995 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
@@ -1022,7 +1025,7 @@ discard block |
||
1022 | 1025 | * Método que agrega el subtotal del DTE |
1023 | 1026 | * @param detalle Arreglo con los detalles del documentos para poder |
1024 | 1027 | * calcular subtotal |
1025 | - * @param x Posición horizontal de inicio en el PDF |
|
1028 | + * @param x integer horizontal de inicio en el PDF |
|
1026 | 1029 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
1027 | 1030 | * @version 2016-08-17 |
1028 | 1031 | */ |
@@ -1048,7 +1051,7 @@ discard block |
||
1048 | 1051 | /** |
1049 | 1052 | * Método que agrega los descuentos y/o recargos globales del documento |
1050 | 1053 | * @param descuentosRecargos Arreglo con los descuentos y/o recargos del documento (tag DscRcgGlobal del XML) |
1051 | - * @param x Posición horizontal de inicio en el PDF |
|
1054 | + * @param x integer horizontal de inicio en el PDF |
|
1052 | 1055 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
1053 | 1056 | * @version 2016-08-17 |
1054 | 1057 | */ |
@@ -1072,7 +1075,7 @@ discard block |
||
1072 | 1075 | /** |
1073 | 1076 | * Método que agrega los pagos del documento |
1074 | 1077 | * @param pagos Arreglo con los pagos del documento |
1075 | - * @param x Posición horizontal de inicio en el PDF |
|
1078 | + * @param x integer horizontal de inicio en el PDF |
|
1076 | 1079 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
1077 | 1080 | * @version 2016-07-24 |
1078 | 1081 | */ |
@@ -1209,9 +1212,9 @@ discard block |
||
1209 | 1212 | * - Se imprime en el tamaño mínimo: 2x5 cms |
1210 | 1213 | * - En el lado de abajo con margen izquierdo mínimo de 2 cms |
1211 | 1214 | * @param timbre String con los datos del timbre |
1212 | - * @param x Posición horizontal de inicio en el PDF |
|
1213 | - * @param y Posición vertical de inicio en el PDF |
|
1214 | - * @param w Ancho del timbre |
|
1215 | + * @param x integer horizontal de inicio en el PDF |
|
1216 | + * @param y integer vertical de inicio en el PDF |
|
1217 | + * @param w integer del timbre |
|
1215 | 1218 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
1216 | 1219 | * @version 2017-10-05 |
1217 | 1220 | */ |
@@ -1249,10 +1252,10 @@ discard block |
||
1249 | 1252 | |
1250 | 1253 | /** |
1251 | 1254 | * Método que agrega el acuse de rebido |
1252 | - * @param x Posición horizontal de inicio en el PDF |
|
1253 | - * @param y Posición vertical de inicio en el PDF |
|
1254 | - * @param w Ancho del acuse de recibo |
|
1255 | - * @param h Alto del acuse de recibo |
|
1255 | + * @param x integer horizontal de inicio en el PDF |
|
1256 | + * @param y integer vertical de inicio en el PDF |
|
1257 | + * @param w integer del acuse de recibo |
|
1258 | + * @param h integer del acuse de recibo |
|
1256 | 1259 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
1257 | 1260 | * @version 2017-10-05 |
1258 | 1261 | */ |
@@ -1280,10 +1283,10 @@ discard block |
||
1280 | 1283 | |
1281 | 1284 | /** |
1282 | 1285 | * Método que agrega el acuse de rebido |
1283 | - * @param x Posición horizontal de inicio en el PDF |
|
1286 | + * @param x integer horizontal de inicio en el PDF |
|
1284 | 1287 | * @param y Posición vertical de inicio en el PDF |
1285 | - * @param w Ancho del acuse de recibo |
|
1286 | - * @param h Alto del acuse de recibo |
|
1288 | + * @param w integer del acuse de recibo |
|
1289 | + * @param h integer del acuse de recibo |
|
1287 | 1290 | * @author Pablo Reyes (https://github.com/pabloxp) |
1288 | 1291 | * @version 2015-11-17 |
1289 | 1292 | */ |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | { |
172 | 172 | parent::__construct(); |
173 | 173 | $this->SetTitle('Documento Tributario Electrónico (DTE) de Chile by LibreDTE'); |
174 | - $this->papelContinuo = $papelContinuo === true ? 80 : $papelContinuo; |
|
174 | + $this->papelContinuo = $papelContinuo===true ? 80 : $papelContinuo; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | $this->setY(max($y)); |
317 | 317 | $this->Ln(); |
318 | 318 | $y = []; |
319 | - $y[] = $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor'])?$dte['Encabezado']['Emisor']['CdgVendedor']:null); |
|
319 | + $y[] = $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor']) ? $dte['Encabezado']['Emisor']['CdgVendedor'] : null); |
|
320 | 320 | $y[] = $this->agregarReceptor($dte['Encabezado']); |
321 | 321 | $this->setY(max($y)); |
322 | 322 | $this->agregarTraslado( |
@@ -376,15 +376,15 @@ discard block |
||
376 | 376 | $dte['Encabezado']['IdDoc']['TipoDTE'], |
377 | 377 | $dte['Encabezado']['IdDoc']['Folio'], |
378 | 378 | $dte['Encabezado']['Emisor']['CmnaOrigen'], |
379 | - $x_start, $y_start, $width-($x_start*4), 10, |
|
380 | - [0,0,0] |
|
379 | + $x_start, $y_start, $width-($x_start * 4), 10, |
|
380 | + [0, 0, 0] |
|
381 | 381 | ); |
382 | - $y = $this->agregarEmisor($dte['Encabezado']['Emisor'], $x_start, $y+2, 40, 8, 9, [0,0,0]); |
|
382 | + $y = $this->agregarEmisor($dte['Encabezado']['Emisor'], $x_start, $y+2, 40, 8, 9, [0, 0, 0]); |
|
383 | 383 | // datos del documento |
384 | 384 | $this->SetY($y); |
385 | 385 | $this->Ln(); |
386 | 386 | $this->setFont('', '', 8); |
387 | - $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor'])?$dte['Encabezado']['Emisor']['CdgVendedor']:null, $x_start, $offset, false); |
|
387 | + $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor']) ? $dte['Encabezado']['Emisor']['CdgVendedor'] : null, $x_start, $offset, false); |
|
388 | 388 | $this->agregarReceptor($dte['Encabezado'], $x_start, $offset); |
389 | 389 | $this->agregarTraslado( |
390 | 390 | !empty($dte['Encabezado']['IdDoc']['IndTraslado']) ? $dte['Encabezado']['IdDoc']['IndTraslado'] : null, |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | $this->AddPage('P', [$height ? $height : $this->papel_continuo_alto, $width]); |
438 | 438 | $x = 1; |
439 | 439 | $y = 5; |
440 | - $this->SetXY($x,$y); |
|
440 | + $this->SetXY($x, $y); |
|
441 | 441 | // agregar datos del documento |
442 | 442 | $this->setFont('', '', 8); |
443 | 443 | $this->MultiTexto(!empty($dte['Encabezado']['Emisor']['RznSoc']) ? $dte['Encabezado']['Emisor']['RznSoc'] : $dte['Encabezado']['Emisor']['RznSocEmisor'], $x, null, '', $width-2); |
@@ -527,13 +527,13 @@ discard block |
||
527 | 527 | $this->logo['uri'], |
528 | 528 | $x, |
529 | 529 | $y, |
530 | - !$this->logo['posicion']?$w_img:null, $this->logo['posicion']?($w_img/2):null, |
|
530 | + !$this->logo['posicion'] ? $w_img : null, $this->logo['posicion'] ? ($w_img / 2) : null, |
|
531 | 531 | 'PNG', |
532 | - (isset($emisor['url'])?$emisor['url']:''), |
|
532 | + (isset($emisor['url']) ? $emisor['url'] : ''), |
|
533 | 533 | 'T' |
534 | 534 | ); |
535 | 535 | if ($this->logo['posicion']) { |
536 | - $this->SetY($this->y + ($w_img/2)); |
|
536 | + $this->SetY($this->y+($w_img / 2)); |
|
537 | 537 | $w += 40; |
538 | 538 | } else { |
539 | 539 | $x = $this->x+3; |
@@ -544,14 +544,14 @@ discard block |
||
544 | 544 | } |
545 | 545 | // agregar datos del emisor |
546 | 546 | $this->setFont('', 'B', $font_size ? $font_size : 14); |
547 | - $this->SetTextColorArray($color===null?[32, 92, 144]:$color); |
|
547 | + $this->SetTextColorArray($color===null ? [32, 92, 144] : $color); |
|
548 | 548 | $this->MultiTexto(!empty($emisor['RznSoc']) ? $emisor['RznSoc'] : $emisor['RznSocEmisor'], $x, $this->y+2, 'L', $w); |
549 | 549 | $this->setFont('', 'B', $font_size ? $font_size : 9); |
550 | - $this->SetTextColorArray([0,0,0]); |
|
550 | + $this->SetTextColorArray([0, 0, 0]); |
|
551 | 551 | $this->MultiTexto(!empty($emisor['GiroEmis']) ? $emisor['GiroEmis'] : $emisor['GiroEmisor'], $x, $this->y, 'L', $w); |
552 | 552 | $comuna = !empty($emisor['CmnaOrigen']) ? $emisor['CmnaOrigen'] : null; |
553 | 553 | $ciudad = !empty($emisor['CiudadOrigen']) ? $emisor['CiudadOrigen'] : \sasco\LibreDTE\Chile::getCiudad($comuna); |
554 | - $this->MultiTexto($emisor['DirOrigen'].($comuna?(', '.$comuna):'').($ciudad?(', '.$ciudad):''), $x, $this->y, 'L', $w); |
|
554 | + $this->MultiTexto($emisor['DirOrigen'].($comuna ? (', '.$comuna) : '').($ciudad ? (', '.$ciudad) : ''), $x, $this->y, 'L', $w); |
|
555 | 555 | if (!empty($emisor['Sucursal'])) { |
556 | 556 | $this->MultiTexto('Sucursal: '.$emisor['Sucursal'], $x, $this->y, 'L', $w); |
557 | 557 | } |
@@ -595,12 +595,12 @@ discard block |
||
595 | 595 | private function agregarFolio($rut, $tipo, $folio, $sucursal_sii = null, $x = 130, $y = 15, $w = 70, $font_size = null, array $color = null) |
596 | 596 | { |
597 | 597 | if ($color===null) { |
598 | - $color = $tipo ? ($tipo==52 ? [0,172,140] : [255,0,0]) : [0,0,0]; |
|
598 | + $color = $tipo ? ($tipo==52 ? [0, 172, 140] : [255, 0, 0]) : [0, 0, 0]; |
|
599 | 599 | } |
600 | 600 | $this->SetTextColorArray($color); |
601 | 601 | // colocar rut emisor, glosa documento y folio |
602 | 602 | list($rut, $dv) = explode('-', $rut); |
603 | - $this->setFont ('', 'B', $font_size ? $font_size : 15); |
|
603 | + $this->setFont('', 'B', $font_size ? $font_size : 15); |
|
604 | 604 | $this->MultiTexto('R.U.T.: '.$this->num($rut).'-'.$dv, $x, $y+4, 'C', $w); |
605 | 605 | $this->setFont('', 'B', $font_size ? $font_size : 12); |
606 | 606 | $this->MultiTexto($this->getTipo($tipo), $x, null, 'C', $w); |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | if ($tipo) { |
614 | 614 | $this->Texto('S.I.I. - '.\sasco\LibreDTE\Sii::getDireccionRegional($sucursal_sii), $x, $this->getY()+4, 'C', $w); |
615 | 615 | } |
616 | - $this->SetTextColorArray([0,0,0]); |
|
616 | + $this->SetTextColorArray([0, 0, 0]); |
|
617 | 617 | $this->Ln(); |
618 | 618 | return $this->y; |
619 | 619 | } |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | $this->Texto('Señor(es)', $x); |
745 | 745 | $this->Texto(':', $x+$offset); |
746 | 746 | $this->setFont('', '', null); |
747 | - $this->MultiTexto($receptor['RznSocRecep'], $x+$offset+2, null, '', $x==10?105:0); |
|
747 | + $this->MultiTexto($receptor['RznSocRecep'], $x+$offset+2, null, '', $x==10 ? 105 : 0); |
|
748 | 748 | } |
749 | 749 | if (!empty($receptor['GiroRecep'])) { |
750 | 750 | $this->setFont('', 'B', null); |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | $ciudad = !empty($receptor['CiudadRecep']) ? $receptor['CiudadRecep'] : ( |
762 | 762 | !empty($receptor['CmnaRecep']) ? \sasco\LibreDTE\Chile::getCiudad($receptor['CmnaRecep']) : '' |
763 | 763 | ); |
764 | - $this->MultiTexto($receptor['DirRecep'].(!empty($receptor['CmnaRecep'])?(', '.$receptor['CmnaRecep']):'').($ciudad?(', '.$ciudad):''), $x+$offset+2); |
|
764 | + $this->MultiTexto($receptor['DirRecep'].(!empty($receptor['CmnaRecep']) ? (', '.$receptor['CmnaRecep']) : '').($ciudad ? (', '.$ciudad) : ''), $x+$offset+2); |
|
765 | 765 | } |
766 | 766 | if (!empty($receptor['Extranjero']['Nacionalidad'])) { |
767 | 767 | $this->setFont('', 'B', null); |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | $this->Texto('Cód. recep.', $x); |
803 | 803 | $this->Texto(':', $x+$offset); |
804 | 804 | $this->setFont('', '', null); |
805 | - $this->MultiTexto($receptor['CdgIntRecep'], $x+$offset+2, null, '', $x==10?105:0); |
|
805 | + $this->MultiTexto($receptor['CdgIntRecep'], $x+$offset+2, null, '', $x==10 ? 105 : 0); |
|
806 | 806 | } |
807 | 807 | return $this->GetY(); |
808 | 808 | } |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | { |
891 | 891 | if (!isset($referencias[0])) |
892 | 892 | $referencias = [$referencias]; |
893 | - foreach($referencias as $r) { |
|
893 | + foreach ($referencias as $r) { |
|
894 | 894 | $texto = $r['NroLinRef'].' - '; |
895 | 895 | if (!empty($r['TpoDocRef'])) { |
896 | 896 | $texto .= $this->getTipo($r['TpoDocRef']).' '; |
@@ -997,9 +997,9 @@ discard block |
||
997 | 997 | $this->SetY($this->getY()+1); |
998 | 998 | $p1x = $x; |
999 | 999 | $p1y = $this->y; |
1000 | - $p2x = $this->getPageWidth() - 2; |
|
1001 | - $p2y = $p1y; // Use same y for a straight line |
|
1002 | - $style = array('width' => 0.2,'color' => array(0, 0, 0)); |
|
1000 | + $p2x = $this->getPageWidth()-2; |
|
1001 | + $p2y = $p1y; // Use same y for a straight line |
|
1002 | + $style = array('width' => 0.2, 'color' => array(0, 0, 0)); |
|
1003 | 1003 | $this->Line($p1x, $p1y, $p2x, $p2y, $style); |
1004 | 1004 | $this->Texto($this->detalle_cols['NmbItem']['title'], $x+1, $this->y, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']); |
1005 | 1005 | $this->Texto($this->detalle_cols['PrcItem']['title'], $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']); |
@@ -1009,9 +1009,9 @@ discard block |
||
1009 | 1009 | if (!isset($detalle[0])) |
1010 | 1010 | $detalle = [$detalle]; |
1011 | 1011 | $this->SetY($this->getY()+2); |
1012 | - foreach($detalle as &$d) { |
|
1012 | + foreach ($detalle as &$d) { |
|
1013 | 1013 | $this->MultiTexto($d['NmbItem'], $x+1, $this->y+4, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']); |
1014 | - $this->Texto(number_format($d['PrcItem'],0,',','.'), $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']); |
|
1014 | + $this->Texto(number_format($d['PrcItem'], 0, ',', '.'), $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']); |
|
1015 | 1015 | $this->Texto($this->num($d['QtyItem']), $x+35, $this->y, ucfirst($this->detalle_cols['QtyItem']['align'][0]), $this->detalle_cols['QtyItem']['width']); |
1016 | 1016 | $this->Texto($this->num($d['MontoItem']), $x+45, $this->y, ucfirst($this->detalle_cols['MontoItem']['align'][0]), $this->detalle_cols['MontoItem']['width']); |
1017 | 1017 | } |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | if (!isset($detalle[0])) { |
1032 | 1032 | $detalle = [$detalle]; |
1033 | 1033 | } |
1034 | - foreach($detalle as &$d) { |
|
1034 | + foreach ($detalle as &$d) { |
|
1035 | 1035 | if (!empty($d['MontoItem'])) { |
1036 | 1036 | $subtotal += $d['MontoItem']; |
1037 | 1037 | } |
@@ -1056,13 +1056,13 @@ discard block |
||
1056 | 1056 | { |
1057 | 1057 | if (!isset($descuentosRecargos[0])) |
1058 | 1058 | $descuentosRecargos = [$descuentosRecargos]; |
1059 | - foreach($descuentosRecargos as $dr) { |
|
1059 | + foreach ($descuentosRecargos as $dr) { |
|
1060 | 1060 | $tipo = $dr['TpoMov']=='D' ? 'Descuento' : 'Recargo'; |
1061 | 1061 | $valor = $dr['TpoValor']=='%' ? $dr['ValorDR'].'%' : $this->num($dr['ValorDR']); |
1062 | 1062 | if ($this->papelContinuo) { |
1063 | - $this->Texto($tipo.' global: '.$valor.(!empty($dr['GlosaDR'])?(' ('.$dr['GlosaDR'].')'):''), $x); |
|
1063 | + $this->Texto($tipo.' global: '.$valor.(!empty($dr['GlosaDR']) ? (' ('.$dr['GlosaDR'].')') : ''), $x); |
|
1064 | 1064 | } else { |
1065 | - $this->Texto($tipo.(!empty($dr['GlosaDR'])?(' ('.$dr['GlosaDR'].')'):'').':', 77, null, 'R', 100); |
|
1065 | + $this->Texto($tipo.(!empty($dr['GlosaDR']) ? (' ('.$dr['GlosaDR'].')') : '').':', 77, null, 'R', 100); |
|
1066 | 1066 | $this->Texto($valor, 177, null, 'R', 22); |
1067 | 1067 | } |
1068 | 1068 | $this->Ln(); |
@@ -1082,8 +1082,8 @@ discard block |
||
1082 | 1082 | $pagos = [$pagos]; |
1083 | 1083 | $this->Texto('Pago(s) programado(s):', $x); |
1084 | 1084 | $this->Ln(); |
1085 | - foreach($pagos as $p) { |
|
1086 | - $this->Texto(' - '.$this->date($p['FchPago'], false).': $'.$this->num($p['MntPago']).'.-'.(!empty($p['GlosaPagos'])?(' ('.$p['GlosaPagos'].')'):''), $x); |
|
1085 | + foreach ($pagos as $p) { |
|
1086 | + $this->Texto(' - '.$this->date($p['FchPago'], false).': $'.$this->num($p['MntPago']).'.-'.(!empty($p['GlosaPagos']) ? (' ('.$p['GlosaPagos'].')') : ''), $x); |
|
1087 | 1087 | $this->Ln(); |
1088 | 1088 | } |
1089 | 1089 | } |
@@ -1134,7 +1134,7 @@ discard block |
||
1134 | 1134 | if (!isset($ImptoReten[0])) { |
1135 | 1135 | $ImptoReten = [$ImptoReten]; |
1136 | 1136 | } |
1137 | - foreach($ImptoReten as $i) { |
|
1137 | + foreach ($ImptoReten as $i) { |
|
1138 | 1138 | $totales['ImptoReten_'.$i['TipoImp']] = $i['MontoImp']; |
1139 | 1139 | if (!empty($i['TasaImp'])) { |
1140 | 1140 | $glosas['ImptoReten_'.$i['TipoImp']] = \sasco\LibreDTE\Sii\ImpuestosAdicionales::getGlosa($i['TipoImp']).' ('.$i['TasaImp'].'%) $'; |
@@ -1226,7 +1226,7 @@ discard block |
||
1226 | 1226 | 'vpadding' => 0, |
1227 | 1227 | 'module_width' => 1, // width of a single module in points |
1228 | 1228 | 'module_height' => 1, // height of a single module in points |
1229 | - 'fgcolor' => [0,0,0], |
|
1229 | + 'fgcolor' => [0, 0, 0], |
|
1230 | 1230 | 'bgcolor' => false, // [255,255,255] |
1231 | 1231 | 'position' => $this->papelContinuo ? 'C' : 'S', |
1232 | 1232 | ]; |
@@ -1259,7 +1259,7 @@ discard block |
||
1259 | 1259 | private function agregarAcuseRecibo($x = 93, $y = 190, $w = 50, $h = 40) |
1260 | 1260 | { |
1261 | 1261 | $y = (!$this->papelContinuo and !$this->timbre_pie) ? $this->x_fin_datos : $y; |
1262 | - $this->SetTextColorArray([0,0,0]); |
|
1262 | + $this->SetTextColorArray([0, 0, 0]); |
|
1263 | 1263 | $this->Rect($x, $y, $w, $h, 'D', ['all' => ['width' => 0.1, 'color' => [0, 0, 0]]]); |
1264 | 1264 | $this->setFont('', 'B', 10); |
1265 | 1265 | $this->Texto('Acuse de recibo', $x, $y+1, 'C', $w); |
@@ -1289,9 +1289,9 @@ discard block |
||
1289 | 1289 | */ |
1290 | 1290 | private function agregarAcuseReciboContinuo($x = 3, $y = null, $w = 68, $h = 40) |
1291 | 1291 | { |
1292 | - $this->SetTextColorArray([0,0,0]); |
|
1292 | + $this->SetTextColorArray([0, 0, 0]); |
|
1293 | 1293 | $this->Rect($x, $y, $w, $h, 'D', ['all' => ['width' => 0.1, 'color' => [0, 0, 0]]]); |
1294 | - $style = array('width' => 0.2,'color' => array(0, 0, 0)); |
|
1294 | + $style = array('width' => 0.2, 'color' => array(0, 0, 0)); |
|
1295 | 1295 | $this->Line($x, $y+22, $w+3, $y+22, $style); |
1296 | 1296 | //$this->setFont('', 'B', 10); |
1297 | 1297 | //$this->Texto('Acuse de recibo', $x, $y+1, 'C', $w); |
@@ -1321,7 +1321,7 @@ discard block |
||
1321 | 1321 | $y = (!$this->papelContinuo and !$this->timbre_pie) ? $this->x_fin_datos : $y; |
1322 | 1322 | $y += 64; |
1323 | 1323 | $this->setFont('', 'B', $font_size); |
1324 | - $this->Texto('CEDIBLE'.($tipo==52?' CON SU FACTURA':''), null, $y, 'R'); |
|
1324 | + $this->Texto('CEDIBLE'.($tipo==52 ? ' CON SU FACTURA' : ''), null, $y, 'R'); |
|
1325 | 1325 | } |
1326 | 1326 | |
1327 | 1327 | /** |
@@ -1332,7 +1332,7 @@ discard block |
||
1332 | 1332 | private function agregarLeyendaDestinoContinuo($tipo) |
1333 | 1333 | { |
1334 | 1334 | $this->setFont('', 'B', 8); |
1335 | - $this->Texto('CEDIBLE'.($tipo==52?' CON SU FACTURA':''), null, $this->y+6, 'R'); |
|
1335 | + $this->Texto('CEDIBLE'.($tipo==52 ? ' CON SU FACTURA' : ''), null, $this->y+6, 'R'); |
|
1336 | 1336 | } |
1337 | 1337 | |
1338 | 1338 | /** |
@@ -1363,7 +1363,7 @@ discard block |
||
1363 | 1363 | $dias = ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado']; |
1364 | 1364 | $meses = ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre']; |
1365 | 1365 | $unixtime = strtotime($date); |
1366 | - $fecha = date(($mostrar_dia?'\D\I\A ':'').'j \d\e \M\E\S \d\e\l Y', $unixtime); |
|
1366 | + $fecha = date(($mostrar_dia ? '\D\I\A ' : '').'j \d\e \M\E\S \d\e\l Y', $unixtime); |
|
1367 | 1367 | $dia = $dias[date('w', $unixtime)]; |
1368 | 1368 | $mes = $meses[date('n', $unixtime)-1]; |
1369 | 1369 | return str_replace(array('DIA', 'MES'), array($dia, $mes), $fecha); |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | * Método que genera nodos XML a partir de un arreglo |
53 | 53 | * @param data Arreglo con los datos que se usarán para generar XML |
54 | 54 | * @param namespace Arreglo con el espacio de nombres para el XML que se generará (URI y prefijo) |
55 | - * @param parent DOMElement padre para los elementos, o =null para que sea la raíz |
|
56 | - * @return Objeto \sasco\LibreDTE\XML |
|
55 | + * @param parent \DOMElement padre para los elementos, o =null para que sea la raíz |
|
56 | + * @return XML \sasco\LibreDTE\XML |
|
57 | 57 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
58 | 58 | * @version 2017-10-22 |
59 | 59 | */ |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | /** |
154 | 154 | * Método para realizar consultas XPATH al documento XML |
155 | 155 | * @param expression Expresión XPath a ejecutar |
156 | - * @return DOMNodeList |
|
156 | + * @return \DOMNodeList |
|
157 | 157 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
158 | 158 | * @version 2015-08-05 |
159 | 159 | */ |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * Método que cuenta los nodos con el mismo nombre hijos deun DOMElement |
275 | 275 | * No sirve usar: $dom->getElementsByTagName($tagName)->length ya que esto |
276 | 276 | * entrega todos los nodos con el nombre, sean hijos, nietos, etc. |
277 | - * @return Cantidad de nodos hijos con el mismo nombre en el DOMElement |
|
277 | + * @return integer de nodos hijos con el mismo nombre en el DOMElement |
|
278 | 278 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
279 | 279 | * @version 2015-09-07 |
280 | 280 | */ |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | |
315 | 315 | /** |
316 | 316 | * Método que entrega el nombre del archivo del schema del XML |
317 | - * @return Nombre del schema o bien =false si no se encontró |
|
317 | + * @return string del schema o bien =false si no se encontró |
|
318 | 318 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
319 | 319 | * @version 2015-12-14 |
320 | 320 | */ |
@@ -356,6 +356,7 @@ discard block |
||
356 | 356 | * respeta el estándar y las requiere convertidas |
357 | 357 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
358 | 358 | * @version 2017-01-20 |
359 | + * @param string $xml |
|
359 | 360 | */ |
360 | 361 | private function fixEntities($xml) |
361 | 362 | { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
58 | 58 | * @version 2017-10-22 |
59 | 59 | */ |
60 | - public function generate(array $data, array $namespace = null, \DOMElement &$parent = null) |
|
60 | + public function generate(array $data, array $namespace = null, \DOMElement & $parent = null) |
|
61 | 61 | { |
62 | 62 | if ($parent===null) { |
63 | 63 | $parent = &$this; |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | */ |
198 | 198 | private function utf2iso($string) |
199 | 199 | { |
200 | - return mb_detect_encoding($string, ['UTF-8', 'ISO-8859-1']) != 'ISO-8859-1' ? utf8_decode($string) : $string; |
|
200 | + return mb_detect_encoding($string, ['UTF-8', 'ISO-8859-1'])!='ISO-8859-1' ? utf8_decode($string) : $string; |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | } |
238 | 238 | // agregar nodos hijos |
239 | 239 | if ($dom->hasChildNodes()) { |
240 | - foreach($dom->childNodes as $child) { |
|
240 | + foreach ($dom->childNodes as $child) { |
|
241 | 241 | if ($child instanceof \DOMText) { |
242 | 242 | $textContent = trim($child->textContent); |
243 | 243 | if ($textContent!="") { |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | $newXML = ''; |
363 | 363 | $n_letras = strlen($xml); |
364 | 364 | $convertir = false; |
365 | - for ($i=0; $i<$n_letras; ++$i) { |
|
365 | + for ($i = 0; $i<$n_letras; ++$i) { |
|
366 | 366 | if ($xml[$i]=='>') |
367 | 367 | $convertir = true; |
368 | 368 | if ($xml[$i]=='<') |
@@ -120,8 +120,9 @@ discard block |
||
120 | 120 | private function sanitize($txt) |
121 | 121 | { |
122 | 122 | // si no se paso un texto o bien es un número no se hace nada |
123 | - if (!$txt or is_numeric($txt)) |
|
124 | - return $txt; |
|
123 | + if (!$txt or is_numeric($txt)) { |
|
124 | + return $txt; |
|
125 | + } |
|
125 | 126 | // convertir "predefined entities" de XML |
126 | 127 | $txt = str_replace( |
127 | 128 | ['&', '&', '<', '<', '>', '>', '"', '"', ''', '''], |
@@ -174,8 +175,9 @@ discard block |
||
174 | 175 | { |
175 | 176 | if ($xpath) { |
176 | 177 | $node = $this->xpath($xpath)->item(0); |
177 | - if (!$node) |
|
178 | - return false; |
|
178 | + if (!$node) { |
|
179 | + return false; |
|
180 | + } |
|
179 | 181 | $xml = $this->utf2iso($node->C14N()); |
180 | 182 | $xml = $this->fixEntities($xml); |
181 | 183 | } else { |
@@ -222,12 +224,15 @@ discard block |
||
222 | 224 | public function toArray(\DOMElement $dom = null, array &$array = null, $arregloNodos = false) |
223 | 225 | { |
224 | 226 | // determinar valores de parámetros |
225 | - if (!$dom) |
|
226 | - $dom = $this->documentElement; |
|
227 | - if (!$dom) |
|
228 | - return false; |
|
229 | - if ($array===null) |
|
230 | - $array = [$dom->tagName => null]; |
|
227 | + if (!$dom) { |
|
228 | + $dom = $this->documentElement; |
|
229 | + } |
|
230 | + if (!$dom) { |
|
231 | + return false; |
|
232 | + } |
|
233 | + if ($array===null) { |
|
234 | + $array = [$dom->tagName => null]; |
|
235 | + } |
|
231 | 236 | // agregar atributos del nodo |
232 | 237 | if ($dom->hasAttributes()) { |
233 | 238 | $array[$dom->tagName]['@attributes'] = []; |
@@ -243,22 +248,24 @@ discard block |
||
243 | 248 | if ($textContent!="") { |
244 | 249 | if ($dom->childNodes->length==1 and empty($array[$dom->tagName])) { |
245 | 250 | $array[$dom->tagName] = $textContent; |
246 | - } else |
|
247 | - $array[$dom->tagName]['@value'] = $textContent; |
|
251 | + } else { |
|
252 | + $array[$dom->tagName]['@value'] = $textContent; |
|
253 | + } |
|
248 | 254 | } |
249 | - } |
|
250 | - else if ($child instanceof \DOMElement) { |
|
255 | + } else if ($child instanceof \DOMElement) { |
|
251 | 256 | $nodos_gemelos = $this->countTwins($dom, $child->tagName); |
252 | 257 | if ($nodos_gemelos==1) { |
253 | - if ($arregloNodos) |
|
254 | - $this->toArray($child, $array); |
|
255 | - else |
|
256 | - $this->toArray($child, $array[$dom->tagName]); |
|
258 | + if ($arregloNodos) { |
|
259 | + $this->toArray($child, $array); |
|
260 | + } else { |
|
261 | + $this->toArray($child, $array[$dom->tagName]); |
|
262 | + } |
|
257 | 263 | } |
258 | 264 | // crear arreglo con nodos hijos que tienen el mismo nombre de tag |
259 | 265 | else { |
260 | - if (!isset($array[$dom->tagName][$child->tagName])) |
|
261 | - $array[$dom->tagName][$child->tagName] = []; |
|
266 | + if (!isset($array[$dom->tagName][$child->tagName])) { |
|
267 | + $array[$dom->tagName][$child->tagName] = []; |
|
268 | + } |
|
262 | 269 | $siguiente = count($array[$dom->tagName][$child->tagName]); |
263 | 270 | $array[$dom->tagName][$child->tagName][$siguiente] = []; |
264 | 271 | $this->toArray($child, $array[$dom->tagName][$child->tagName][$siguiente], true); |
@@ -282,8 +289,9 @@ discard block |
||
282 | 289 | { |
283 | 290 | $twins = 0; |
284 | 291 | foreach ($dom->childNodes as $child) { |
285 | - if ($child instanceof \DOMElement and $child->tagName==$tagName) |
|
286 | - $twins++; |
|
292 | + if ($child instanceof \DOMElement and $child->tagName==$tagName) { |
|
293 | + $twins++; |
|
294 | + } |
|
287 | 295 | } |
288 | 296 | return $twins; |
289 | 297 | } |
@@ -297,8 +305,9 @@ discard block |
||
297 | 305 | public function getErrors() |
298 | 306 | { |
299 | 307 | $errors = []; |
300 | - foreach (libxml_get_errors() as $e) |
|
301 | - $errors[] = $e->message; |
|
308 | + foreach (libxml_get_errors() as $e) { |
|
309 | + $errors[] = $e->message; |
|
310 | + } |
|
302 | 311 | return $errors; |
303 | 312 | } |
304 | 313 | |
@@ -321,8 +330,9 @@ discard block |
||
321 | 330 | public function getSchema() |
322 | 331 | { |
323 | 332 | $schemaLocation = $this->documentElement->getAttribute('xsi:schemaLocation'); |
324 | - if (!$schemaLocation or strpos($schemaLocation, ' ')===false) |
|
325 | - return false; |
|
333 | + if (!$schemaLocation or strpos($schemaLocation, ' ')===false) { |
|
334 | + return false; |
|
335 | + } |
|
326 | 336 | list($uri, $xsd) = explode(' ', $schemaLocation); |
327 | 337 | return $xsd; |
328 | 338 | } |
@@ -363,10 +373,12 @@ discard block |
||
363 | 373 | $n_letras = strlen($xml); |
364 | 374 | $convertir = false; |
365 | 375 | for ($i=0; $i<$n_letras; ++$i) { |
366 | - if ($xml[$i]=='>') |
|
367 | - $convertir = true; |
|
368 | - if ($xml[$i]=='<') |
|
369 | - $convertir = false; |
|
376 | + if ($xml[$i]=='>') { |
|
377 | + $convertir = true; |
|
378 | + } |
|
379 | + if ($xml[$i]=='<') { |
|
380 | + $convertir = false; |
|
381 | + } |
|
370 | 382 | if ($convertir) { |
371 | 383 | $l = $xml[$i]=='\'' ? ''' : ($xml[$i]=='"' ? '"' : $xml[$i]); |
372 | 384 | } else { |
@@ -102,10 +102,12 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function agregar(array $detalle, $normalizar = true) |
104 | 104 | { |
105 | - if ($normalizar) |
|
106 | - $this->normalizarDetalle($detalle); |
|
107 | - if (!$detalle['TpoDoc']) |
|
108 | - return false; |
|
105 | + if ($normalizar) { |
|
106 | + $this->normalizarDetalle($detalle); |
|
107 | + } |
|
108 | + if (!$detalle['TpoDoc']) { |
|
109 | + return false; |
|
110 | + } |
|
109 | 111 | $this->detalles[] = $detalle; |
110 | 112 | return true; |
111 | 113 | } |
@@ -174,8 +176,9 @@ discard block |
||
174 | 176 | } |
175 | 177 | // calcular valores que no se hayan entregado |
176 | 178 | if (isset($detalle['FctProp'])) { |
177 | - if ($detalle['IVAUsoComun']===false) |
|
178 | - $detalle['IVAUsoComun'] = round($detalle['MntNeto'] * ($detalle['TasaImp']/100)); |
|
179 | + if ($detalle['IVAUsoComun']===false) { |
|
180 | + $detalle['IVAUsoComun'] = round($detalle['MntNeto'] * ($detalle['TasaImp']/100)); |
|
181 | + } |
|
179 | 182 | } else if (!$detalle['MntIVA'] and !is_array($detalle['IVANoRec']) and $detalle['TasaImp'] and $detalle['MntNeto']) { |
180 | 183 | $detalle['MntIVA'] = round($detalle['MntNeto'] * ($detalle['TasaImp']/100)); |
181 | 184 | } |
@@ -185,8 +188,9 @@ discard block |
||
185 | 188 | } |
186 | 189 | // normalizar IVA no recuperable |
187 | 190 | if (!empty($detalle['IVANoRec'])) { |
188 | - if (!isset($detalle['IVANoRec'][0])) |
|
189 | - $detalle['IVANoRec'] = [$detalle['IVANoRec']]; |
|
191 | + if (!isset($detalle['IVANoRec'][0])) { |
|
192 | + $detalle['IVANoRec'] = [$detalle['IVANoRec']]; |
|
193 | + } |
|
190 | 194 | // si son múltiples iva no recuperable se arma arreglo real |
191 | 195 | if (strpos($detalle['IVANoRec'][0]['CodIVANoRec'], ',')) { |
192 | 196 | $CodIVANoRec = explode(',', $detalle['IVANoRec'][0]['CodIVANoRec']); |
@@ -203,8 +207,9 @@ discard block |
||
203 | 207 | } |
204 | 208 | // normalizar otros impuestos |
205 | 209 | if (!empty($detalle['OtrosImp'])) { |
206 | - if (!isset($detalle['OtrosImp'][0])) |
|
207 | - $detalle['OtrosImp'] = [$detalle['OtrosImp']]; |
|
210 | + if (!isset($detalle['OtrosImp'][0])) { |
|
211 | + $detalle['OtrosImp'] = [$detalle['OtrosImp']]; |
|
212 | + } |
|
208 | 213 | // si son múltiples impuestos se arma arreglo real |
209 | 214 | if (strpos($detalle['OtrosImp'][0]['CodImp'], ',')) { |
210 | 215 | $CodImp = explode(',', $detalle['OtrosImp'][0]['CodImp']); |
@@ -265,8 +270,9 @@ discard block |
||
265 | 270 | } |
266 | 271 | // si el código de sucursal no existe se pone a falso, esto básicamente |
267 | 272 | // porque algunos sistemas podrían usar 0 cuando no hay CdgSIISucur |
268 | - if (!$detalle['CdgSIISucur']) |
|
269 | - $detalle['CdgSIISucur'] = false; |
|
273 | + if (!$detalle['CdgSIISucur']) { |
|
274 | + $detalle['CdgSIISucur'] = false; |
|
275 | + } |
|
270 | 276 | } |
271 | 277 | |
272 | 278 | /** |
@@ -521,8 +527,9 @@ discard block |
||
521 | 527 | 'TipoEnvio' => 'TOTAL', |
522 | 528 | 'FolioNotificacion' => false, |
523 | 529 | ], $caratula); |
524 | - if ($this->caratula['TipoEnvio']=='ESPECIAL') |
|
525 | - $this->caratula['FolioNotificacion'] = null; |
|
530 | + if ($this->caratula['TipoEnvio']=='ESPECIAL') { |
|
531 | + $this->caratula['FolioNotificacion'] = null; |
|
532 | + } |
|
526 | 533 | $this->id = 'LibreDTE_LIBRO_'.$this->caratula['TipoOperacion'].'_'.str_replace('-', '', $this->caratula['RutEmisorLibro']).'_'.str_replace('-', '', $this->caratula['PeriodoTributario']).'_'.date('U'); |
527 | 534 | } |
528 | 535 | |
@@ -536,8 +543,9 @@ discard block |
||
536 | 543 | public function generar($incluirDetalle = true) |
537 | 544 | { |
538 | 545 | // si ya se había generado se entrega directamente |
539 | - if ($this->xml_data) |
|
540 | - return $this->xml_data; |
|
546 | + if ($this->xml_data) { |
|
547 | + return $this->xml_data; |
|
548 | + } |
|
541 | 549 | // generar totales de DTE y sus montos |
542 | 550 | $TotalesPeriodo = $this->getResumen(); |
543 | 551 | $ResumenPeriodo = $TotalesPeriodo ? ['TotalesPeriodo'=>$TotalesPeriodo] : false; |
@@ -702,8 +710,9 @@ discard block |
||
702 | 710 | $manual = []; |
703 | 711 | if (isset($this->toArray()['LibroCompraVenta']['EnvioLibro']['ResumenPeriodo']['TotalesPeriodo'])) { |
704 | 712 | $totales = $this->toArray()['LibroCompraVenta']['EnvioLibro']['ResumenPeriodo']['TotalesPeriodo']; |
705 | - if (!isset($totales[0])) |
|
706 | - $totales = [$totales]; |
|
713 | + if (!isset($totales[0])) { |
|
714 | + $totales = [$totales]; |
|
715 | + } |
|
707 | 716 | foreach ($totales as $total) { |
708 | 717 | if (isset($total['TpoDoc']) and in_array($total['TpoDoc'], [35, 38, 48])) { |
709 | 718 | $manual[$total['TpoDoc']] = array_merge($this->total_default, $total); |
@@ -723,8 +732,9 @@ discard block |
||
723 | 732 | $manual = []; |
724 | 733 | if (isset($this->toArray()['LibroCompraVenta']['EnvioLibro']['ResumenPeriodo']['TotalesPeriodo'])) { |
725 | 734 | $totales = $this->toArray()['LibroCompraVenta']['EnvioLibro']['ResumenPeriodo']['TotalesPeriodo']; |
726 | - if (!isset($totales[0])) |
|
727 | - $totales = [$totales]; |
|
735 | + if (!isset($totales[0])) { |
|
736 | + $totales = [$totales]; |
|
737 | + } |
|
728 | 738 | foreach ($totales as $total) { |
729 | 739 | if (in_array($total['TpoDoc'], [39, 41])) { |
730 | 740 | $manual[$total['TpoDoc']] = array_merge($this->total_default, $total); |
@@ -154,8 +154,9 @@ discard block |
||
154 | 154 | foreach ($casos as $caso) { |
155 | 155 | // determinar tipo documento y folio |
156 | 156 | $TipoDTE = self::$tipos[$caso['documento']]; |
157 | - if (!isset($folios[$TipoDTE])) |
|
158 | - $folios[$TipoDTE] = 1; |
|
157 | + if (!isset($folios[$TipoDTE])) { |
|
158 | + $folios[$TipoDTE] = 1; |
|
159 | + } |
|
159 | 160 | $Folio = $folios[$TipoDTE]; |
160 | 161 | // crear encabezado del documento |
161 | 162 | $documento = [ |
@@ -257,14 +258,17 @@ discard block |
||
257 | 258 | foreach ($item as $col => $val) { |
258 | 259 | $col = self::$item_cols[$col]; |
259 | 260 | // procesar cada valor de acuerdo al nombre de la columna |
260 | - if (in_array($col, ['DescuentoPct', 'RecargoPct'])) |
|
261 | - $detalle[$col] = substr($val, 0, -1); |
|
262 | - else |
|
263 | - $detalle[$col] = utf8_encode($val); // se convierte de ISO-8859-1 a UTF-8 |
|
261 | + if (in_array($col, ['DescuentoPct', 'RecargoPct'])) { |
|
262 | + $detalle[$col] = substr($val, 0, -1); |
|
263 | + } else { |
|
264 | + $detalle[$col] = utf8_encode($val); |
|
265 | + } |
|
266 | + // se convierte de ISO-8859-1 a UTF-8 |
|
264 | 267 | } |
265 | 268 | // si el item es EXENTO se agrega campo que lo indica |
266 | - if (strpos($detalle['NmbItem'], 'EXENTO')) |
|
267 | - $detalle['IndExe'] = 1; |
|
269 | + if (strpos($detalle['NmbItem'], 'EXENTO')) { |
|
270 | + $detalle['IndExe'] = 1; |
|
271 | + } |
|
268 | 272 | // si hay una referencia se completa con los campos del |
269 | 273 | // detalle de la referencia que no estén en este detalle |
270 | 274 | if (!empty($caso['referencia'])) { |
@@ -274,8 +278,9 @@ discard block |
||
274 | 278 | for ($i=0; $i<$n_detalle_r; $i++) { |
275 | 279 | if ($detalle_r[$i]['NmbItem']==$detalle['NmbItem']) { |
276 | 280 | foreach ($detalle_r[$i] as $attr => $val) { |
277 | - if (!isset($detalle[$attr])) |
|
278 | - $detalle[$attr] = $val; |
|
281 | + if (!isset($detalle[$attr])) { |
|
282 | + $detalle[$attr] = $val; |
|
283 | + } |
|
279 | 284 | } |
280 | 285 | } |
281 | 286 | } |
@@ -359,8 +364,9 @@ discard block |
||
359 | 364 | 'ValorDR' => substr($caso['recargo'], 0, -1), |
360 | 365 | ]; |
361 | 366 | } |
362 | - if (empty($documento['DscRcgGlobal'])) |
|
363 | - unset($documento['DscRcgGlobal']); |
|
367 | + if (empty($documento['DscRcgGlobal'])) { |
|
368 | + unset($documento['DscRcgGlobal']); |
|
369 | + } |
|
364 | 370 | // agregar descuento del documento de la referencia |
365 | 371 | else if (!empty($caso['referencia'])) { |
366 | 372 | $referencia = self::getReferencia($caso['referencia']['razon']); |
@@ -392,14 +398,16 @@ discard block |
||
392 | 398 | // agregar totales |
393 | 399 | $documento['Encabezado']['Totales'] = $referencia['Totales']; |
394 | 400 | // agregar tasa de IVA si corresponde |
395 | - if (isset($documento['Encabezado']['Totales']['TasaIVA'])) |
|
396 | - $documento['Encabezado']['Totales']['TasaIVA'] = \sasco\LibreDTE\Sii::getIVA(); |
|
401 | + if (isset($documento['Encabezado']['Totales']['TasaIVA'])) { |
|
402 | + $documento['Encabezado']['Totales']['TasaIVA'] = \sasco\LibreDTE\Sii::getIVA(); |
|
403 | + } |
|
397 | 404 | // si el documento referenciado es factura exenta y hay MntExe |
398 | 405 | if (isset($documento['Encabezado']['Totales']['MntExe'])) { |
399 | - if ($documentos[$caso['referencia']['caso']]['Encabezado']['IdDoc']['TipoDTE']==34) |
|
400 | - $documento['Encabezado']['Totales']['MntExe'] = 0; |
|
401 | - else |
|
402 | - unset($documento['Encabezado']['Totales']['MntExe']); |
|
406 | + if ($documentos[$caso['referencia']['caso']]['Encabezado']['IdDoc']['TipoDTE']==34) { |
|
407 | + $documento['Encabezado']['Totales']['MntExe'] = 0; |
|
408 | + } else { |
|
409 | + unset($documento['Encabezado']['Totales']['MntExe']); |
|
410 | + } |
|
403 | 411 | } |
404 | 412 | // si es documento de exportación se resetean los totales y se copia el tipo de moneda si no existe |
405 | 413 | if (in_array($documento['Encabezado']['IdDoc']['TipoDTE'], [111, 112])) { |
@@ -412,8 +420,9 @@ discard block |
||
412 | 420 | } |
413 | 421 | // agregar referencia de exportación si existe |
414 | 422 | if (!empty($caso['exportacion']['REFERENCIA'])) { |
415 | - if (!is_array($caso['exportacion']['REFERENCIA'])) |
|
416 | - $caso['exportacion']['REFERENCIA'] = [$caso['exportacion']['REFERENCIA']]; |
|
423 | + if (!is_array($caso['exportacion']['REFERENCIA'])) { |
|
424 | + $caso['exportacion']['REFERENCIA'] = [$caso['exportacion']['REFERENCIA']]; |
|
425 | + } |
|
417 | 426 | foreach ($caso['exportacion']['REFERENCIA'] as $ref) { |
418 | 427 | $documento['Referencia'][] = [ |
419 | 428 | 'TpoDocRef' => self::$referencias_exportacion[$ref], |
@@ -433,14 +442,16 @@ discard block |
||
433 | 442 | if (isset($documento['Encabezado']['Totales'])) { |
434 | 443 | $hayValor = false; |
435 | 444 | foreach ($documento['Detalle'] as $d) { |
436 | - if (!empty($d['PrcItem'])) |
|
437 | - $hayValor = true; |
|
445 | + if (!empty($d['PrcItem'])) { |
|
446 | + $hayValor = true; |
|
447 | + } |
|
438 | 448 | } |
439 | 449 | if (!$hayValor) { |
440 | - if (isset($documento['Encabezado']['Totales']['MntExe'])) |
|
441 | - $documento['Encabezado']['Totales'] = ['MntExe'=>0]; |
|
442 | - else |
|
443 | - $documento['Encabezado']['Totales'] = []; |
|
450 | + if (isset($documento['Encabezado']['Totales']['MntExe'])) { |
|
451 | + $documento['Encabezado']['Totales'] = ['MntExe'=>0]; |
|
452 | + } else { |
|
453 | + $documento['Encabezado']['Totales'] = []; |
|
454 | + } |
|
444 | 455 | $documento['Encabezado']['Totales']['MntTotal'] = 0; |
445 | 456 | } |
446 | 457 | } |
@@ -548,8 +559,9 @@ discard block |
||
548 | 559 | $n_lineas = count($lineas); |
549 | 560 | for ($i=$i; $i<$n_lineas; $i++) { |
550 | 561 | // si la línea está vacía se omite |
551 | - if (!$lineas[$i]) |
|
552 | - continue; |
|
562 | + if (!$lineas[$i]) { |
|
563 | + continue; |
|
564 | + } |
|
553 | 565 | // si hay descuento global se guarda |
554 | 566 | if (strpos($lineas[$i], 'DESCUENTO GLOBAL ITEMES AFECTOS')===0) { |
555 | 567 | $aux = explode("\t", $lineas[$i]); |
@@ -585,13 +597,15 @@ discard block |
||
585 | 597 | } |
586 | 598 | // agregar a los datos de aduanas |
587 | 599 | else { |
588 | - if (!isset($datos['exportacion'])) |
|
589 | - $datos['exportacion'] = []; |
|
600 | + if (!isset($datos['exportacion'])) { |
|
601 | + $datos['exportacion'] = []; |
|
602 | + } |
|
590 | 603 | if (!isset($datos['exportacion'][$var])) { |
591 | 604 | $datos['exportacion'][$var] = $val; |
592 | 605 | } else { |
593 | - if (!is_array($datos['exportacion'][$var])) |
|
594 | - $datos['exportacion'][$var] = [$datos['exportacion'][$var]]; |
|
606 | + if (!is_array($datos['exportacion'][$var])) { |
|
607 | + $datos['exportacion'][$var] = [$datos['exportacion'][$var]]; |
|
608 | + } |
|
595 | 609 | $datos['exportacion'][$var][] = $val; |
596 | 610 | } |
597 | 611 | } |