@@ -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-07-24 |
| 340 | 340 | */ |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | 116 | * Método que entrega el RUT de a quién se está autorizando el CAF |
| 117 | - * @return Rut del emisor del CAF |
|
| 117 | + * @return false|string del emisor del CAF |
|
| 118 | 118 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 119 | 119 | * @version 2015-10-30 |
| 120 | 120 | */ |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | /** |
| 158 | 158 | * Método que entrega la firma del SII sobre el nodo DA |
| 159 | - * @return Firma en base64 |
|
| 159 | + * @return false|string en base64 |
|
| 160 | 160 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 161 | 161 | * @version 2015-10-30 |
| 162 | 162 | */ |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | /** |
| 172 | 172 | * Método que entrega el IDK (serial number) de la clave pública del SII |
| 173 | 173 | * utilizada para firmar el CAF |
| 174 | - * @return Serial number |
|
| 174 | + * @return \sasco\LibreDTE\IDK|null number |
|
| 175 | 175 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 176 | 176 | * @version 2015-10-30 |
| 177 | 177 | */ |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | /** |
| 187 | 187 | * Método que entrega la clave privada proporcionada por el SII para el CAF |
| 188 | - * @return Clave privada en base64 |
|
| 188 | + * @return false|string privada en base64 |
|
| 189 | 189 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 190 | 190 | * @version 2015-10-30 |
| 191 | 191 | */ |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | /** |
| 201 | 201 | * Método que entrega la clave pública proporcionada por el SII para el CAF |
| 202 | - * @return Clave pública en base64 |
|
| 202 | + * @return false|string pública en base64 |
|
| 203 | 203 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 204 | 204 | * @version 2015-10-30 |
| 205 | 205 | */ |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | /** |
| 229 | 229 | * Método que entrega la fecha de autorización con la que se emitió el CAF |
| 230 | - * @return Fecha de autorización del CAF |
|
| 230 | + * @return false|string de autorización del CAF |
|
| 231 | 231 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 232 | 232 | * @version 2017-07-19 |
| 233 | 233 | */ |
@@ -63,8 +63,9 @@ discard block |
||
| 63 | 63 | // validar firma del SII sobre los folios |
| 64 | 64 | $firma = $this->getFirma(); |
| 65 | 65 | $idk = $this->getIDK(); |
| 66 | - if (!$firma or !$idk) |
|
| 67 | - return false; |
|
| 66 | + if (!$firma or !$idk) { |
|
| 67 | + return false; |
|
| 68 | + } |
|
| 68 | 69 | $pub_key = \sasco\LibreDTE\Sii::cert($idk); |
| 69 | 70 | if (!$pub_key or openssl_verify($this->xml->getFlattened('/AUTORIZACION/CAF/DA'), base64_decode($firma), $pub_key)!==1) { |
| 70 | 71 | \sasco\LibreDTE\Log::write( |
@@ -75,8 +76,9 @@ discard block |
||
| 75 | 76 | } |
| 76 | 77 | // validar clave privada y pública proporcionada por el SII |
| 77 | 78 | $private_key = $this->getPrivateKey(); |
| 78 | - if (!$private_key) |
|
| 79 | - return false; |
|
| 79 | + if (!$private_key) { |
|
| 80 | + return false; |
|
| 81 | + } |
|
| 80 | 82 | $plain = md5(date('U')); |
| 81 | 83 | if (!openssl_private_encrypt($plain, $crypt, $private_key)) { |
| 82 | 84 | \sasco\LibreDTE\Log::write( |
@@ -86,8 +88,9 @@ discard block |
||
| 86 | 88 | return false; |
| 87 | 89 | } |
| 88 | 90 | $public_key = $this->getPublicKey(); |
| 89 | - if (!$public_key) |
|
| 90 | - return false; |
|
| 91 | + if (!$public_key) { |
|
| 92 | + return false; |
|
| 93 | + } |
|
| 91 | 94 | if (!openssl_public_decrypt($crypt, $plain_firmado, $public_key)) { |
| 92 | 95 | \sasco\LibreDTE\Log::write( |
| 93 | 96 | \sasco\LibreDTE\Estado::FOLIOS_ERROR_DESENCRIPTAR, |
@@ -106,8 +109,9 @@ discard block |
||
| 106 | 109 | */ |
| 107 | 110 | public function getCaf() |
| 108 | 111 | { |
| 109 | - if (!$this->xml) |
|
| 110 | - return false; |
|
| 112 | + if (!$this->xml) { |
|
| 113 | + return false; |
|
| 114 | + } |
|
| 111 | 115 | $CAF = $this->xml->getElementsByTagName('CAF')->item(0); |
| 112 | 116 | return $CAF ? $CAF : false; |
| 113 | 117 | } |
@@ -120,8 +124,9 @@ discard block |
||
| 120 | 124 | */ |
| 121 | 125 | public function getEmisor() |
| 122 | 126 | { |
| 123 | - if (!$this->xml) |
|
| 124 | - return false; |
|
| 127 | + if (!$this->xml) { |
|
| 128 | + return false; |
|
| 129 | + } |
|
| 125 | 130 | $RE = $this->xml->getElementsByTagName('RE')->item(0); |
| 126 | 131 | return $RE ? $RE->nodeValue : false; |
| 127 | 132 | } |
@@ -134,8 +139,9 @@ discard block |
||
| 134 | 139 | */ |
| 135 | 140 | public function getDesde() |
| 136 | 141 | { |
| 137 | - if (!$this->xml) |
|
| 138 | - return false; |
|
| 142 | + if (!$this->xml) { |
|
| 143 | + return false; |
|
| 144 | + } |
|
| 139 | 145 | $D = $this->xml->getElementsByTagName('D')->item(0); |
| 140 | 146 | return $D ? (int)$D->nodeValue : false; |
| 141 | 147 | } |
@@ -148,8 +154,9 @@ discard block |
||
| 148 | 154 | */ |
| 149 | 155 | public function getHasta() |
| 150 | 156 | { |
| 151 | - if (!$this->xml) |
|
| 152 | - return false; |
|
| 157 | + if (!$this->xml) { |
|
| 158 | + return false; |
|
| 159 | + } |
|
| 153 | 160 | $H = $this->xml->getElementsByTagName('H')->item(0); |
| 154 | 161 | return $H ? (int)$H->nodeValue : false; |
| 155 | 162 | } |
@@ -162,8 +169,9 @@ discard block |
||
| 162 | 169 | */ |
| 163 | 170 | private function getFirma() |
| 164 | 171 | { |
| 165 | - if (!$this->xml) |
|
| 166 | - return false; |
|
| 172 | + if (!$this->xml) { |
|
| 173 | + return false; |
|
| 174 | + } |
|
| 167 | 175 | $FRMA = $this->xml->getElementsByTagName('FRMA')->item(0); |
| 168 | 176 | return $FRMA ? $FRMA->nodeValue : false; |
| 169 | 177 | } |
@@ -177,8 +185,9 @@ discard block |
||
| 177 | 185 | */ |
| 178 | 186 | private function getIDK() |
| 179 | 187 | { |
| 180 | - if (!$this->xml) |
|
| 181 | - return false; |
|
| 188 | + if (!$this->xml) { |
|
| 189 | + return false; |
|
| 190 | + } |
|
| 182 | 191 | $IDK = $this->xml->getElementsByTagName('IDK')->item(0); |
| 183 | 192 | return $IDK ? (int)$IDK->nodeValue : false; |
| 184 | 193 | } |
@@ -191,8 +200,9 @@ discard block |
||
| 191 | 200 | */ |
| 192 | 201 | public function getPrivateKey() |
| 193 | 202 | { |
| 194 | - if (!$this->xml) |
|
| 195 | - return false; |
|
| 203 | + if (!$this->xml) { |
|
| 204 | + return false; |
|
| 205 | + } |
|
| 196 | 206 | $RSASK = $this->xml->getElementsByTagName('RSASK')->item(0); |
| 197 | 207 | return $RSASK ? $RSASK->nodeValue : false; |
| 198 | 208 | } |
@@ -205,8 +215,9 @@ discard block |
||
| 205 | 215 | */ |
| 206 | 216 | public function getPublicKey() |
| 207 | 217 | { |
| 208 | - if (!$this->xml) |
|
| 209 | - return false; |
|
| 218 | + if (!$this->xml) { |
|
| 219 | + return false; |
|
| 220 | + } |
|
| 210 | 221 | $RSAPUBK = $this->xml->getElementsByTagName('RSAPUBK')->item(0); |
| 211 | 222 | return $RSAPUBK ? $RSAPUBK->nodeValue : false; |
| 212 | 223 | } |
@@ -219,8 +230,9 @@ discard block |
||
| 219 | 230 | */ |
| 220 | 231 | public function getTipo() |
| 221 | 232 | { |
| 222 | - if (!$this->xml) |
|
| 223 | - return false; |
|
| 233 | + if (!$this->xml) { |
|
| 234 | + return false; |
|
| 235 | + } |
|
| 224 | 236 | $TD = $this->xml->getElementsByTagName('TD')->item(0); |
| 225 | 237 | return $TD ? (int)$TD->nodeValue : false; |
| 226 | 238 | } |
@@ -233,8 +245,9 @@ discard block |
||
| 233 | 245 | */ |
| 234 | 246 | public function getFechaAutorizacion() |
| 235 | 247 | { |
| 236 | - if (!$this->xml) |
|
| 237 | - return false; |
|
| 248 | + if (!$this->xml) { |
|
| 249 | + return false; |
|
| 250 | + } |
|
| 238 | 251 | $FA = $this->xml->getElementsByTagName('FA')->item(0); |
| 239 | 252 | return $FA ? $FA->nodeValue : false; |
| 240 | 253 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | /** |
| 175 | 175 | * Método que asigna la ubicación del logo de la empresa |
| 176 | 176 | * @param logo URI del logo (puede ser local o en una URL) |
| 177 | - * @param posicion Posición respecto a datos del emisor (=0 izq, =1 arriba) |
|
| 177 | + * @param posicion integer respecto a datos del emisor (=0 izq, =1 arriba) |
|
| 178 | 178 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 179 | 179 | * @version 2016-08-04 |
| 180 | 180 | */ |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | * contínuo |
| 337 | 337 | * @param dte Arreglo con los datos del XML (tag Documento) |
| 338 | 338 | * @param timbre String XML con el tag TED del DTE |
| 339 | - * @param width Ancho del papel contínuo en mm |
|
| 339 | + * @param width boolean del papel contínuo en mm |
|
| 340 | 340 | * @author Pablo Reyes (https://github.com/pabloxp) |
| 341 | 341 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 342 | 342 | * @version 2017-06-15 |
@@ -482,10 +482,11 @@ discard block |
||
| 482 | 482 | * - Dirección casa central del emisor |
| 483 | 483 | * - Dirección sucursales |
| 484 | 484 | * @param emisor Arreglo con los datos del emisor (tag Emisor del XML) |
| 485 | - * @param x Posición horizontal de inicio en el PDF |
|
| 486 | - * @param y Posición vertical de inicio en el PDF |
|
| 487 | - * @param w Ancho de la información del emisor |
|
| 488 | - * @param w_img Ancho máximo de la imagen |
|
| 485 | + * @param x integer horizontal de inicio en el PDF |
|
| 486 | + * @param y integer vertical de inicio en el PDF |
|
| 487 | + * @param w integer de la información del emisor |
|
| 488 | + * @param w_img integer máximo de la imagen |
|
| 489 | + * @param integer $font_size |
|
| 489 | 490 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 490 | 491 | * @version 2016-12-02 |
| 491 | 492 | */ |
@@ -555,11 +556,13 @@ discard block |
||
| 555 | 556 | * @param rut RUT del emisor |
| 556 | 557 | * @param tipo Código o glosa del tipo de documento |
| 557 | 558 | * @param sucursal_sii Código o glosa de la sucursal del SII del Emisor |
| 558 | - * @param x Posición horizontal de inicio en el PDF |
|
| 559 | - * @param y Posición vertical de inicio en el PDF |
|
| 560 | - * @param w Ancho de la información del emisor |
|
| 559 | + * @param x integer horizontal de inicio en el PDF |
|
| 560 | + * @param y integer vertical de inicio en el PDF |
|
| 561 | + * @param w integer de la información del emisor |
|
| 562 | + * @param integer $font_size |
|
| 561 | 563 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 562 | 564 | * @version 2016-12-02 |
| 565 | + * @return integer |
|
| 563 | 566 | */ |
| 564 | 567 | private function agregarFolio($rut, $tipo, $folio, $sucursal_sii = null, $x = 130, $y = 15, $w = 70, $font_size = null, array $color = null) |
| 565 | 568 | { |
@@ -605,7 +608,7 @@ discard block |
||
| 605 | 608 | * Método que agrega los datos de la emisión del DTE que no son los dato del |
| 606 | 609 | * receptor |
| 607 | 610 | * @param IdDoc Información general del documento |
| 608 | - * @param x Posición horizontal de inicio en el PDF |
|
| 611 | + * @param x integer horizontal de inicio en el PDF |
|
| 609 | 612 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 610 | 613 | * @version 2017-06-15 |
| 611 | 614 | */ |
@@ -693,7 +696,7 @@ discard block |
||
| 693 | 696 | /** |
| 694 | 697 | * Método que agrega los datos del receptor |
| 695 | 698 | * @param receptor Arreglo con los datos del receptor (tag Receptor del XML) |
| 696 | - * @param x Posición horizontal de inicio en el PDF |
|
| 699 | + * @param x integer horizontal de inicio en el PDF |
|
| 697 | 700 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 698 | 701 | * @version 2017-06-15 |
| 699 | 702 | */ |
@@ -780,7 +783,7 @@ discard block |
||
| 780 | 783 | * Método que agrega los datos del traslado |
| 781 | 784 | * @param IndTraslado |
| 782 | 785 | * @param Transporte |
| 783 | - * @param x Posición horizontal de inicio en el PDF |
|
| 786 | + * @param x integer horizontal de inicio en el PDF |
|
| 784 | 787 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 785 | 788 | * @version 2016-08-03 |
| 786 | 789 | */ |
@@ -851,7 +854,7 @@ discard block |
||
| 851 | 854 | /** |
| 852 | 855 | * Método que agrega las referencias del documento |
| 853 | 856 | * @param referencias Arreglo con las referencias del documento (tag Referencia del XML) |
| 854 | - * @param x Posición horizontal de inicio en el PDF |
|
| 857 | + * @param x integer horizontal de inicio en el PDF |
|
| 855 | 858 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 856 | 859 | * @version 2016-08-03 |
| 857 | 860 | */ |
@@ -874,7 +877,7 @@ discard block |
||
| 874 | 877 | /** |
| 875 | 878 | * Método que agrega el detalle del documento |
| 876 | 879 | * @param detalle Arreglo con el detalle del documento (tag Detalle del XML) |
| 877 | - * @param x Posición horizontal de inicio en el PDF |
|
| 880 | + * @param x integer horizontal de inicio en el PDF |
|
| 878 | 881 | * @param y Posición vertical de inicio en el PDF |
| 879 | 882 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 880 | 883 | * @version 2016-08-05 |
@@ -941,7 +944,7 @@ discard block |
||
| 941 | 944 | /** |
| 942 | 945 | * Método que agrega el detalle del documento |
| 943 | 946 | * @param detalle Arreglo con el detalle del documento (tag Detalle del XML) |
| 944 | - * @param x Posición horizontal de inicio en el PDF |
|
| 947 | + * @param x integer horizontal de inicio en el PDF |
|
| 945 | 948 | * @param y Posición vertical de inicio en el PDF |
| 946 | 949 | * @author Pablo Reyes (https://github.com/pabloxp) |
| 947 | 950 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
@@ -977,7 +980,7 @@ discard block |
||
| 977 | 980 | * Método que agrega el subtotal del DTE |
| 978 | 981 | * @param detalle Arreglo con los detalles del documentos para poder |
| 979 | 982 | * calcular subtotal |
| 980 | - * @param x Posición horizontal de inicio en el PDF |
|
| 983 | + * @param x integer horizontal de inicio en el PDF |
|
| 981 | 984 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 982 | 985 | * @version 2016-08-17 |
| 983 | 986 | */ |
@@ -1003,7 +1006,7 @@ discard block |
||
| 1003 | 1006 | /** |
| 1004 | 1007 | * Método que agrega los descuentos y/o recargos globales del documento |
| 1005 | 1008 | * @param descuentosRecargos Arreglo con los descuentos y/o recargos del documento (tag DscRcgGlobal del XML) |
| 1006 | - * @param x Posición horizontal de inicio en el PDF |
|
| 1009 | + * @param x integer horizontal de inicio en el PDF |
|
| 1007 | 1010 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 1008 | 1011 | * @version 2016-08-17 |
| 1009 | 1012 | */ |
@@ -1027,7 +1030,7 @@ discard block |
||
| 1027 | 1030 | /** |
| 1028 | 1031 | * Método que agrega los pagos del documento |
| 1029 | 1032 | * @param pagos Arreglo con los pagos del documento |
| 1030 | - * @param x Posición horizontal de inicio en el PDF |
|
| 1033 | + * @param x integer horizontal de inicio en el PDF |
|
| 1031 | 1034 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 1032 | 1035 | * @version 2016-07-24 |
| 1033 | 1036 | */ |
@@ -1137,9 +1140,9 @@ discard block |
||
| 1137 | 1140 | * - Se imprime en el tamaño mínimo: 2x5 cms |
| 1138 | 1141 | * - En el lado de abajo con margen izquierdo mínimo de 2 cms |
| 1139 | 1142 | * @param timbre String con los datos del timbre |
| 1140 | - * @param x Posición horizontal de inicio en el PDF |
|
| 1141 | - * @param y Posición vertical de inicio en el PDF |
|
| 1142 | - * @param w Ancho del timbre |
|
| 1143 | + * @param x integer horizontal de inicio en el PDF |
|
| 1144 | + * @param y integer vertical de inicio en el PDF |
|
| 1145 | + * @param w integer del timbre |
|
| 1143 | 1146 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 1144 | 1147 | * @version 2017-07-13 |
| 1145 | 1148 | */ |
@@ -1176,10 +1179,10 @@ discard block |
||
| 1176 | 1179 | |
| 1177 | 1180 | /** |
| 1178 | 1181 | * Método que agrega el acuse de rebido |
| 1179 | - * @param x Posición horizontal de inicio en el PDF |
|
| 1180 | - * @param y Posición vertical de inicio en el PDF |
|
| 1181 | - * @param w Ancho del acuse de recibo |
|
| 1182 | - * @param h Alto del acuse de recibo |
|
| 1182 | + * @param x integer horizontal de inicio en el PDF |
|
| 1183 | + * @param y integer vertical de inicio en el PDF |
|
| 1184 | + * @param w integer del acuse de recibo |
|
| 1185 | + * @param h integer del acuse de recibo |
|
| 1183 | 1186 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 1184 | 1187 | * @version 2015-09-08 |
| 1185 | 1188 | */ |
@@ -1206,10 +1209,10 @@ discard block |
||
| 1206 | 1209 | |
| 1207 | 1210 | /** |
| 1208 | 1211 | * Método que agrega el acuse de rebido |
| 1209 | - * @param x Posición horizontal de inicio en el PDF |
|
| 1212 | + * @param x integer horizontal de inicio en el PDF |
|
| 1210 | 1213 | * @param y Posición vertical de inicio en el PDF |
| 1211 | - * @param w Ancho del acuse de recibo |
|
| 1212 | - * @param h Alto del acuse de recibo |
|
| 1214 | + * @param w integer del acuse de recibo |
|
| 1215 | + * @param h integer del acuse de recibo |
|
| 1213 | 1216 | * @author Pablo Reyes (https://github.com/pabloxp) |
| 1214 | 1217 | * @version 2015-11-17 |
| 1215 | 1218 | */ |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | { |
| 169 | 169 | parent::__construct(); |
| 170 | 170 | $this->SetTitle('Documento Tributario Electrónico (DTE) de Chile by LibreDTE'); |
| 171 | - $this->papelContinuo = $papelContinuo === true ? 80 : $papelContinuo; |
|
| 171 | + $this->papelContinuo = $papelContinuo===true ? 80 : $papelContinuo; |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | $this->setY(max($y)); |
| 304 | 304 | $this->Ln(); |
| 305 | 305 | $y = []; |
| 306 | - $y[] = $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor'])?$dte['Encabezado']['Emisor']['CdgVendedor']:null); |
|
| 306 | + $y[] = $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor']) ? $dte['Encabezado']['Emisor']['CdgVendedor'] : null); |
|
| 307 | 307 | $y[] = $this->agregarReceptor($dte['Encabezado']); |
| 308 | 308 | $this->setY(max($y)); |
| 309 | 309 | $this->agregarTraslado( |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | // determinar alto de la página y agregarla |
| 351 | 351 | $height = 145; |
| 352 | 352 | $n_detalle = count($dte['Detalle']); |
| 353 | - if ($n_detalle>1) $height += $n_detalle*20; |
|
| 353 | + if ($n_detalle>1) $height += $n_detalle * 20; |
|
| 354 | 354 | if ($this->cedible) $height += 50; |
| 355 | 355 | $this->AddPage('P', [$height, $width]); |
| 356 | 356 | // agregar cabecera del documento |
@@ -359,15 +359,15 @@ discard block |
||
| 359 | 359 | $dte['Encabezado']['IdDoc']['TipoDTE'], |
| 360 | 360 | $dte['Encabezado']['IdDoc']['Folio'], |
| 361 | 361 | $dte['Encabezado']['Emisor']['CmnaOrigen'], |
| 362 | - $x_start, $y_start, $width-($x_start*4), 10, |
|
| 363 | - [0,0,0] |
|
| 362 | + $x_start, $y_start, $width-($x_start * 4), 10, |
|
| 363 | + [0, 0, 0] |
|
| 364 | 364 | ); |
| 365 | - $y = $this->agregarEmisor($dte['Encabezado']['Emisor'], $x_start, $y+2, 40, 8, 9, [0,0,0]); |
|
| 365 | + $y = $this->agregarEmisor($dte['Encabezado']['Emisor'], $x_start, $y+2, 40, 8, 9, [0, 0, 0]); |
|
| 366 | 366 | // datos del documento |
| 367 | 367 | $this->SetY($y); |
| 368 | 368 | $this->Ln(); |
| 369 | 369 | $this->setFont('', '', 8); |
| 370 | - $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor'])?$dte['Encabezado']['Emisor']['CdgVendedor']:null, $x_start, $offset, false); |
|
| 370 | + $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor']) ? $dte['Encabezado']['Emisor']['CdgVendedor'] : null, $x_start, $offset, false); |
|
| 371 | 371 | $this->agregarReceptor($dte['Encabezado'], $x_start, $offset); |
| 372 | 372 | $this->agregarTraslado( |
| 373 | 373 | !empty($dte['Encabezado']['IdDoc']['IndTraslado']) ? $dte['Encabezado']['IdDoc']['IndTraslado'] : null, |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | $this->AddPage('P', [$height, $width]); |
| 418 | 418 | $x = 1; |
| 419 | 419 | $y = 5; |
| 420 | - $this->SetXY($x,$y); |
|
| 420 | + $this->SetXY($x, $y); |
|
| 421 | 421 | // agregar datos del documento |
| 422 | 422 | $this->setFont('', '', 8); |
| 423 | 423 | $this->MultiTexto(!empty($dte['Encabezado']['Emisor']['RznSoc']) ? $dte['Encabezado']['Emisor']['RznSoc'] : $dte['Encabezado']['Emisor']['RznSocEmisor'], $x, null, '', $width-2); |
@@ -497,13 +497,13 @@ discard block |
||
| 497 | 497 | $this->logo['uri'], |
| 498 | 498 | $x, |
| 499 | 499 | $y, |
| 500 | - !$this->logo['posicion']?$w_img:null, $this->logo['posicion']?($w_img/2):null, |
|
| 500 | + !$this->logo['posicion'] ? $w_img : null, $this->logo['posicion'] ? ($w_img / 2) : null, |
|
| 501 | 501 | 'PNG', |
| 502 | - (isset($emisor['url'])?$emisor['url']:''), |
|
| 502 | + (isset($emisor['url']) ? $emisor['url'] : ''), |
|
| 503 | 503 | 'T' |
| 504 | 504 | ); |
| 505 | 505 | if ($this->logo['posicion']) { |
| 506 | - $this->SetY($this->y + ($w_img/2)); |
|
| 506 | + $this->SetY($this->y+($w_img / 2)); |
|
| 507 | 507 | $w += 40; |
| 508 | 508 | } else { |
| 509 | 509 | $x = $this->x+3; |
@@ -514,13 +514,13 @@ discard block |
||
| 514 | 514 | } |
| 515 | 515 | // agregar datos del emisor |
| 516 | 516 | $this->setFont('', 'B', $font_size ? $font_size : 14); |
| 517 | - $this->SetTextColorArray($color===null?[32, 92, 144]:$color); |
|
| 517 | + $this->SetTextColorArray($color===null ? [32, 92, 144] : $color); |
|
| 518 | 518 | $this->MultiTexto(!empty($emisor['RznSoc']) ? $emisor['RznSoc'] : $emisor['RznSocEmisor'], $x, $this->y+2, 'L', $w); |
| 519 | 519 | $this->setFont('', 'B', $font_size ? $font_size : 9); |
| 520 | - $this->SetTextColorArray([0,0,0]); |
|
| 520 | + $this->SetTextColorArray([0, 0, 0]); |
|
| 521 | 521 | $this->MultiTexto(!empty($emisor['GiroEmis']) ? $emisor['GiroEmis'] : $emisor['GiroEmisor'], $x, $this->y, 'L', $w); |
| 522 | 522 | $ciudad = !empty($emisor['CiudadOrigen']) ? $emisor['CiudadOrigen'] : \sasco\LibreDTE\Chile::getCiudad($emisor['CmnaOrigen']); |
| 523 | - $this->MultiTexto($emisor['DirOrigen'].', '.$emisor['CmnaOrigen'].($ciudad?(', '.$ciudad):''), $x, $this->y, 'L', $w); |
|
| 523 | + $this->MultiTexto($emisor['DirOrigen'].', '.$emisor['CmnaOrigen'].($ciudad ? (', '.$ciudad) : ''), $x, $this->y, 'L', $w); |
|
| 524 | 524 | if (!empty($emisor['Sucursal'])) { |
| 525 | 525 | $this->MultiTexto('Sucursal: '.$emisor['Sucursal'], $x, $this->y, 'L', $w); |
| 526 | 526 | } |
@@ -564,12 +564,12 @@ discard block |
||
| 564 | 564 | private function agregarFolio($rut, $tipo, $folio, $sucursal_sii = null, $x = 130, $y = 15, $w = 70, $font_size = null, array $color = null) |
| 565 | 565 | { |
| 566 | 566 | if ($color===null) { |
| 567 | - $color = $tipo ? ($tipo==52 ? [0,172,140] : [255,0,0]) : [0,0,0]; |
|
| 567 | + $color = $tipo ? ($tipo==52 ? [0, 172, 140] : [255, 0, 0]) : [0, 0, 0]; |
|
| 568 | 568 | } |
| 569 | 569 | $this->SetTextColorArray($color); |
| 570 | 570 | // colocar rut emisor, glosa documento y folio |
| 571 | 571 | list($rut, $dv) = explode('-', $rut); |
| 572 | - $this->setFont ('', 'B', $font_size ? $font_size : 15); |
|
| 572 | + $this->setFont('', 'B', $font_size ? $font_size : 15); |
|
| 573 | 573 | $this->MultiTexto('R.U.T.: '.$this->num($rut).'-'.$dv, $x, $y+4, 'C', $w); |
| 574 | 574 | $this->setFont('', 'B', $font_size ? $font_size : 12); |
| 575 | 575 | $this->MultiTexto($this->getTipo($tipo), $x, null, 'C', $w); |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | if ($tipo) { |
| 583 | 583 | $this->Texto('S.I.I. - '.\sasco\LibreDTE\Sii::getDireccionRegional($sucursal_sii), $x, $this->getY()+4, 'C', $w); |
| 584 | 584 | } |
| 585 | - $this->SetTextColorArray([0,0,0]); |
|
| 585 | + $this->SetTextColorArray([0, 0, 0]); |
|
| 586 | 586 | $this->Ln(); |
| 587 | 587 | return $this->y; |
| 588 | 588 | } |
@@ -713,7 +713,7 @@ discard block |
||
| 713 | 713 | $this->Texto('Señor(es)', $x); |
| 714 | 714 | $this->Texto(':', $x+$offset); |
| 715 | 715 | $this->setFont('', '', null); |
| 716 | - $this->MultiTexto($receptor['RznSocRecep'], $x+$offset+2, null, '', $x==10?105:0); |
|
| 716 | + $this->MultiTexto($receptor['RznSocRecep'], $x+$offset+2, null, '', $x==10 ? 105 : 0); |
|
| 717 | 717 | } |
| 718 | 718 | if (!empty($receptor['GiroRecep'])) { |
| 719 | 719 | $this->setFont('', 'B', null); |
@@ -730,7 +730,7 @@ discard block |
||
| 730 | 730 | $ciudad = !empty($receptor['CiudadRecep']) ? $receptor['CiudadRecep'] : ( |
| 731 | 731 | !empty($receptor['CmnaRecep']) ? \sasco\LibreDTE\Chile::getCiudad($receptor['CmnaRecep']) : '' |
| 732 | 732 | ); |
| 733 | - $this->MultiTexto($receptor['DirRecep'].(!empty($receptor['CmnaRecep'])?(', '.$receptor['CmnaRecep']):'').($ciudad?(', '.$ciudad):''), $x+$offset+2); |
|
| 733 | + $this->MultiTexto($receptor['DirRecep'].(!empty($receptor['CmnaRecep']) ? (', '.$receptor['CmnaRecep']) : '').($ciudad ? (', '.$ciudad) : ''), $x+$offset+2); |
|
| 734 | 734 | } |
| 735 | 735 | if (!empty($receptor['Extranjero']['Nacionalidad'])) { |
| 736 | 736 | $this->setFont('', 'B', null); |
@@ -771,7 +771,7 @@ discard block |
||
| 771 | 771 | $this->Texto('Cód. recep.', $x); |
| 772 | 772 | $this->Texto(':', $x+$offset); |
| 773 | 773 | $this->setFont('', '', null); |
| 774 | - $this->MultiTexto($receptor['CdgIntRecep'], $x+$offset+2, null, '', $x==10?105:0); |
|
| 774 | + $this->MultiTexto($receptor['CdgIntRecep'], $x+$offset+2, null, '', $x==10 ? 105 : 0); |
|
| 775 | 775 | } |
| 776 | 776 | return $this->GetY(); |
| 777 | 777 | } |
@@ -859,7 +859,7 @@ discard block |
||
| 859 | 859 | { |
| 860 | 860 | if (!isset($referencias[0])) |
| 861 | 861 | $referencias = [$referencias]; |
| 862 | - foreach($referencias as $r) { |
|
| 862 | + foreach ($referencias as $r) { |
|
| 863 | 863 | $texto = $r['NroLinRef'].' - '.$this->getTipo($r['TpoDocRef']).' N° '.$r['FolioRef'].' del '.$r['FchRef']; |
| 864 | 864 | if (isset($r['RazonRef']) and $r['RazonRef']!==false) |
| 865 | 865 | $texto = $texto.': '.$r['RazonRef']; |
@@ -952,9 +952,9 @@ discard block |
||
| 952 | 952 | $this->SetY($this->getY()+1); |
| 953 | 953 | $p1x = $x; |
| 954 | 954 | $p1y = $this->y; |
| 955 | - $p2x = $this->getPageWidth() - 2; |
|
| 956 | - $p2y = $p1y; // Use same y for a straight line |
|
| 957 | - $style = array('width' => 0.2,'color' => array(0, 0, 0)); |
|
| 955 | + $p2x = $this->getPageWidth()-2; |
|
| 956 | + $p2y = $p1y; // Use same y for a straight line |
|
| 957 | + $style = array('width' => 0.2, 'color' => array(0, 0, 0)); |
|
| 958 | 958 | $this->Line($p1x, $p1y, $p2x, $p2y, $style); |
| 959 | 959 | $this->Texto($this->detalle_cols['NmbItem']['title'], $x+1, $this->y, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']); |
| 960 | 960 | $this->Texto($this->detalle_cols['PrcItem']['title'], $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']); |
@@ -964,9 +964,9 @@ discard block |
||
| 964 | 964 | if (!isset($detalle[0])) |
| 965 | 965 | $detalle = [$detalle]; |
| 966 | 966 | $this->SetY($this->getY()+2); |
| 967 | - foreach($detalle as &$d) { |
|
| 967 | + foreach ($detalle as &$d) { |
|
| 968 | 968 | $this->MultiTexto($d['NmbItem'], $x+1, $this->y+4, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']); |
| 969 | - $this->Texto(number_format($d['PrcItem'],0,',','.'), $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']); |
|
| 969 | + $this->Texto(number_format($d['PrcItem'], 0, ',', '.'), $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']); |
|
| 970 | 970 | $this->Texto($this->num($d['QtyItem']), $x+35, $this->y, ucfirst($this->detalle_cols['QtyItem']['align'][0]), $this->detalle_cols['QtyItem']['width']); |
| 971 | 971 | $this->Texto($this->num($d['MontoItem']), $x+45, $this->y, ucfirst($this->detalle_cols['MontoItem']['align'][0]), $this->detalle_cols['MontoItem']['width']); |
| 972 | 972 | } |
@@ -986,7 +986,7 @@ discard block |
||
| 986 | 986 | if (!isset($detalle[0])) { |
| 987 | 987 | $detalle = [$detalle]; |
| 988 | 988 | } |
| 989 | - foreach($detalle as &$d) { |
|
| 989 | + foreach ($detalle as &$d) { |
|
| 990 | 990 | if (!empty($d['MontoItem'])) { |
| 991 | 991 | $subtotal += $d['MontoItem']; |
| 992 | 992 | } |
@@ -1011,13 +1011,13 @@ discard block |
||
| 1011 | 1011 | { |
| 1012 | 1012 | if (!isset($descuentosRecargos[0])) |
| 1013 | 1013 | $descuentosRecargos = [$descuentosRecargos]; |
| 1014 | - foreach($descuentosRecargos as $dr) { |
|
| 1014 | + foreach ($descuentosRecargos as $dr) { |
|
| 1015 | 1015 | $tipo = $dr['TpoMov']=='D' ? 'Descuento' : 'Recargo'; |
| 1016 | 1016 | $valor = $dr['TpoValor']=='%' ? $dr['ValorDR'].'%' : $this->num($dr['ValorDR']); |
| 1017 | 1017 | if ($this->papelContinuo) { |
| 1018 | - $this->Texto($tipo.' global: '.$valor.(!empty($dr['GlosaDR'])?(' ('.$dr['GlosaDR'].')'):''), $x); |
|
| 1018 | + $this->Texto($tipo.' global: '.$valor.(!empty($dr['GlosaDR']) ? (' ('.$dr['GlosaDR'].')') : ''), $x); |
|
| 1019 | 1019 | } else { |
| 1020 | - $this->Texto($tipo.(!empty($dr['GlosaDR'])?(' ('.$dr['GlosaDR'].')'):'').':', 77, null, 'R', 100); |
|
| 1020 | + $this->Texto($tipo.(!empty($dr['GlosaDR']) ? (' ('.$dr['GlosaDR'].')') : '').':', 77, null, 'R', 100); |
|
| 1021 | 1021 | $this->Texto($valor, 177, null, 'R', 22); |
| 1022 | 1022 | } |
| 1023 | 1023 | $this->Ln(); |
@@ -1037,8 +1037,8 @@ discard block |
||
| 1037 | 1037 | $pagos = [$pagos]; |
| 1038 | 1038 | $this->Texto('Pago(s) programado(s):', $x); |
| 1039 | 1039 | $this->Ln(); |
| 1040 | - foreach($pagos as $p) { |
|
| 1041 | - $this->Texto(' - '.$this->date($p['FchPago'], false).': $'.$this->num($p['MntPago']).'.-'.(!empty($p['GlosaPagos'])?(' ('.$p['GlosaPagos'].')'):''), $x); |
|
| 1040 | + foreach ($pagos as $p) { |
|
| 1041 | + $this->Texto(' - '.$this->date($p['FchPago'], false).': $'.$this->num($p['MntPago']).'.-'.(!empty($p['GlosaPagos']) ? (' ('.$p['GlosaPagos'].')') : ''), $x); |
|
| 1042 | 1042 | $this->Ln(); |
| 1043 | 1043 | } |
| 1044 | 1044 | } |
@@ -1088,7 +1088,7 @@ discard block |
||
| 1088 | 1088 | if (!isset($ImptoReten[0])) { |
| 1089 | 1089 | $ImptoReten = [$ImptoReten]; |
| 1090 | 1090 | } |
| 1091 | - foreach($ImptoReten as $i) { |
|
| 1091 | + foreach ($ImptoReten as $i) { |
|
| 1092 | 1092 | $totales['ImptoReten_'.$i['TipoImp']] = $i['MontoImp']; |
| 1093 | 1093 | if (!empty($i['TasaImp'])) { |
| 1094 | 1094 | $glosas['ImptoReten_'.$i['TipoImp']] = \sasco\LibreDTE\Sii\ImpuestosAdicionales::getGlosa($i['TipoImp']).' ('.$i['TasaImp'].'%) $'; |
@@ -1153,7 +1153,7 @@ discard block |
||
| 1153 | 1153 | 'vpadding' => 0, |
| 1154 | 1154 | 'module_width' => 1, // width of a single module in points |
| 1155 | 1155 | 'module_height' => 1, // height of a single module in points |
| 1156 | - 'fgcolor' => [0,0,0], |
|
| 1156 | + 'fgcolor' => [0, 0, 0], |
|
| 1157 | 1157 | 'bgcolor' => false, // [255,255,255] |
| 1158 | 1158 | 'position' => $this->papelContinuo ? 'C' : 'S', |
| 1159 | 1159 | ]; |
@@ -1185,7 +1185,7 @@ discard block |
||
| 1185 | 1185 | */ |
| 1186 | 1186 | private function agregarAcuseRecibo($x = 93, $y = 190, $w = 50, $h = 40) |
| 1187 | 1187 | { |
| 1188 | - $this->SetTextColorArray([0,0,0]); |
|
| 1188 | + $this->SetTextColorArray([0, 0, 0]); |
|
| 1189 | 1189 | $this->Rect($x, $y, $w, $h, 'D', ['all' => ['width' => 0.1, 'color' => [0, 0, 0]]]); |
| 1190 | 1190 | $this->setFont('', 'B', 10); |
| 1191 | 1191 | $this->Texto('Acuse de recibo', $x, $y+1, 'C', $w); |
@@ -1215,9 +1215,9 @@ discard block |
||
| 1215 | 1215 | */ |
| 1216 | 1216 | private function agregarAcuseReciboContinuo($x = 3, $y = null, $w = 68, $h = 40) |
| 1217 | 1217 | { |
| 1218 | - $this->SetTextColorArray([0,0,0]); |
|
| 1218 | + $this->SetTextColorArray([0, 0, 0]); |
|
| 1219 | 1219 | $this->Rect($x, $y, $w, $h, 'D', ['all' => ['width' => 0.1, 'color' => [0, 0, 0]]]); |
| 1220 | - $style = array('width' => 0.2,'color' => array(0, 0, 0)); |
|
| 1220 | + $style = array('width' => 0.2, 'color' => array(0, 0, 0)); |
|
| 1221 | 1221 | $this->Line($x, $y+22, $w+3, $y+22, $style); |
| 1222 | 1222 | //$this->setFont('', 'B', 10); |
| 1223 | 1223 | //$this->Texto('Acuse de recibo', $x, $y+1, 'C', $w); |
@@ -1245,7 +1245,7 @@ discard block |
||
| 1245 | 1245 | private function agregarLeyendaDestino($tipo, $y = 254, $font_size = 10) |
| 1246 | 1246 | { |
| 1247 | 1247 | $this->setFont('', 'B', $font_size); |
| 1248 | - $this->Texto('CEDIBLE'.($tipo==52?' CON SU FACTURA':''), null, $y, 'R'); |
|
| 1248 | + $this->Texto('CEDIBLE'.($tipo==52 ? ' CON SU FACTURA' : ''), null, $y, 'R'); |
|
| 1249 | 1249 | } |
| 1250 | 1250 | |
| 1251 | 1251 | /** |
@@ -1276,7 +1276,7 @@ discard block |
||
| 1276 | 1276 | $dias = ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado']; |
| 1277 | 1277 | $meses = ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre']; |
| 1278 | 1278 | $unixtime = strtotime($date); |
| 1279 | - $fecha = date(($mostrar_dia?'\D\I\A ':'').'j \d\e \M\E\S \d\e\l Y', $unixtime); |
|
| 1279 | + $fecha = date(($mostrar_dia ? '\D\I\A ' : '').'j \d\e \M\E\S \d\e\l Y', $unixtime); |
|
| 1280 | 1280 | $dia = $dias[date('w', $unixtime)]; |
| 1281 | 1281 | $mes = $meses[date('n', $unixtime)-1]; |
| 1282 | 1282 | return str_replace(array('DIA', 'MES'), array($dia, $mes), $fecha); |
@@ -310,15 +310,17 @@ discard block |
||
| 310 | 310 | !empty($dte['Encabezado']['IdDoc']['IndTraslado']) ? $dte['Encabezado']['IdDoc']['IndTraslado'] : null, |
| 311 | 311 | !empty($dte['Encabezado']['Transporte']) ? $dte['Encabezado']['Transporte'] : null |
| 312 | 312 | ); |
| 313 | - if (!empty($dte['Referencia'])) |
|
| 314 | - $this->agregarReferencia($dte['Referencia']); |
|
| 313 | + if (!empty($dte['Referencia'])) { |
|
| 314 | + $this->agregarReferencia($dte['Referencia']); |
|
| 315 | + } |
|
| 315 | 316 | $this->agregarDetalle($dte['Detalle']); |
| 316 | 317 | if (!empty($dte['DscRcgGlobal'])) { |
| 317 | 318 | $this->agregarSubTotal($dte['Detalle']); |
| 318 | 319 | $this->agregarDescuentosRecargos($dte['DscRcgGlobal']); |
| 319 | 320 | } |
| 320 | - if (!empty($dte['Encabezado']['IdDoc']['MntPagos'])) |
|
| 321 | - $this->agregarPagos($dte['Encabezado']['IdDoc']['MntPagos']); |
|
| 321 | + if (!empty($dte['Encabezado']['IdDoc']['MntPagos'])) { |
|
| 322 | + $this->agregarPagos($dte['Encabezado']['IdDoc']['MntPagos']); |
|
| 323 | + } |
|
| 322 | 324 | $this->agregarTotales($dte['Encabezado']['Totales']); |
| 323 | 325 | // agregar observaciones |
| 324 | 326 | $this->agregarObservacion($dte['Encabezado']['IdDoc']); |
@@ -350,8 +352,12 @@ discard block |
||
| 350 | 352 | // determinar alto de la página y agregarla |
| 351 | 353 | $height = 145; |
| 352 | 354 | $n_detalle = count($dte['Detalle']); |
| 353 | - if ($n_detalle>1) $height += $n_detalle*20; |
|
| 354 | - if ($this->cedible) $height += 50; |
|
| 355 | + if ($n_detalle>1) { |
|
| 356 | + $height += $n_detalle*20; |
|
| 357 | + } |
|
| 358 | + if ($this->cedible) { |
|
| 359 | + $height += 50; |
|
| 360 | + } |
|
| 355 | 361 | $this->AddPage('P', [$height, $width]); |
| 356 | 362 | // agregar cabecera del documento |
| 357 | 363 | $y = $this->agregarFolio( |
@@ -412,8 +418,12 @@ discard block |
||
| 412 | 418 | { |
| 413 | 419 | // determinar alto de la página y agregarla |
| 414 | 420 | $height = 100; |
| 415 | - if ($this->cedible) $height += 50; |
|
| 416 | - if ($dte['Encabezado']['Receptor']['RUTRecep']!='66666666-6') $height += 40; |
|
| 421 | + if ($this->cedible) { |
|
| 422 | + $height += 50; |
|
| 423 | + } |
|
| 424 | + if ($dte['Encabezado']['Receptor']['RUTRecep']!='66666666-6') { |
|
| 425 | + $height += 40; |
|
| 426 | + } |
|
| 417 | 427 | $this->AddPage('P', [$height, $width]); |
| 418 | 428 | $x = 1; |
| 419 | 429 | $y = 5; |
@@ -526,10 +536,12 @@ discard block |
||
| 526 | 536 | } |
| 527 | 537 | $contacto = []; |
| 528 | 538 | if (!empty($emisor['Telefono'])) { |
| 529 | - if (!is_array($emisor['Telefono'])) |
|
| 530 | - $emisor['Telefono'] = [$emisor['Telefono']]; |
|
| 531 | - foreach ($emisor['Telefono'] as $t) |
|
| 532 | - $contacto[] = $t; |
|
| 539 | + if (!is_array($emisor['Telefono'])) { |
|
| 540 | + $emisor['Telefono'] = [$emisor['Telefono']]; |
|
| 541 | + } |
|
| 542 | + foreach ($emisor['Telefono'] as $t) { |
|
| 543 | + $contacto[] = $t; |
|
| 544 | + } |
|
| 533 | 545 | } |
| 534 | 546 | if (!empty($emisor['CorreoEmisor'])) { |
| 535 | 547 | $contacto[] = $emisor['CorreoEmisor']; |
@@ -596,8 +608,9 @@ discard block |
||
| 596 | 608 | */ |
| 597 | 609 | private function getTipo($tipo) |
| 598 | 610 | { |
| 599 | - if (!is_numeric($tipo) and !isset($this->tipos[$tipo])) |
|
| 600 | - return $tipo; |
|
| 611 | + if (!is_numeric($tipo) and !isset($this->tipos[$tipo])) { |
|
| 612 | + return $tipo; |
|
| 613 | + } |
|
| 601 | 614 | return isset($this->tipos[$tipo]) ? strtoupper($this->tipos[$tipo]) : 'Documento '.$tipo; |
| 602 | 615 | } |
| 603 | 616 | |
@@ -747,10 +760,12 @@ discard block |
||
| 747 | 760 | $this->MultiTexto($receptor['Extranjero']['NumId'], $x+$offset+2); |
| 748 | 761 | } |
| 749 | 762 | $contacto = []; |
| 750 | - if (!empty($receptor['Contacto'])) |
|
| 751 | - $contacto[] = $receptor['Contacto']; |
|
| 752 | - if (!empty($receptor['CorreoRecep'])) |
|
| 753 | - $contacto[] = $receptor['CorreoRecep']; |
|
| 763 | + if (!empty($receptor['Contacto'])) { |
|
| 764 | + $contacto[] = $receptor['Contacto']; |
|
| 765 | + } |
|
| 766 | + if (!empty($receptor['CorreoRecep'])) { |
|
| 767 | + $contacto[] = $receptor['CorreoRecep']; |
|
| 768 | + } |
|
| 754 | 769 | if (!empty($contacto)) { |
| 755 | 770 | $this->setFont('', 'B', null); |
| 756 | 771 | $this->Texto('Contacto', $x); |
@@ -800,15 +815,19 @@ discard block |
||
| 800 | 815 | if (!empty($Transporte['DirDest']) and !empty($Transporte['CmnaDest'])) { |
| 801 | 816 | $transporte .= 'a '.$Transporte['DirDest'].', '.$Transporte['CmnaDest']; |
| 802 | 817 | } |
| 803 | - if (!empty($Transporte['RUTTrans'])) |
|
| 804 | - $transporte .= ' por '.$Transporte['RUTTrans']; |
|
| 805 | - if (!empty($Transporte['Patente'])) |
|
| 806 | - $transporte .= ' en vehículo '.$Transporte['Patente']; |
|
| 818 | + if (!empty($Transporte['RUTTrans'])) { |
|
| 819 | + $transporte .= ' por '.$Transporte['RUTTrans']; |
|
| 820 | + } |
|
| 821 | + if (!empty($Transporte['Patente'])) { |
|
| 822 | + $transporte .= ' en vehículo '.$Transporte['Patente']; |
|
| 823 | + } |
|
| 807 | 824 | if (isset($Transporte['Chofer']) and is_array($Transporte['Chofer'])) { |
| 808 | - if (!empty($Transporte['Chofer']['NombreChofer'])) |
|
| 809 | - $transporte .= ' con chofer '.$Transporte['Chofer']['NombreChofer']; |
|
| 810 | - if (!empty($Transporte['Chofer']['RUTChofer'])) |
|
| 811 | - $transporte .= ' ('.$Transporte['Chofer']['RUTChofer'].')'; |
|
| 825 | + if (!empty($Transporte['Chofer']['NombreChofer'])) { |
|
| 826 | + $transporte .= ' con chofer '.$Transporte['Chofer']['NombreChofer']; |
|
| 827 | + } |
|
| 828 | + if (!empty($Transporte['Chofer']['RUTChofer'])) { |
|
| 829 | + $transporte .= ' ('.$Transporte['Chofer']['RUTChofer'].')'; |
|
| 830 | + } |
|
| 812 | 831 | } |
| 813 | 832 | if ($transporte) { |
| 814 | 833 | $this->setFont('', 'B', null); |
@@ -822,8 +841,9 @@ discard block |
||
| 822 | 841 | if (!empty($Transporte['Aduana']) and is_array($Transporte['Aduana'])) { |
| 823 | 842 | $col = 0; |
| 824 | 843 | foreach ($Transporte['Aduana'] as $tag => $codigo) { |
| 825 | - if ($codigo===false) |
|
| 826 | - continue; |
|
| 844 | + if ($codigo===false) { |
|
| 845 | + continue; |
|
| 846 | + } |
|
| 827 | 847 | $glosa = \sasco\LibreDTE\Sii\Aduana::getGlosa($tag); |
| 828 | 848 | $valor = \sasco\LibreDTE\Sii\Aduana::getValor($tag, $codigo); |
| 829 | 849 | if ($glosa!==false and $valor!==false) { |
@@ -836,15 +856,18 @@ discard block |
||
| 836 | 856 | $this->Texto(':', $x+$offset+$col); |
| 837 | 857 | $this->setFont('', '', null); |
| 838 | 858 | $this->Texto($valor, $x+$offset+2+$col); |
| 839 | - if ($tag=='TipoBultos') |
|
| 840 | - $col = abs($col-110); |
|
| 841 | - if ($col) |
|
| 842 | - $this->Ln(); |
|
| 859 | + if ($tag=='TipoBultos') { |
|
| 860 | + $col = abs($col-110); |
|
| 861 | + } |
|
| 862 | + if ($col) { |
|
| 863 | + $this->Ln(); |
|
| 864 | + } |
|
| 843 | 865 | $col = abs($col-110); |
| 844 | 866 | } |
| 845 | 867 | } |
| 846 | - if ($col) |
|
| 847 | - $this->Ln(); |
|
| 868 | + if ($col) { |
|
| 869 | + $this->Ln(); |
|
| 870 | + } |
|
| 848 | 871 | } |
| 849 | 872 | } |
| 850 | 873 | |
@@ -857,12 +880,14 @@ discard block |
||
| 857 | 880 | */ |
| 858 | 881 | private function agregarReferencia($referencias, $x = 10, $offset = 22) |
| 859 | 882 | { |
| 860 | - if (!isset($referencias[0])) |
|
| 861 | - $referencias = [$referencias]; |
|
| 883 | + if (!isset($referencias[0])) { |
|
| 884 | + $referencias = [$referencias]; |
|
| 885 | + } |
|
| 862 | 886 | foreach($referencias as $r) { |
| 863 | 887 | $texto = $r['NroLinRef'].' - '.$this->getTipo($r['TpoDocRef']).' N° '.$r['FolioRef'].' del '.$r['FchRef']; |
| 864 | - if (isset($r['RazonRef']) and $r['RazonRef']!==false) |
|
| 865 | - $texto = $texto.': '.$r['RazonRef']; |
|
| 888 | + if (isset($r['RazonRef']) and $r['RazonRef']!==false) { |
|
| 889 | + $texto = $texto.': '.$r['RazonRef']; |
|
| 890 | + } |
|
| 866 | 891 | $this->setFont('', 'B', null); |
| 867 | 892 | $this->Texto('Referencia', $x); |
| 868 | 893 | $this->Texto(':', $x+$offset); |
@@ -881,8 +906,9 @@ discard block |
||
| 881 | 906 | */ |
| 882 | 907 | private function agregarDetalle($detalle, $x = 10) |
| 883 | 908 | { |
| 884 | - if (!isset($detalle[0])) |
|
| 885 | - $detalle = [$detalle]; |
|
| 909 | + if (!isset($detalle[0])) { |
|
| 910 | + $detalle = [$detalle]; |
|
| 911 | + } |
|
| 886 | 912 | $this->setFont('', '', $this->detalle_fuente); |
| 887 | 913 | // titulos |
| 888 | 914 | $titulos = []; |
@@ -899,36 +925,42 @@ discard block |
||
| 899 | 925 | $item['NmbItem'] .= !$this->item_detalle_posicion ? '<br/>' : ': '; |
| 900 | 926 | $item['NmbItem'] .= '<span style="font-size:0.7em">'.$item['DscItem'].'</span>'; |
| 901 | 927 | } |
| 902 | - if (!in_array($col, $titulos_keys) or ($dte_exento and $col=='IndExe')) |
|
| 903 | - unset($item[$col]); |
|
| 928 | + if (!in_array($col, $titulos_keys) or ($dte_exento and $col=='IndExe')) { |
|
| 929 | + unset($item[$col]); |
|
| 930 | + } |
|
| 904 | 931 | } |
| 905 | 932 | // ajustes a IndExe |
| 906 | 933 | if (isset($item['IndExe'])) { |
| 907 | - if ($item['IndExe']==1) |
|
| 908 | - $item['IndExe'] = 'EX'; |
|
| 909 | - else if ($item['IndExe']==2) |
|
| 910 | - $item['IndExe'] = 'NF'; |
|
| 934 | + if ($item['IndExe']==1) { |
|
| 935 | + $item['IndExe'] = 'EX'; |
|
| 936 | + } else if ($item['IndExe']==2) { |
|
| 937 | + $item['IndExe'] = 'NF'; |
|
| 938 | + } |
|
| 911 | 939 | } |
| 912 | 940 | // agregar todas las columnas que se podrían imprimir en la tabla |
| 913 | 941 | $item_default = []; |
| 914 | - foreach ($this->detalle_cols as $key => $info) |
|
| 915 | - $item_default[$key] = false; |
|
| 942 | + foreach ($this->detalle_cols as $key => $info) { |
|
| 943 | + $item_default[$key] = false; |
|
| 944 | + } |
|
| 916 | 945 | $item = array_merge($item_default, $item); |
| 917 | 946 | // si hay código de item se extrae su valor |
| 918 | - if ($item['CdgItem']) |
|
| 919 | - $item['CdgItem'] = $item['CdgItem']['VlrCodigo']; |
|
| 947 | + if ($item['CdgItem']) { |
|
| 948 | + $item['CdgItem'] = $item['CdgItem']['VlrCodigo']; |
|
| 949 | + } |
|
| 920 | 950 | // dar formato a números |
| 921 | 951 | foreach (['QtyItem', 'PrcItem', 'DescuentoMonto', 'RecargoMonto', 'MontoItem'] as $col) { |
| 922 | - if ($item[$col]) |
|
| 923 | - $item[$col] = $this->num($item[$col]); |
|
| 952 | + if ($item[$col]) { |
|
| 953 | + $item[$col] = $this->num($item[$col]); |
|
| 954 | + } |
|
| 924 | 955 | } |
| 925 | 956 | } |
| 926 | 957 | // opciones |
| 927 | 958 | $options = ['align'=>[]]; |
| 928 | 959 | $i = 0; |
| 929 | 960 | foreach ($this->detalle_cols as $info) { |
| 930 | - if (isset($info['width'])) |
|
| 931 | - $options['width'][$i] = $info['width']; |
|
| 961 | + if (isset($info['width'])) { |
|
| 962 | + $options['width'][$i] = $info['width']; |
|
| 963 | + } |
|
| 932 | 964 | $options['align'][$i] = $info['align']; |
| 933 | 965 | $i++; |
| 934 | 966 | } |
@@ -961,8 +993,9 @@ discard block |
||
| 961 | 993 | $this->Texto($this->detalle_cols['QtyItem']['title'], $x+35, $this->y, ucfirst($this->detalle_cols['QtyItem']['align'][0]), $this->detalle_cols['QtyItem']['width']); |
| 962 | 994 | $this->Texto($this->detalle_cols['MontoItem']['title'], $x+45, $this->y, ucfirst($this->detalle_cols['MontoItem']['align'][0]), $this->detalle_cols['MontoItem']['width']); |
| 963 | 995 | $this->Line($p1x, $p1y+4, $p2x, $p2y+4, $style); |
| 964 | - if (!isset($detalle[0])) |
|
| 965 | - $detalle = [$detalle]; |
|
| 996 | + if (!isset($detalle[0])) { |
|
| 997 | + $detalle = [$detalle]; |
|
| 998 | + } |
|
| 966 | 999 | $this->SetY($this->getY()+2); |
| 967 | 1000 | foreach($detalle as &$d) { |
| 968 | 1001 | $this->MultiTexto($d['NmbItem'], $x+1, $this->y+4, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']); |
@@ -1009,8 +1042,9 @@ discard block |
||
| 1009 | 1042 | */ |
| 1010 | 1043 | private function agregarDescuentosRecargos(array $descuentosRecargos, $x = 10) |
| 1011 | 1044 | { |
| 1012 | - if (!isset($descuentosRecargos[0])) |
|
| 1013 | - $descuentosRecargos = [$descuentosRecargos]; |
|
| 1045 | + if (!isset($descuentosRecargos[0])) { |
|
| 1046 | + $descuentosRecargos = [$descuentosRecargos]; |
|
| 1047 | + } |
|
| 1014 | 1048 | foreach($descuentosRecargos as $dr) { |
| 1015 | 1049 | $tipo = $dr['TpoMov']=='D' ? 'Descuento' : 'Recargo'; |
| 1016 | 1050 | $valor = $dr['TpoValor']=='%' ? $dr['ValorDR'].'%' : $this->num($dr['ValorDR']); |
@@ -1033,8 +1067,9 @@ discard block |
||
| 1033 | 1067 | */ |
| 1034 | 1068 | private function agregarPagos(array $pagos, $x = 10) |
| 1035 | 1069 | { |
| 1036 | - if (!isset($pagos[0])) |
|
| 1037 | - $pagos = [$pagos]; |
|
| 1070 | + if (!isset($pagos[0])) { |
|
| 1071 | + $pagos = [$pagos]; |
|
| 1072 | + } |
|
| 1038 | 1073 | $this->Texto('Pago(s) programado(s):', $x); |
| 1039 | 1074 | $this->Ln(); |
| 1040 | 1075 | foreach($pagos as $p) { |
@@ -1258,11 +1293,13 @@ discard block |
||
| 1258 | 1293 | */ |
| 1259 | 1294 | private function num($n) |
| 1260 | 1295 | { |
| 1261 | - if (!is_numeric($n)) |
|
| 1262 | - return $n; |
|
| 1296 | + if (!is_numeric($n)) { |
|
| 1297 | + return $n; |
|
| 1298 | + } |
|
| 1263 | 1299 | $broken_number = explode('.', (string)$n); |
| 1264 | - if (isset($broken_number[1])) |
|
| 1265 | - return number_format($broken_number[0], 0, ',', '.').','.$broken_number[1]; |
|
| 1300 | + if (isset($broken_number[1])) { |
|
| 1301 | + return number_format($broken_number[0], 0, ',', '.').','.$broken_number[1]; |
|
| 1302 | + } |
|
| 1266 | 1303 | return number_format($broken_number[0], 0, ',', '.'); |
| 1267 | 1304 | } |
| 1268 | 1305 | |
@@ -79,11 +79,11 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | // calcular valores que no se hayan entregado |
| 81 | 81 | if (!$detalle['IVA'] and $detalle['TasaImp'] and $detalle['MntNeto']) { |
| 82 | - $detalle['IVA'] = round($detalle['MntNeto'] * ($detalle['TasaImp']/100)); |
|
| 82 | + $detalle['IVA'] = round($detalle['MntNeto'] * ($detalle['TasaImp'] / 100)); |
|
| 83 | 83 | } |
| 84 | 84 | // calcular monto total si no se especificó |
| 85 | 85 | if ($detalle['MntTotal']===false) { |
| 86 | - $detalle['MntTotal'] = $detalle['MntNeto'] + $detalle['IVA']; |
|
| 86 | + $detalle['MntTotal'] = $detalle['MntNeto']+$detalle['IVA']; |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $data = \sasco\LibreDTE\CSV::read($archivo); |
| 101 | 101 | $n_data = count($data); |
| 102 | 102 | $detalles = []; |
| 103 | - for ($i=1; $i<$n_data; $i++) { |
|
| 103 | + for ($i = 1; $i<$n_data; $i++) { |
|
| 104 | 104 | // detalle genérico |
| 105 | 105 | $detalle = [ |
| 106 | 106 | 'Folio' => $data[$i][0], |
@@ -203,17 +203,17 @@ discard block |
||
| 203 | 203 | // se contabiliza si la guía está anulada |
| 204 | 204 | if ($d['Anulado']==1 or $d['Anulado']==2) { |
| 205 | 205 | if ($d['Anulado']==1) { |
| 206 | - $ResumenPeriodo['TotFolAnulado'] = (int)$ResumenPeriodo['TotFolAnulado'] + 1; |
|
| 206 | + $ResumenPeriodo['TotFolAnulado'] = (int)$ResumenPeriodo['TotFolAnulado']+1; |
|
| 207 | 207 | } else { |
| 208 | - $ResumenPeriodo['TotGuiaAnulada'] = (int)$ResumenPeriodo['TotGuiaAnulada'] + 1; |
|
| 208 | + $ResumenPeriodo['TotGuiaAnulada'] = (int)$ResumenPeriodo['TotGuiaAnulada']+1; |
|
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | // si no está anulado |
| 212 | 212 | else { |
| 213 | 213 | // si es de venta |
| 214 | 214 | if ($d['TpoOper']==1) { |
| 215 | - $ResumenPeriodo['TotGuiaVenta'] = (int)$ResumenPeriodo['TotGuiaVenta'] + 1; |
|
| 216 | - $ResumenPeriodo['TotMntGuiaVta'] = (int)$ResumenPeriodo['TotMntGuiaVta'] + $d['MntTotal']; |
|
| 215 | + $ResumenPeriodo['TotGuiaVenta'] = (int)$ResumenPeriodo['TotGuiaVenta']+1; |
|
| 216 | + $ResumenPeriodo['TotMntGuiaVta'] = (int)$ResumenPeriodo['TotMntGuiaVta']+$d['MntTotal']; |
|
| 217 | 217 | } |
| 218 | 218 | // si no es de venta |
| 219 | 219 | else { |
@@ -57,8 +57,9 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | $this->startPageGroup(); |
| 59 | 59 | $this->AddPage(); |
| 60 | - if (isset($libro['LibroCompraVenta'])) |
|
| 61 | - $libro = $libro['LibroCompraVenta']; |
|
| 60 | + if (isset($libro['LibroCompraVenta'])) { |
|
| 61 | + $libro = $libro['LibroCompraVenta']; |
|
| 62 | + } |
|
| 62 | 63 | // título del libro |
| 63 | 64 | $this->SetFont('helvetica', 'B', 16); |
| 64 | 65 | $this->Texto('Libro de '.ucfirst(strtolower($libro['EnvioLibro']['Caratula']['TipoOperacion'])), null, null, 'C'); |
@@ -109,8 +110,7 @@ discard block |
||
| 109 | 110 | $total_resumen['TotIVARetTotal'] += !empty($total['TotIVARetTotal']) ? $total['TotIVARetTotal'] : 0; |
| 110 | 111 | $total_resumen['TotIVANoRetenido'] += !empty($total['TotIVANoRetenido']) ? $total['TotIVANoRetenido'] : 0; |
| 111 | 112 | $total_resumen['TotMntTotal'] += $total['TotMntTotal']; |
| 112 | - } |
|
| 113 | - else if (in_array($total['TpoDoc'], $this->dte_tipo_operacion['resta'])) { |
|
| 113 | + } else if (in_array($total['TpoDoc'], $this->dte_tipo_operacion['resta'])) { |
|
| 114 | 114 | $total_resumen['TotMntExe'] -= !empty($total['TotMntExe']) ? $total['TotMntExe'] : 0; |
| 115 | 115 | $total_resumen['TotMntNeto'] -= !empty($total['TotMntNeto']) ? $total['TotMntNeto'] : 0; |
| 116 | 116 | $total_resumen['TotMntIVA'] -= !empty($total['TotMntIVA']) ? $total['TotMntIVA'] : 0; |
@@ -171,10 +171,13 @@ discard block |
||
| 171 | 171 | foreach ($libro['EnvioLibro']['Detalle'] as $d) { |
| 172 | 172 | // impuesto adicional |
| 173 | 173 | if (!empty($d['OtrosImp'])) { |
| 174 | - if (!isset($d['OtrosImp'][0])) |
|
| 175 | - $d['OtrosImp'] = [$d['OtrosImp']]; |
|
| 174 | + if (!isset($d['OtrosImp'][0])) { |
|
| 175 | + $d['OtrosImp'] = [$d['OtrosImp']]; |
|
| 176 | + } |
|
| 176 | 177 | $n_OtrosImp = count($d['OtrosImp']); |
| 177 | - } else $n_OtrosImp = 0; |
|
| 178 | + } else { |
|
| 179 | + $n_OtrosImp = 0; |
|
| 180 | + } |
|
| 178 | 181 | // se agrega detalle |
| 179 | 182 | $detalle[] = [ |
| 180 | 183 | $d['TpoDoc'], |
@@ -96,10 +96,12 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | public function agregar(array $detalle, $normalizar = true) |
| 98 | 98 | { |
| 99 | - if ($normalizar) |
|
| 100 | - $this->normalizarDetalle($detalle); |
|
| 101 | - if (!$detalle['TpoDoc']) |
|
| 102 | - return false; |
|
| 99 | + if ($normalizar) { |
|
| 100 | + $this->normalizarDetalle($detalle); |
|
| 101 | + } |
|
| 102 | + if (!$detalle['TpoDoc']) { |
|
| 103 | + return false; |
|
| 104 | + } |
|
| 103 | 105 | $this->detalles[] = $detalle; |
| 104 | 106 | return true; |
| 105 | 107 | } |
@@ -166,8 +168,9 @@ discard block |
||
| 166 | 168 | $detalle['RznSoc'] = mb_substr($detalle['RznSoc'], 0, 50); |
| 167 | 169 | // calcular valores que no se hayan entregado |
| 168 | 170 | if (isset($detalle['FctProp'])) { |
| 169 | - if ($detalle['IVAUsoComun']===false) |
|
| 170 | - $detalle['IVAUsoComun'] = round($detalle['MntNeto'] * ($detalle['TasaImp']/100)); |
|
| 171 | + if ($detalle['IVAUsoComun']===false) { |
|
| 172 | + $detalle['IVAUsoComun'] = round($detalle['MntNeto'] * ($detalle['TasaImp']/100)); |
|
| 173 | + } |
|
| 171 | 174 | } else if (!$detalle['MntIVA'] and !is_array($detalle['IVANoRec']) and $detalle['TasaImp'] and $detalle['MntNeto']) { |
| 172 | 175 | $detalle['MntIVA'] = round($detalle['MntNeto'] * ($detalle['TasaImp']/100)); |
| 173 | 176 | } |
@@ -177,8 +180,9 @@ discard block |
||
| 177 | 180 | } |
| 178 | 181 | // normalizar IVA no recuperable |
| 179 | 182 | if (!empty($detalle['IVANoRec'])) { |
| 180 | - if (!isset($detalle['IVANoRec'][0])) |
|
| 181 | - $detalle['IVANoRec'] = [$detalle['IVANoRec']]; |
|
| 183 | + if (!isset($detalle['IVANoRec'][0])) { |
|
| 184 | + $detalle['IVANoRec'] = [$detalle['IVANoRec']]; |
|
| 185 | + } |
|
| 182 | 186 | // si son múltiples iva no recuperable se arma arreglo real |
| 183 | 187 | if (strpos($detalle['IVANoRec'][0]['CodIVANoRec'], ',')) { |
| 184 | 188 | $CodIVANoRec = explode(',', $detalle['IVANoRec'][0]['CodIVANoRec']); |
@@ -195,8 +199,9 @@ discard block |
||
| 195 | 199 | } |
| 196 | 200 | // normalizar otros impuestos |
| 197 | 201 | if (!empty($detalle['OtrosImp'])) { |
| 198 | - if (!isset($detalle['OtrosImp'][0])) |
|
| 199 | - $detalle['OtrosImp'] = [$detalle['OtrosImp']]; |
|
| 202 | + if (!isset($detalle['OtrosImp'][0])) { |
|
| 203 | + $detalle['OtrosImp'] = [$detalle['OtrosImp']]; |
|
| 204 | + } |
|
| 200 | 205 | // si son múltiples impuestos se arma arreglo real |
| 201 | 206 | if (strpos($detalle['OtrosImp'][0]['CodImp'], ',')) { |
| 202 | 207 | $CodImp = explode(',', $detalle['OtrosImp'][0]['CodImp']); |
@@ -257,8 +262,9 @@ discard block |
||
| 257 | 262 | } |
| 258 | 263 | // si el código de sucursal no existe se pone a falso, esto básicamente |
| 259 | 264 | // porque algunos sistemas podrían usar 0 cuando no hay CdgSIISucur |
| 260 | - if (!$detalle['CdgSIISucur']) |
|
| 261 | - $detalle['CdgSIISucur'] = false; |
|
| 265 | + if (!$detalle['CdgSIISucur']) { |
|
| 266 | + $detalle['CdgSIISucur'] = false; |
|
| 267 | + } |
|
| 262 | 268 | } |
| 263 | 269 | |
| 264 | 270 | /** |
@@ -513,8 +519,9 @@ discard block |
||
| 513 | 519 | 'TipoEnvio' => 'TOTAL', |
| 514 | 520 | 'FolioNotificacion' => false, |
| 515 | 521 | ], $caratula); |
| 516 | - if ($this->caratula['TipoEnvio']=='ESPECIAL') |
|
| 517 | - $this->caratula['FolioNotificacion'] = null; |
|
| 522 | + if ($this->caratula['TipoEnvio']=='ESPECIAL') { |
|
| 523 | + $this->caratula['FolioNotificacion'] = null; |
|
| 524 | + } |
|
| 518 | 525 | $this->id = 'LibreDTE_LIBRO_'.$this->caratula['TipoOperacion'].'_'.str_replace('-', '', $this->caratula['RutEmisorLibro']).'_'.str_replace('-', '', $this->caratula['PeriodoTributario']).'_'.date('U'); |
| 519 | 526 | } |
| 520 | 527 | |
@@ -528,8 +535,9 @@ discard block |
||
| 528 | 535 | public function generar($incluirDetalle = true) |
| 529 | 536 | { |
| 530 | 537 | // si ya se había generado se entrega directamente |
| 531 | - if ($this->xml_data) |
|
| 532 | - return $this->xml_data; |
|
| 538 | + if ($this->xml_data) { |
|
| 539 | + return $this->xml_data; |
|
| 540 | + } |
|
| 533 | 541 | // generar totales de DTE y sus montos |
| 534 | 542 | $TotalesPeriodo = $this->getResumen(); |
| 535 | 543 | $ResumenPeriodo = $TotalesPeriodo ? ['TotalesPeriodo'=>$TotalesPeriodo] : false; |
@@ -604,13 +612,16 @@ discard block |
||
| 604 | 612 | } |
| 605 | 613 | $totales[$d['TpoDoc']]['TotMntTotal'] += $d['MntTotal']; |
| 606 | 614 | // contabilizar documentos anulados |
| 607 | - if (!empty($d['Anulado']) and $d['Anulado']=='A') |
|
| 608 | - $totales[$d['TpoDoc']]['TotAnulado']++; |
|
| 615 | + if (!empty($d['Anulado']) and $d['Anulado']=='A') { |
|
| 616 | + $totales[$d['TpoDoc']]['TotAnulado']++; |
|
| 617 | + } |
|
| 609 | 618 | // si hay activo fijo se contabiliza |
| 610 | - if (!empty($d['MntActivoFijo'])) |
|
| 611 | - $totales[$d['TpoDoc']]['TotMntActivoFijo'] += $d['MntActivoFijo']; |
|
| 612 | - if (!empty($d['MntIVAActivoFijo'])) |
|
| 613 | - $totales[$d['TpoDoc']]['TotMntIVAActivoFijo'] += $d['MntIVAActivoFijo']; |
|
| 619 | + if (!empty($d['MntActivoFijo'])) { |
|
| 620 | + $totales[$d['TpoDoc']]['TotMntActivoFijo'] += $d['MntActivoFijo']; |
|
| 621 | + } |
|
| 622 | + if (!empty($d['MntIVAActivoFijo'])) { |
|
| 623 | + $totales[$d['TpoDoc']]['TotMntIVAActivoFijo'] += $d['MntIVAActivoFijo']; |
|
| 624 | + } |
|
| 614 | 625 | // si hay iva no recuperable se contabiliza |
| 615 | 626 | if (!empty($d['IVANoRec'])) { |
| 616 | 627 | foreach ($d['IVANoRec'] as $IVANoRec) { |
@@ -633,8 +644,9 @@ discard block |
||
| 633 | 644 | unset($d['FctProp']); // se quita el factor de proporcionalidad del detalle ya que no es parte del XML |
| 634 | 645 | } |
| 635 | 646 | // contabilizar IVA fuera de plazo |
| 636 | - if (!empty($d['IVAFueraPlazo'])) |
|
| 637 | - $totales[$d['TpoDoc']]['TotIVAFueraPlazo'] += $d['IVAFueraPlazo']; |
|
| 647 | + if (!empty($d['IVAFueraPlazo'])) { |
|
| 648 | + $totales[$d['TpoDoc']]['TotIVAFueraPlazo'] += $d['IVAFueraPlazo']; |
|
| 649 | + } |
|
| 638 | 650 | // si hay otro tipo de impuesto se contabiliza |
| 639 | 651 | if (!empty($d['OtrosImp'])) { |
| 640 | 652 | foreach ($d['OtrosImp'] as $OtrosImp) { |
@@ -648,17 +660,21 @@ discard block |
||
| 648 | 660 | } |
| 649 | 661 | } |
| 650 | 662 | // contabilizar impuesto sin derecho a crédito |
| 651 | - if (!empty($d['MntSinCred'])) |
|
| 652 | - $totales[$d['TpoDoc']]['TotImpSinCredito'] += $d['MntSinCred']; |
|
| 663 | + if (!empty($d['MntSinCred'])) { |
|
| 664 | + $totales[$d['TpoDoc']]['TotImpSinCredito'] += $d['MntSinCred']; |
|
| 665 | + } |
|
| 653 | 666 | // contabilidad IVA retenido total |
| 654 | - if (!empty($d['IVARetTotal'])) |
|
| 655 | - $totales[$d['TpoDoc']]['TotIVARetTotal'] += $d['IVARetTotal']; |
|
| 667 | + if (!empty($d['IVARetTotal'])) { |
|
| 668 | + $totales[$d['TpoDoc']]['TotIVARetTotal'] += $d['IVARetTotal']; |
|
| 669 | + } |
|
| 656 | 670 | // contabilizar IVA retenido parcial |
| 657 | - if (!empty($d['IVARetParcial'])) |
|
| 658 | - $totales[$d['TpoDoc']]['TotIVARetParcial'] += $d['IVARetParcial']; |
|
| 671 | + if (!empty($d['IVARetParcial'])) { |
|
| 672 | + $totales[$d['TpoDoc']]['TotIVARetParcial'] += $d['IVARetParcial']; |
|
| 673 | + } |
|
| 659 | 674 | // contabilizar IVA no retenido |
| 660 | - if (!empty($d['IVANoRetenido'])) |
|
| 661 | - $totales[$d['TpoDoc']]['TotIVANoRetenido'] += $d['IVANoRetenido']; |
|
| 675 | + if (!empty($d['IVANoRetenido'])) { |
|
| 676 | + $totales[$d['TpoDoc']]['TotIVANoRetenido'] += $d['IVANoRetenido']; |
|
| 677 | + } |
|
| 662 | 678 | } |
| 663 | 679 | // agregar resumenes pasados que no se hayan generado por los detalles |
| 664 | 680 | foreach ($this->resumen as $tipo => $resumen) { |
@@ -682,8 +698,9 @@ discard block |
||
| 682 | 698 | $manual = []; |
| 683 | 699 | if (isset($this->toArray()['LibroCompraVenta']['EnvioLibro']['ResumenPeriodo']['TotalesPeriodo'])) { |
| 684 | 700 | $totales = $this->toArray()['LibroCompraVenta']['EnvioLibro']['ResumenPeriodo']['TotalesPeriodo']; |
| 685 | - if (!isset($totales[0])) |
|
| 686 | - $totales = [$totales]; |
|
| 701 | + if (!isset($totales[0])) { |
|
| 702 | + $totales = [$totales]; |
|
| 703 | + } |
|
| 687 | 704 | foreach ($totales as $total) { |
| 688 | 705 | if (isset($total['TpoDoc']) and in_array($total['TpoDoc'], [35, 38, 48])) { |
| 689 | 706 | $manual[$total['TpoDoc']] = array_merge($this->total_default, $total); |
@@ -703,8 +720,9 @@ discard block |
||
| 703 | 720 | $manual = []; |
| 704 | 721 | if (isset($this->toArray()['LibroCompraVenta']['EnvioLibro']['ResumenPeriodo']['TotalesPeriodo'])) { |
| 705 | 722 | $totales = $this->toArray()['LibroCompraVenta']['EnvioLibro']['ResumenPeriodo']['TotalesPeriodo']; |
| 706 | - if (!isset($totales[0])) |
|
| 707 | - $totales = [$totales]; |
|
| 723 | + if (!isset($totales[0])) { |
|
| 724 | + $totales = [$totales]; |
|
| 725 | + } |
|
| 708 | 726 | foreach ($totales as $total) { |
| 709 | 727 | if (in_array($total['TpoDoc'], [39, 41])) { |
| 710 | 728 | $manual[$total['TpoDoc']] = array_merge($this->total_default, $total); |