@@ -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 | */ |
@@ -1767,7 +1767,7 @@ discard block |
||
| 1767 | 1767 | * - Firma del DTE |
| 1768 | 1768 | * - RUT del emisor (si se pasó uno para comparar) |
| 1769 | 1769 | * - RUT del receptor (si se pasó uno para comparar) |
| 1770 | - * @return Código del estado de la validación |
|
| 1770 | + * @return integer del estado de la validación |
|
| 1771 | 1771 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 1772 | 1772 | * @version 2019-07-03 |
| 1773 | 1773 | */ |
@@ -1880,7 +1880,7 @@ discard block |
||
| 1880 | 1880 | |
| 1881 | 1881 | /** |
| 1882 | 1882 | * Método que obtiene el estado del DTE |
| 1883 | - * @param Firma objeto que representa la Firma Electrónca |
|
| 1883 | + * @param Firma \sasco\LibreDTE\FirmaElectronica que representa la Firma Electrónca |
|
| 1884 | 1884 | * @return Arreglo con el estado del DTE |
| 1885 | 1885 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 1886 | 1886 | * @version 2015-10-24 |
@@ -1921,7 +1921,7 @@ discard block |
||
| 1921 | 1921 | |
| 1922 | 1922 | /** |
| 1923 | 1923 | * Método que obtiene el estado avanzado del DTE |
| 1924 | - * @param Firma objeto que representa la Firma Electrónca |
|
| 1924 | + * @param Firma \sasco\LibreDTE\FirmaElectronica que representa la Firma Electrónca |
|
| 1925 | 1925 | * @return Arreglo con el estado del DTE |
| 1926 | 1926 | * @todo Corregir warning y también definir que se retornará (sobre todo en caso de error) |
| 1927 | 1927 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
@@ -57,10 +57,11 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function __construct($datos, $normalizar = true) |
| 59 | 59 | { |
| 60 | - if (is_array($datos)) |
|
| 61 | - $this->setDatos($datos, $normalizar); |
|
| 62 | - else if (is_string($datos)) |
|
| 63 | - $this->loadXML($datos); |
|
| 60 | + if (is_array($datos)) { |
|
| 61 | + $this->setDatos($datos, $normalizar); |
|
| 62 | + } else if (is_string($datos)) { |
|
| 63 | + $this->loadXML($datos); |
|
| 64 | + } |
|
| 64 | 65 | $this->timestamp = date('Y-m-d\TH:i:s'); |
| 65 | 66 | } |
| 66 | 67 | |
@@ -121,8 +122,9 @@ discard block |
||
| 121 | 122 | if ($normalizar) { |
| 122 | 123 | $this->normalizar($datos); |
| 123 | 124 | $method = 'normalizar_'.$this->tipo; |
| 124 | - if (method_exists($this, $method)) |
|
| 125 | - $this->$method($datos); |
|
| 125 | + if (method_exists($this, $method)) { |
|
| 126 | + $this->$method($datos); |
|
| 127 | + } |
|
| 126 | 128 | $this->normalizar_final($datos); |
| 127 | 129 | } |
| 128 | 130 | $this->tipo_general = $this->getTipoGeneral($this->tipo); |
@@ -199,8 +201,9 @@ discard block |
||
| 199 | 201 | */ |
| 200 | 202 | public function getJSON() |
| 201 | 203 | { |
| 202 | - if (!$this->getDatos()) |
|
| 203 | - return false; |
|
| 204 | + if (!$this->getDatos()) { |
|
| 205 | + return false; |
|
| 206 | + } |
|
| 204 | 207 | return json_encode($this->datos, JSON_PRETTY_PRINT); |
| 205 | 208 | } |
| 206 | 209 | |
@@ -225,9 +228,10 @@ discard block |
||
| 225 | 228 | */ |
| 226 | 229 | private function getTipoGeneral($dte) |
| 227 | 230 | { |
| 228 | - foreach ($this->tipos as $tipo => $codigos) |
|
| 229 | - if (in_array($dte, $codigos)) |
|
| 231 | + foreach ($this->tipos as $tipo => $codigos) { |
|
| 232 | + if (in_array($dte, $codigos)) |
|
| 230 | 233 | return $tipo; |
| 234 | + } |
|
| 231 | 235 | \sasco\LibreDTE\Log::write( |
| 232 | 236 | \sasco\LibreDTE\Estado::DTE_ERROR_TIPO, |
| 233 | 237 | \sasco\LibreDTE\Estado::get(\sasco\LibreDTE\Estado::DTE_ERROR_TIPO, $dte) |
@@ -266,10 +270,12 @@ discard block |
||
| 266 | 270 | public function getEmisor() |
| 267 | 271 | { |
| 268 | 272 | $nodo = $this->xml->xpath('/DTE/'.$this->tipo_general.'/Encabezado/Emisor/RUTEmisor')->item(0); |
| 269 | - if ($nodo) |
|
| 270 | - return $nodo->nodeValue; |
|
| 271 | - if (!$this->getDatos()) |
|
| 272 | - return false; |
|
| 273 | + if ($nodo) { |
|
| 274 | + return $nodo->nodeValue; |
|
| 275 | + } |
|
| 276 | + if (!$this->getDatos()) { |
|
| 277 | + return false; |
|
| 278 | + } |
|
| 273 | 279 | return $this->datos['Encabezado']['Emisor']['RUTEmisor']; |
| 274 | 280 | } |
| 275 | 281 | |
@@ -282,10 +288,12 @@ discard block |
||
| 282 | 288 | public function getReceptor() |
| 283 | 289 | { |
| 284 | 290 | $nodo = $this->xml->xpath('/DTE/'.$this->tipo_general.'/Encabezado/Receptor/RUTRecep')->item(0); |
| 285 | - if ($nodo) |
|
| 286 | - return $nodo->nodeValue; |
|
| 287 | - if (!$this->getDatos()) |
|
| 288 | - return false; |
|
| 291 | + if ($nodo) { |
|
| 292 | + return $nodo->nodeValue; |
|
| 293 | + } |
|
| 294 | + if (!$this->getDatos()) { |
|
| 295 | + return false; |
|
| 296 | + } |
|
| 289 | 297 | return $this->datos['Encabezado']['Receptor']['RUTRecep']; |
| 290 | 298 | } |
| 291 | 299 | |
@@ -298,10 +306,12 @@ discard block |
||
| 298 | 306 | public function getFechaEmision() |
| 299 | 307 | { |
| 300 | 308 | $nodo = $this->xml->xpath('/DTE/'.$this->tipo_general.'/Encabezado/IdDoc/FchEmis')->item(0); |
| 301 | - if ($nodo) |
|
| 302 | - return $nodo->nodeValue; |
|
| 303 | - if (!$this->getDatos()) |
|
| 304 | - return false; |
|
| 309 | + if ($nodo) { |
|
| 310 | + return $nodo->nodeValue; |
|
| 311 | + } |
|
| 312 | + if (!$this->getDatos()) { |
|
| 313 | + return false; |
|
| 314 | + } |
|
| 305 | 315 | return $this->datos['Encabezado']['IdDoc']['FchEmis']; |
| 306 | 316 | } |
| 307 | 317 | |
@@ -314,10 +324,12 @@ discard block |
||
| 314 | 324 | public function getMontoTotal() |
| 315 | 325 | { |
| 316 | 326 | $nodo = $this->xml->xpath('/DTE/'.$this->tipo_general.'/Encabezado/Totales/MntTotal')->item(0); |
| 317 | - if ($nodo) |
|
| 318 | - return $nodo->nodeValue; |
|
| 319 | - if (!$this->getDatos()) |
|
| 320 | - return false; |
|
| 327 | + if ($nodo) { |
|
| 328 | + return $nodo->nodeValue; |
|
| 329 | + } |
|
| 330 | + if (!$this->getDatos()) { |
|
| 331 | + return false; |
|
| 332 | + } |
|
| 321 | 333 | return $this->datos['Encabezado']['Totales']['MntTotal']; |
| 322 | 334 | } |
| 323 | 335 | |
@@ -330,10 +342,12 @@ discard block |
||
| 330 | 342 | public function getMoneda() |
| 331 | 343 | { |
| 332 | 344 | $nodo = $this->xml->xpath('/DTE/'.$this->tipo_general.'/Encabezado/Totales/TpoMoneda')->item(0); |
| 333 | - if ($nodo) |
|
| 334 | - return $nodo->nodeValue; |
|
| 335 | - if (!$this->getDatos()) |
|
| 336 | - return false; |
|
| 345 | + if ($nodo) { |
|
| 346 | + return $nodo->nodeValue; |
|
| 347 | + } |
|
| 348 | + if (!$this->getDatos()) { |
|
| 349 | + return false; |
|
| 350 | + } |
|
| 337 | 351 | return $this->datos['Encabezado']['Totales']['TpoMoneda']; |
| 338 | 352 | } |
| 339 | 353 | |
@@ -376,8 +390,9 @@ discard block |
||
| 376 | 390 | return false;*/ |
| 377 | 391 | $xml = new \sasco\LibreDTE\XML(); |
| 378 | 392 | $TED = $this->xml->getElementsByTagName('TED')->item(0); |
| 379 | - if (!$TED) |
|
| 380 | - return '<TED/>'; |
|
| 393 | + if (!$TED) { |
|
| 394 | + return '<TED/>'; |
|
| 395 | + } |
|
| 381 | 396 | $xml->loadXML($TED->C14N()); |
| 382 | 397 | $xml->documentElement->removeAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi'); |
| 383 | 398 | $xml->documentElement->removeAttributeNS('http://www.sii.cl/SiiDte', ''); |
@@ -574,10 +589,12 @@ discard block |
||
| 574 | 589 | */ |
| 575 | 590 | private function calcularNetoIVA($total, $tasa = null) |
| 576 | 591 | { |
| 577 | - if ($tasa === 0 or $tasa === false) |
|
| 578 | - return [0, 0]; |
|
| 579 | - if ($tasa === null) |
|
| 580 | - $tasa = \sasco\LibreDTE\Sii::getIVA(); |
|
| 592 | + if ($tasa === 0 or $tasa === false) { |
|
| 593 | + return [0, 0]; |
|
| 594 | + } |
|
| 595 | + if ($tasa === null) { |
|
| 596 | + $tasa = \sasco\LibreDTE\Sii::getIVA(); |
|
| 597 | + } |
|
| 581 | 598 | // WARNING: el IVA obtenido puede no ser el NETO*(TASA/100) |
| 582 | 599 | // se calcula el monto neto y luego se obtiene el IVA haciendo la resta |
| 583 | 600 | // entre el total y el neto, ya que hay casos de borde como: |
@@ -693,8 +710,9 @@ discard block |
||
| 693 | 710 | } |
| 694 | 711 | // si existe descuento o recargo global se normalizan |
| 695 | 712 | if (!empty($datos['DscRcgGlobal'])) { |
| 696 | - if (!isset($datos['DscRcgGlobal'][0])) |
|
| 697 | - $datos['DscRcgGlobal'] = [$datos['DscRcgGlobal']]; |
|
| 713 | + if (!isset($datos['DscRcgGlobal'][0])) { |
|
| 714 | + $datos['DscRcgGlobal'] = [$datos['DscRcgGlobal']]; |
|
| 715 | + } |
|
| 698 | 716 | $NroLinDR = 1; |
| 699 | 717 | foreach ($datos['DscRcgGlobal'] as &$dr) { |
| 700 | 718 | $dr = array_merge([ |
@@ -1357,8 +1375,9 @@ discard block |
||
| 1357 | 1375 | */ |
| 1358 | 1376 | private function normalizar_detalle(array &$datos) |
| 1359 | 1377 | { |
| 1360 | - if (!isset($datos['Detalle'][0])) |
|
| 1361 | - $datos['Detalle'] = [$datos['Detalle']]; |
|
| 1378 | + if (!isset($datos['Detalle'][0])) { |
|
| 1379 | + $datos['Detalle'] = [$datos['Detalle']]; |
|
| 1380 | + } |
|
| 1362 | 1381 | $item = 1; |
| 1363 | 1382 | foreach ($datos['Detalle'] as &$d) { |
| 1364 | 1383 | $d = array_merge([ |
@@ -1420,8 +1439,9 @@ discard block |
||
| 1420 | 1439 | ]; |
| 1421 | 1440 | } |
| 1422 | 1441 | if ($d['PrcItem']) { |
| 1423 | - if (!$d['QtyItem']) |
|
| 1424 | - $d['QtyItem'] = 1; |
|
| 1442 | + if (!$d['QtyItem']) { |
|
| 1443 | + $d['QtyItem'] = 1; |
|
| 1444 | + } |
|
| 1425 | 1445 | if (empty($d['MontoItem'])) { |
| 1426 | 1446 | $d['MontoItem'] = $this->round( |
| 1427 | 1447 | $d['QtyItem'] * $d['PrcItem'], |
@@ -1487,8 +1507,9 @@ discard block |
||
| 1487 | 1507 | private function normalizar_aplicar_descuentos_recargos(array &$datos) |
| 1488 | 1508 | { |
| 1489 | 1509 | if (!empty($datos['DscRcgGlobal'])) { |
| 1490 | - if (!isset($datos['DscRcgGlobal'][0])) |
|
| 1491 | - $datos['DscRcgGlobal'] = [$datos['DscRcgGlobal']]; |
|
| 1510 | + if (!isset($datos['DscRcgGlobal'][0])) { |
|
| 1511 | + $datos['DscRcgGlobal'] = [$datos['DscRcgGlobal']]; |
|
| 1512 | + } |
|
| 1492 | 1513 | foreach ($datos['DscRcgGlobal'] as &$dr) { |
| 1493 | 1514 | $dr = array_merge([ |
| 1494 | 1515 | 'NroLinDR' => false, |
@@ -1555,8 +1576,9 @@ discard block |
||
| 1555 | 1576 | $montos = []; |
| 1556 | 1577 | foreach ($datos['Detalle'] as &$d) { |
| 1557 | 1578 | if (!empty($d['CodImpAdic'])) { |
| 1558 | - if (!isset($montos[$d['CodImpAdic']])) |
|
| 1559 | - $montos[$d['CodImpAdic']] = 0; |
|
| 1579 | + if (!isset($montos[$d['CodImpAdic']])) { |
|
| 1580 | + $montos[$d['CodImpAdic']] = 0; |
|
| 1581 | + } |
|
| 1560 | 1582 | $montos[$d['CodImpAdic']] += $d['MontoItem']; |
| 1561 | 1583 | } |
| 1562 | 1584 | } |
@@ -1635,10 +1657,12 @@ discard block |
||
| 1635 | 1657 | } |
| 1636 | 1658 | if (empty($datos['Encabezado']['Totales']['MntTotal'])) { |
| 1637 | 1659 | $datos['Encabezado']['Totales']['MntTotal'] = $datos['Encabezado']['Totales']['MntNeto']; |
| 1638 | - if (!empty($datos['Encabezado']['Totales']['IVA'])) |
|
| 1639 | - $datos['Encabezado']['Totales']['MntTotal'] += $datos['Encabezado']['Totales']['IVA']; |
|
| 1640 | - if (!empty($datos['Encabezado']['Totales']['MntExe'])) |
|
| 1641 | - $datos['Encabezado']['Totales']['MntTotal'] += $datos['Encabezado']['Totales']['MntExe']; |
|
| 1660 | + if (!empty($datos['Encabezado']['Totales']['IVA'])) { |
|
| 1661 | + $datos['Encabezado']['Totales']['MntTotal'] += $datos['Encabezado']['Totales']['IVA']; |
|
| 1662 | + } |
|
| 1663 | + if (!empty($datos['Encabezado']['Totales']['MntExe'])) { |
|
| 1664 | + $datos['Encabezado']['Totales']['MntTotal'] += $datos['Encabezado']['Totales']['MntExe']; |
|
| 1665 | + } |
|
| 1642 | 1666 | } |
| 1643 | 1667 | } else { |
| 1644 | 1668 | if (!$datos['Encabezado']['Totales']['MntTotal'] and !empty($datos['Encabezado']['Totales']['MntExe'])) { |
@@ -1664,8 +1688,10 @@ discard block |
||
| 1664 | 1688 | } |
| 1665 | 1689 | // si hay impuesto de crédito a constructoras del 65% se descuenta del total |
| 1666 | 1690 | if (!empty($datos['Encabezado']['Totales']['CredEC'])) { |
| 1667 | - if ($datos['Encabezado']['Totales']['CredEC']===true) |
|
| 1668 | - $datos['Encabezado']['Totales']['CredEC'] = round($datos['Encabezado']['Totales']['IVA'] * 0.65); // TODO: mover a constante o método |
|
| 1691 | + if ($datos['Encabezado']['Totales']['CredEC']===true) { |
|
| 1692 | + $datos['Encabezado']['Totales']['CredEC'] = round($datos['Encabezado']['Totales']['IVA'] * 0.65); |
|
| 1693 | + } |
|
| 1694 | + // TODO: mover a constante o método |
|
| 1669 | 1695 | $datos['Encabezado']['Totales']['MntTotal'] -= $datos['Encabezado']['Totales']['CredEC']; |
| 1670 | 1696 | } |
| 1671 | 1697 | } |
@@ -1889,12 +1915,14 @@ discard block |
||
| 1889 | 1915 | { |
| 1890 | 1916 | // solicitar token |
| 1891 | 1917 | $token = \sasco\LibreDTE\Sii\Autenticacion::getToken($Firma); |
| 1892 | - if (!$token) |
|
| 1893 | - return false; |
|
| 1918 | + if (!$token) { |
|
| 1919 | + return false; |
|
| 1920 | + } |
|
| 1894 | 1921 | // consultar estado dte |
| 1895 | 1922 | $run = $Firma->getID(); |
| 1896 | - if ($run===false) |
|
| 1897 | - return false; |
|
| 1923 | + if ($run===false) { |
|
| 1924 | + return false; |
|
| 1925 | + } |
|
| 1898 | 1926 | list($RutConsultante, $DvConsultante) = explode('-', $run); |
| 1899 | 1927 | list($RutCompania, $DvCompania) = explode('-', $this->getEmisor()); |
| 1900 | 1928 | list($RutReceptor, $DvReceptor) = explode('-', $this->getReceptor()); |
@@ -1913,8 +1941,9 @@ discard block |
||
| 1913 | 1941 | 'token' => $token, |
| 1914 | 1942 | ]); |
| 1915 | 1943 | // si el estado se pudo recuperar se muestra |
| 1916 | - if ($xml===false) |
|
| 1917 | - return false; |
|
| 1944 | + if ($xml===false) { |
|
| 1945 | + return false; |
|
| 1946 | + } |
|
| 1918 | 1947 | // entregar estado |
| 1919 | 1948 | return (array)$xml->xpath('/SII:RESPUESTA/SII:RESP_HDR')[0]; |
| 1920 | 1949 | } |
@@ -1931,8 +1960,9 @@ discard block |
||
| 1931 | 1960 | { |
| 1932 | 1961 | // solicitar token |
| 1933 | 1962 | $token = \sasco\LibreDTE\Sii\Autenticacion::getToken($Firma); |
| 1934 | - if (!$token) |
|
| 1935 | - return false; |
|
| 1963 | + if (!$token) { |
|
| 1964 | + return false; |
|
| 1965 | + } |
|
| 1936 | 1966 | // consultar estado dte |
| 1937 | 1967 | list($RutEmpresa, $DvEmpresa) = explode('-', $this->getEmisor()); |
| 1938 | 1968 | list($RutReceptor, $DvReceptor) = explode('-', $this->getReceptor()); |
@@ -1950,8 +1980,9 @@ discard block |
||
| 1950 | 1980 | 'token' => $token, |
| 1951 | 1981 | ]); |
| 1952 | 1982 | // si el estado se pudo recuperar se muestra |
| 1953 | - if ($xml===false) |
|
| 1954 | - return false; |
|
| 1983 | + if ($xml===false) { |
|
| 1984 | + return false; |
|
| 1985 | + } |
|
| 1955 | 1986 | // entregar estado |
| 1956 | 1987 | return (array)$xml->xpath('/SII:RESPUESTA/SII:RESP_BODY')[0]; |
| 1957 | 1988 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * Método que agrega un DTE al listado que se enviará |
| 45 | - * @param DTE Objeto del DTE |
|
| 45 | + * @param DTE Dte del DTE |
|
| 46 | 46 | * @return =true si se pudo agregar el DTE o =false si no se agregó por exceder el límite de un envío |
| 47 | 47 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 48 | 48 | * @version 2015-12-11 |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | /** |
| 396 | 396 | * Método que determina el estado de validación sobre el envío |
| 397 | 397 | * @param datos Arreglo con datos para hacer las validaciones |
| 398 | - * @return Código del estado de la validación |
|
| 398 | + * @return integer del estado de la validación |
|
| 399 | 399 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 400 | 400 | * @version 2019-07-03 |
| 401 | 401 | */ |
@@ -135,8 +135,9 @@ discard block |
||
| 135 | 135 | public function generar() |
| 136 | 136 | { |
| 137 | 137 | // si ya se había generado se entrega directamente |
| 138 | - if ($this->xml_data) |
|
| 139 | - return $this->xml_data; |
|
| 138 | + if ($this->xml_data) { |
|
| 139 | + return $this->xml_data; |
|
| 140 | + } |
|
| 140 | 141 | // si no hay DTEs para generar entregar falso |
| 141 | 142 | if (!isset($this->dtes[0])) { |
| 142 | 143 | \sasco\LibreDTE\Log::write( |
@@ -185,8 +186,9 @@ discard block |
||
| 185 | 186 | $SubTotDTE = []; |
| 186 | 187 | $subtotales = []; |
| 187 | 188 | foreach ($this->dtes as &$DTE) { |
| 188 | - if (!isset($subtotales[$DTE->getTipo()])) |
|
| 189 | - $subtotales[$DTE->getTipo()] = 0; |
|
| 189 | + if (!isset($subtotales[$DTE->getTipo()])) { |
|
| 190 | + $subtotales[$DTE->getTipo()] = 0; |
|
| 191 | + } |
|
| 190 | 192 | $subtotales[$DTE->getTipo()]++; |
| 191 | 193 | } |
| 192 | 194 | foreach ($subtotales as $tipo => $subtotal) { |
@@ -301,8 +303,9 @@ discard block |
||
| 301 | 303 | { |
| 302 | 304 | $fecha = '9999-12-31'; |
| 303 | 305 | foreach ($this->getDocumentos() as $Dte) { |
| 304 | - if ($Dte->getFechaEmision() < $fecha) |
|
| 305 | - $fecha = $Dte->getFechaEmision(); |
|
| 306 | + if ($Dte->getFechaEmision() < $fecha) { |
|
| 307 | + $fecha = $Dte->getFechaEmision(); |
|
| 308 | + } |
|
| 306 | 309 | } |
| 307 | 310 | return $fecha; |
| 308 | 311 | } |
@@ -316,8 +319,9 @@ discard block |
||
| 316 | 319 | { |
| 317 | 320 | $fecha = '0000-01-01'; |
| 318 | 321 | foreach ($this->getDocumentos() as $Dte) { |
| 319 | - if ($Dte->getFechaEmision() > $fecha) |
|
| 320 | - $fecha = $Dte->getFechaEmision(); |
|
| 322 | + if ($Dte->getFechaEmision() > $fecha) { |
|
| 323 | + $fecha = $Dte->getFechaEmision(); |
|
| 324 | + } |
|
| 321 | 325 | } |
| 322 | 326 | return $fecha; |
| 323 | 327 | } |
@@ -371,8 +375,9 @@ discard block |
||
| 371 | 375 | $DTEs = $this->xml->getElementsByTagName('DTE'); |
| 372 | 376 | foreach ($DTEs as $nodo_dte) { |
| 373 | 377 | $e = $nodo_dte->getElementsByTagName('RUTEmisor')->item(0)->nodeValue; |
| 374 | - if (is_numeric($emisor)) |
|
| 375 | - $e = substr($e, 0, -2); |
|
| 378 | + if (is_numeric($emisor)) { |
|
| 379 | + $e = substr($e, 0, -2); |
|
| 380 | + } |
|
| 376 | 381 | $d = (int)$nodo_dte->getElementsByTagName('TipoDTE')->item(0)->nodeValue; |
| 377 | 382 | $f = (int)$nodo_dte->getElementsByTagName('Folio')->item(0)->nodeValue; |
| 378 | 383 | if ($folio == $f and $dte == $d and $emisor == $e) { |