Completed
Push — master ( e03710...03c145 )
by Esteban De La Fuente
02:29
created
lib/Sii/RegistroCompraVenta.php 2 patches
Doc Comments   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
     /**
57 57
      * Constructor, obtiene el token de la sesión y lo guarda
58
-     * @param Firma Objeto con la firma electrónica
58
+     * @param Firma \sasco\LibreDTE\FirmaElectronica con la firma electrónica
59 59
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
60 60
      * @version 2017-08-28
61 61
      */
@@ -97,6 +97,8 @@  discard block
 block discarded – undo
97 97
      * Método que entrega los eventos asociados a un DTE
98 98
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
99 99
      * @version 2017-08-28
100
+     * @param string $dte
101
+     * @param string $folio
100 102
      */
101 103
     public function listarEventosHistDoc($rut, $dv, $dte, $folio)
102 104
     {
@@ -184,10 +186,10 @@  discard block
 block discarded – undo
184 186
 
185 187
     /**
186 188
      * Método para realizar una solicitud al servicio web del SII
187
-     * @param request Nombre de la función que se ejecutará en el servicio web
189
+     * @param request string de la función que se ejecutará en el servicio web
188 190
      * @param args Argumentos que se pasarán al servicio web
189
-     * @param retry Intentos que se realizarán como máximo para obtener respuesta
190
-     * @return Objeto o String con la respuesta (depende servicio web)
191
+     * @param retry integer que se realizarán como máximo para obtener respuesta
192
+     * @return string o String con la respuesta (depende servicio web)
191 193
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
192 194
      * @version 2017-08-28
193 195
      */
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -220,7 +220,7 @@
 block discarded – undo
220 220
             \sasco\LibreDTE\Log::write(\sasco\LibreDTE\Estado::REQUEST_ERROR_SOAP, \sasco\LibreDTE\Estado::get(\sasco\LibreDTE\Estado::REQUEST_ERROR_SOAP, $msg));
221 221
             return false;
222 222
         }
223
-        for ($i=0; $i<$retry; $i++) {
223
+        for ($i = 0; $i<$retry; $i++) {
224 224
             try {
225 225
                 $body = call_user_func_array([$soap, $request], $args);
226 226
                 break;
Please login to merge, or discard this patch.
lib/Sii/PDF/Dte.php 3 patches
Braces   +80 added lines, -54 removed lines patch added patch discarded remove patch
@@ -555,10 +555,12 @@  discard block
 block discarded – undo
555 555
         }
556 556
         $contacto = [];
557 557
         if (!empty($emisor['Telefono'])) {
558
-            if (!is_array($emisor['Telefono']))
559
-                $emisor['Telefono'] = [$emisor['Telefono']];
560
-            foreach ($emisor['Telefono'] as $t)
561
-                $contacto[] = $t;
558
+            if (!is_array($emisor['Telefono'])) {
559
+                            $emisor['Telefono'] = [$emisor['Telefono']];
560
+            }
561
+            foreach ($emisor['Telefono'] as $t) {
562
+                            $contacto[] = $t;
563
+            }
562 564
         }
563 565
         if (!empty($emisor['CorreoEmisor'])) {
564 566
             $contacto[] = $emisor['CorreoEmisor'];
@@ -625,8 +627,9 @@  discard block
 block discarded – undo
625 627
      */
626 628
     private function getTipo($tipo)
627 629
     {
628
-        if (!is_numeric($tipo) and !isset($this->tipos[$tipo]))
629
-            return $tipo;
630
+        if (!is_numeric($tipo) and !isset($this->tipos[$tipo])) {
631
+                    return $tipo;
632
+        }
630 633
         return isset($this->tipos[$tipo]) ? strtoupper($this->tipos[$tipo]) : 'Documento '.$tipo;
631 634
     }
632 635
 
@@ -776,10 +779,12 @@  discard block
 block discarded – undo
776 779
             $this->MultiTexto($receptor['Extranjero']['NumId'], $x+$offset+2);
777 780
         }
778 781
         $contacto = [];
779
-        if (!empty($receptor['Contacto']))
780
-            $contacto[] = $receptor['Contacto'];
781
-        if (!empty($receptor['CorreoRecep']))
782
-            $contacto[] = $receptor['CorreoRecep'];
782
+        if (!empty($receptor['Contacto'])) {
783
+                    $contacto[] = $receptor['Contacto'];
784
+        }
785
+        if (!empty($receptor['CorreoRecep'])) {
786
+                    $contacto[] = $receptor['CorreoRecep'];
787
+        }
783 788
         if (!empty($contacto)) {
784 789
             $this->setFont('', 'B', null);
785 790
             $this->Texto('Contacto', $x);
@@ -829,15 +834,19 @@  discard block
 block discarded – undo
829 834
             if (!empty($Transporte['DirDest']) and !empty($Transporte['CmnaDest'])) {
830 835
                 $transporte .= 'a '.$Transporte['DirDest'].', '.$Transporte['CmnaDest'];
831 836
             }
832
-            if (!empty($Transporte['RUTTrans']))
833
-                $transporte .= ' por '.$Transporte['RUTTrans'];
834
-            if (!empty($Transporte['Patente']))
835
-                $transporte .= ' en vehículo '.$Transporte['Patente'];
837
+            if (!empty($Transporte['RUTTrans'])) {
838
+                            $transporte .= ' por '.$Transporte['RUTTrans'];
839
+            }
840
+            if (!empty($Transporte['Patente'])) {
841
+                            $transporte .= ' en vehículo '.$Transporte['Patente'];
842
+            }
836 843
             if (isset($Transporte['Chofer']) and is_array($Transporte['Chofer'])) {
837
-                if (!empty($Transporte['Chofer']['NombreChofer']))
838
-                    $transporte .= ' con chofer '.$Transporte['Chofer']['NombreChofer'];
839
-                if (!empty($Transporte['Chofer']['RUTChofer']))
840
-                    $transporte .= ' ('.$Transporte['Chofer']['RUTChofer'].')';
844
+                if (!empty($Transporte['Chofer']['NombreChofer'])) {
845
+                                    $transporte .= ' con chofer '.$Transporte['Chofer']['NombreChofer'];
846
+                }
847
+                if (!empty($Transporte['Chofer']['RUTChofer'])) {
848
+                                    $transporte .= ' ('.$Transporte['Chofer']['RUTChofer'].')';
849
+                }
841 850
             }
842 851
             if ($transporte) {
843 852
                 $this->setFont('', 'B', null);
@@ -851,8 +860,9 @@  discard block
 block discarded – undo
851 860
         if (!empty($Transporte['Aduana']) and is_array($Transporte['Aduana'])) {
852 861
             $col = 0;
853 862
             foreach ($Transporte['Aduana'] as $tag => $codigo) {
854
-                if ($codigo===false)
855
-                    continue;
863
+                if ($codigo===false) {
864
+                                    continue;
865
+                }
856 866
                 $glosa = \sasco\LibreDTE\Sii\Aduana::getGlosa($tag);
857 867
                 $valor = \sasco\LibreDTE\Sii\Aduana::getValor($tag, $codigo);
858 868
                 if ($glosa!==false and $valor!==false) {
@@ -865,15 +875,18 @@  discard block
 block discarded – undo
865 875
                     $this->Texto(':', $x+$offset+$col);
866 876
                     $this->setFont('', '', null);
867 877
                     $this->Texto($valor, $x+$offset+2+$col);
868
-                    if ($tag=='TipoBultos')
869
-                        $col = abs($col-110);
870
-                    if ($col)
871
-                        $this->Ln();
878
+                    if ($tag=='TipoBultos') {
879
+                                            $col = abs($col-110);
880
+                    }
881
+                    if ($col) {
882
+                                            $this->Ln();
883
+                    }
872 884
                     $col = abs($col-110);
873 885
                 }
874 886
             }
875
-            if ($col)
876
-                $this->Ln();
887
+            if ($col) {
888
+                            $this->Ln();
889
+            }
877 890
         }
878 891
     }
879 892
 
@@ -886,8 +899,9 @@  discard block
 block discarded – undo
886 899
      */
887 900
     private function agregarReferencia($referencias, $x = 10, $offset = 22)
888 901
     {
889
-        if (!isset($referencias[0]))
890
-            $referencias = [$referencias];
902
+        if (!isset($referencias[0])) {
903
+                    $referencias = [$referencias];
904
+        }
891 905
         foreach($referencias as $r) {
892 906
             $texto = $r['NroLinRef'].' - ';
893 907
             if (!empty($r['TpoDocRef'])) {
@@ -924,8 +938,9 @@  discard block
 block discarded – undo
924 938
      */
925 939
     private function agregarDetalle($detalle, $x = 10)
926 940
     {
927
-        if (!isset($detalle[0]))
928
-            $detalle = [$detalle];
941
+        if (!isset($detalle[0])) {
942
+                    $detalle = [$detalle];
943
+        }
929 944
         $this->setFont('', '', $this->detalle_fuente);
930 945
         // titulos
931 946
         $titulos = [];
@@ -942,36 +957,42 @@  discard block
 block discarded – undo
942 957
                     $item['NmbItem'] .= !$this->item_detalle_posicion ? '<br/>' : ': ';
943 958
                     $item['NmbItem'] .= '<span style="font-size:0.7em">'.$item['DscItem'].'</span>';
944 959
                 }
945
-                if (!in_array($col, $titulos_keys) or ($dte_exento and $col=='IndExe'))
946
-                    unset($item[$col]);
960
+                if (!in_array($col, $titulos_keys) or ($dte_exento and $col=='IndExe')) {
961
+                                    unset($item[$col]);
962
+                }
947 963
             }
948 964
             // ajustes a IndExe
949 965
             if (isset($item['IndExe'])) {
950
-                if ($item['IndExe']==1)
951
-                    $item['IndExe'] = 'EX';
952
-                else if ($item['IndExe']==2)
953
-                    $item['IndExe'] = 'NF';
966
+                if ($item['IndExe']==1) {
967
+                                    $item['IndExe'] = 'EX';
968
+                } else if ($item['IndExe']==2) {
969
+                                    $item['IndExe'] = 'NF';
970
+                }
954 971
             }
955 972
             // agregar todas las columnas que se podrían imprimir en la tabla
956 973
             $item_default = [];
957
-            foreach ($this->detalle_cols as $key => $info)
958
-                $item_default[$key] = false;
974
+            foreach ($this->detalle_cols as $key => $info) {
975
+                            $item_default[$key] = false;
976
+            }
959 977
             $item = array_merge($item_default, $item);
960 978
             // si hay código de item se extrae su valor
961
-            if ($item['CdgItem'])
962
-                $item['CdgItem'] = $item['CdgItem']['VlrCodigo'];
979
+            if ($item['CdgItem']) {
980
+                            $item['CdgItem'] = $item['CdgItem']['VlrCodigo'];
981
+            }
963 982
             // dar formato a números
964 983
             foreach (['QtyItem', 'PrcItem', 'DescuentoMonto', 'RecargoMonto', 'MontoItem'] as $col) {
965
-                if ($item[$col])
966
-                    $item[$col] = $this->num($item[$col]);
984
+                if ($item[$col]) {
985
+                                    $item[$col] = $this->num($item[$col]);
986
+                }
967 987
             }
968 988
         }
969 989
         // opciones
970 990
         $options = ['align'=>[]];
971 991
         $i = 0;
972 992
         foreach ($this->detalle_cols as $info) {
973
-            if (isset($info['width']))
974
-                $options['width'][$i] = $info['width'];
993
+            if (isset($info['width'])) {
994
+                            $options['width'][$i] = $info['width'];
995
+            }
975 996
             $options['align'][$i] = $info['align'];
976 997
             $i++;
977 998
         }
@@ -1004,8 +1025,9 @@  discard block
 block discarded – undo
1004 1025
         $this->Texto($this->detalle_cols['QtyItem']['title'], $x+35, $this->y, ucfirst($this->detalle_cols['QtyItem']['align'][0]), $this->detalle_cols['QtyItem']['width']);
1005 1026
         $this->Texto($this->detalle_cols['MontoItem']['title'], $x+45, $this->y, ucfirst($this->detalle_cols['MontoItem']['align'][0]), $this->detalle_cols['MontoItem']['width']);
1006 1027
         $this->Line($p1x, $p1y+4, $p2x, $p2y+4, $style);
1007
-        if (!isset($detalle[0]))
1008
-            $detalle = [$detalle];
1028
+        if (!isset($detalle[0])) {
1029
+                    $detalle = [$detalle];
1030
+        }
1009 1031
         $this->SetY($this->getY()+2);
1010 1032
         foreach($detalle as  &$d) {
1011 1033
             $this->MultiTexto($d['NmbItem'], $x+1, $this->y+4, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']);
@@ -1052,8 +1074,9 @@  discard block
 block discarded – undo
1052 1074
      */
1053 1075
     private function agregarDescuentosRecargos(array $descuentosRecargos, $x = 10)
1054 1076
     {
1055
-        if (!isset($descuentosRecargos[0]))
1056
-            $descuentosRecargos = [$descuentosRecargos];
1077
+        if (!isset($descuentosRecargos[0])) {
1078
+                    $descuentosRecargos = [$descuentosRecargos];
1079
+        }
1057 1080
         foreach($descuentosRecargos as $dr) {
1058 1081
             $tipo = $dr['TpoMov']=='D' ? 'Descuento' : 'Recargo';
1059 1082
             $valor = $dr['TpoValor']=='%' ? $dr['ValorDR'].'%' : $this->num($dr['ValorDR']);
@@ -1076,8 +1099,9 @@  discard block
 block discarded – undo
1076 1099
      */
1077 1100
     private function agregarPagos(array $pagos, $x = 10)
1078 1101
     {
1079
-        if (!isset($pagos[0]))
1080
-            $pagos = [$pagos];
1102
+        if (!isset($pagos[0])) {
1103
+                    $pagos = [$pagos];
1104
+        }
1081 1105
         $this->Texto('Pago(s) programado(s):', $x);
1082 1106
         $this->Ln();
1083 1107
         foreach($pagos as $p) {
@@ -1343,11 +1367,13 @@  discard block
 block discarded – undo
1343 1367
      */
1344 1368
     private function num($n)
1345 1369
     {
1346
-        if (!is_numeric($n))
1347
-            return $n;
1370
+        if (!is_numeric($n)) {
1371
+                    return $n;
1372
+        }
1348 1373
         $broken_number = explode('.', (string)$n);
1349
-        if (isset($broken_number[1]))
1350
-            return number_format($broken_number[0], 0, ',', '.').','.$broken_number[1];
1374
+        if (isset($broken_number[1])) {
1375
+                    return number_format($broken_number[0], 0, ',', '.').','.$broken_number[1];
1376
+        }
1351 1377
         return number_format($broken_number[0], 0, ',', '.');
1352 1378
     }
1353 1379
 
Please login to merge, or discard this patch.
Doc Comments   +31 added lines, -28 removed lines patch added patch discarded remove patch
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
      */
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
lib/Sii/Dte.php 3 patches
Braces   +102 added lines, -68 removed lines patch added patch discarded remove patch
@@ -57,10 +57,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
@@ -355,8 +369,9 @@  discard block
 block discarded – undo
355 369
             return false;*/
356 370
         $xml = new \sasco\LibreDTE\XML();
357 371
         $TED = $this->xml->getElementsByTagName('TED')->item(0);
358
-        if (!$TED)
359
-            return '<TED/>';
372
+        if (!$TED) {
373
+                    return '<TED/>';
374
+        }
360 375
         $xml->loadXML($TED->C14N());
361 376
         $xml->documentElement->removeAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi');
362 377
         $xml->documentElement->removeAttributeNS('http://www.sii.cl/SiiDte', '');
@@ -553,10 +568,12 @@  discard block
 block discarded – undo
553 568
      */
554 569
     private function calcularNetoIVA($total, $tasa = null)
555 570
     {
556
-        if ($tasa === 0 or $tasa === false)
557
-            return [0, 0];
558
-        if ($tasa === null)
559
-            $tasa = \sasco\LibreDTE\Sii::getIVA();
571
+        if ($tasa === 0 or $tasa === false) {
572
+                    return [0, 0];
573
+        }
574
+        if ($tasa === null) {
575
+                    $tasa = \sasco\LibreDTE\Sii::getIVA();
576
+        }
560 577
         // WARNING: el IVA obtenido puede no ser el NETO*(TASA/100)
561 578
         // se calcula el monto neto y luego se obtiene el IVA haciendo la resta
562 579
         // entre el total y el neto, ya que hay casos de borde como:
@@ -665,8 +682,9 @@  discard block
 block discarded – undo
665 682
         }
666 683
         // si existe descuento o recargo global se normalizan
667 684
         if (!empty($datos['DscRcgGlobal'])) {
668
-            if (!isset($datos['DscRcgGlobal'][0]))
669
-                $datos['DscRcgGlobal'] = [$datos['DscRcgGlobal']];
685
+            if (!isset($datos['DscRcgGlobal'][0])) {
686
+                            $datos['DscRcgGlobal'] = [$datos['DscRcgGlobal']];
687
+            }
670 688
             $NroLinDR = 1;
671 689
             foreach ($datos['DscRcgGlobal'] as &$dr) {
672 690
                 $dr = array_merge([
@@ -1310,8 +1328,9 @@  discard block
 block discarded – undo
1310 1328
      */
1311 1329
     private function normalizar_detalle(array &$datos)
1312 1330
     {
1313
-        if (!isset($datos['Detalle'][0]))
1314
-            $datos['Detalle'] = [$datos['Detalle']];
1331
+        if (!isset($datos['Detalle'][0])) {
1332
+                    $datos['Detalle'] = [$datos['Detalle']];
1333
+        }
1315 1334
         $item = 1;
1316 1335
         foreach ($datos['Detalle'] as &$d) {
1317 1336
             $d = array_merge([
@@ -1373,8 +1392,9 @@  discard block
 block discarded – undo
1373 1392
                 ];
1374 1393
             }
1375 1394
             if ($d['PrcItem']) {
1376
-                if (!$d['QtyItem'])
1377
-                    $d['QtyItem'] = 1;
1395
+                if (!$d['QtyItem']) {
1396
+                                    $d['QtyItem'] = 1;
1397
+                }
1378 1398
                 if (empty($d['MontoItem'])) {
1379 1399
                     $d['MontoItem'] = $this->round(
1380 1400
                         $d['QtyItem'] * $d['PrcItem'],
@@ -1440,8 +1460,9 @@  discard block
 block discarded – undo
1440 1460
     private function normalizar_aplicar_descuentos_recargos(array &$datos)
1441 1461
     {
1442 1462
         if (!empty($datos['DscRcgGlobal'])) {
1443
-            if (!isset($datos['DscRcgGlobal'][0]))
1444
-                $datos['DscRcgGlobal'] = [$datos['DscRcgGlobal']];
1463
+            if (!isset($datos['DscRcgGlobal'][0])) {
1464
+                            $datos['DscRcgGlobal'] = [$datos['DscRcgGlobal']];
1465
+            }
1445 1466
             foreach ($datos['DscRcgGlobal'] as &$dr) {
1446 1467
                 $dr = array_merge([
1447 1468
                     'NroLinDR' => false,
@@ -1508,8 +1529,9 @@  discard block
 block discarded – undo
1508 1529
         $montos = [];
1509 1530
         foreach ($datos['Detalle'] as &$d) {
1510 1531
             if (!empty($d['CodImpAdic'])) {
1511
-                if (!isset($montos[$d['CodImpAdic']]))
1512
-                    $montos[$d['CodImpAdic']] = 0;
1532
+                if (!isset($montos[$d['CodImpAdic']])) {
1533
+                                    $montos[$d['CodImpAdic']] = 0;
1534
+                }
1513 1535
                 $montos[$d['CodImpAdic']] += $d['MontoItem'];
1514 1536
             }
1515 1537
         }
@@ -1588,10 +1610,12 @@  discard block
 block discarded – undo
1588 1610
             }
1589 1611
             if (empty($datos['Encabezado']['Totales']['MntTotal'])) {
1590 1612
                 $datos['Encabezado']['Totales']['MntTotal'] = $datos['Encabezado']['Totales']['MntNeto'];
1591
-                if (!empty($datos['Encabezado']['Totales']['IVA']))
1592
-                    $datos['Encabezado']['Totales']['MntTotal'] += $datos['Encabezado']['Totales']['IVA'];
1593
-                if (!empty($datos['Encabezado']['Totales']['MntExe']))
1594
-                    $datos['Encabezado']['Totales']['MntTotal'] += $datos['Encabezado']['Totales']['MntExe'];
1613
+                if (!empty($datos['Encabezado']['Totales']['IVA'])) {
1614
+                                    $datos['Encabezado']['Totales']['MntTotal'] += $datos['Encabezado']['Totales']['IVA'];
1615
+                }
1616
+                if (!empty($datos['Encabezado']['Totales']['MntExe'])) {
1617
+                                    $datos['Encabezado']['Totales']['MntTotal'] += $datos['Encabezado']['Totales']['MntExe'];
1618
+                }
1595 1619
             }
1596 1620
         } else {
1597 1621
             if (!$datos['Encabezado']['Totales']['MntTotal'] and !empty($datos['Encabezado']['Totales']['MntExe'])) {
@@ -1617,8 +1641,10 @@  discard block
 block discarded – undo
1617 1641
         }
1618 1642
         // si hay impuesto de crédito a constructoras del 65% se descuenta del total
1619 1643
         if (!empty($datos['Encabezado']['Totales']['CredEC'])) {
1620
-            if ($datos['Encabezado']['Totales']['CredEC']===true)
1621
-                $datos['Encabezado']['Totales']['CredEC'] = round($datos['Encabezado']['Totales']['IVA'] * 0.65); // TODO: mover a constante o método
1644
+            if ($datos['Encabezado']['Totales']['CredEC']===true) {
1645
+                            $datos['Encabezado']['Totales']['CredEC'] = round($datos['Encabezado']['Totales']['IVA'] * 0.65);
1646
+            }
1647
+            // TODO: mover a constante o método
1622 1648
             $datos['Encabezado']['Totales']['MntTotal'] -= $datos['Encabezado']['Totales']['CredEC'];
1623 1649
         }
1624 1650
     }
@@ -1724,10 +1750,12 @@  discard block
 block discarded – undo
1724 1750
         /*if (!$this->checkFirma())
1725 1751
             return 1;*/
1726 1752
         if (is_array($datos)) {
1727
-            if (isset($datos['RUTEmisor']) and $this->getEmisor()!=$datos['RUTEmisor'])
1728
-                return 2;
1729
-            if (isset($datos['RUTRecep']) and $this->getReceptor()!=$datos['RUTRecep'])
1730
-                return 3;
1753
+            if (isset($datos['RUTEmisor']) and $this->getEmisor()!=$datos['RUTEmisor']) {
1754
+                            return 2;
1755
+            }
1756
+            if (isset($datos['RUTRecep']) and $this->getReceptor()!=$datos['RUTRecep']) {
1757
+                            return 3;
1758
+            }
1731 1759
         }
1732 1760
         return 0;
1733 1761
     }
@@ -1741,8 +1769,9 @@  discard block
 block discarded – undo
1741 1769
      */
1742 1770
     public function checkFirma()
1743 1771
     {
1744
-        if (!$this->xml)
1745
-            return null;
1772
+        if (!$this->xml) {
1773
+                    return null;
1774
+        }
1746 1775
         // obtener firma
1747 1776
         $Signature = $this->xml->documentElement->getElementsByTagName('Signature')->item(0);
1748 1777
         // preparar documento a validar
@@ -1834,12 +1863,14 @@  discard block
 block discarded – undo
1834 1863
     {
1835 1864
         // solicitar token
1836 1865
         $token = \sasco\LibreDTE\Sii\Autenticacion::getToken($Firma);
1837
-        if (!$token)
1838
-            return false;
1866
+        if (!$token) {
1867
+                    return false;
1868
+        }
1839 1869
         // consultar estado dte
1840 1870
         $run = $Firma->getID();
1841
-        if ($run===false)
1842
-            return false;
1871
+        if ($run===false) {
1872
+                    return false;
1873
+        }
1843 1874
         list($RutConsultante, $DvConsultante) = explode('-', $run);
1844 1875
         list($RutCompania, $DvCompania) = explode('-', $this->getEmisor());
1845 1876
         list($RutReceptor, $DvReceptor) = explode('-', $this->getReceptor());
@@ -1858,8 +1889,9 @@  discard block
 block discarded – undo
1858 1889
             'token'             => $token,
1859 1890
         ]);
1860 1891
         // si el estado se pudo recuperar se muestra
1861
-        if ($xml===false)
1862
-            return false;
1892
+        if ($xml===false) {
1893
+                    return false;
1894
+        }
1863 1895
         // entregar estado
1864 1896
         return (array)$xml->xpath('/SII:RESPUESTA/SII:RESP_HDR')[0];
1865 1897
     }
@@ -1876,8 +1908,9 @@  discard block
 block discarded – undo
1876 1908
     {
1877 1909
         // solicitar token
1878 1910
         $token = \sasco\LibreDTE\Sii\Autenticacion::getToken($Firma);
1879
-        if (!$token)
1880
-            return false;
1911
+        if (!$token) {
1912
+                    return false;
1913
+        }
1881 1914
         // consultar estado dte
1882 1915
         list($RutEmpresa, $DvEmpresa) = explode('-', $this->getEmisor());
1883 1916
         list($RutReceptor, $DvReceptor) = explode('-', $this->getReceptor());
@@ -1895,8 +1928,9 @@  discard block
 block discarded – undo
1895 1928
             'token'             => $token,
1896 1929
         ]);
1897 1930
         // si el estado se pudo recuperar se muestra
1898
-        if ($xml===false)
1899
-            return false;
1931
+        if ($xml===false) {
1932
+                    return false;
1933
+        }
1900 1934
         // entregar estado
1901 1935
         return (array)$xml->xpath('/SII:RESPUESTA/SII:RESP_BODY')[0];
1902 1936
     }
Please login to merge, or discard this patch.
Doc Comments   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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)
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
lib/Sii.php 3 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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]);
Please login to merge, or discard this patch.
Braces   +26 added lines, -18 removed lines patch added patch discarded remove patch
@@ -466,8 +466,9 @@  discard block
 block discarded – undo
466 466
         // entregar WSDL local (modificados para ambiente de certificación)
467 467
         if ($ambiente==self::CERTIFICACION) {
468 468
             $wsdl = dirname(dirname(__FILE__)).'/wsdl/'.self::$config['servidor'][$ambiente].'/'.$servicio.'.jws';
469
-            if (is_readable($wsdl))
470
-                return $wsdl;
469
+            if (is_readable($wsdl)) {
470
+                            return $wsdl;
471
+            }
471 472
         }
472 473
         // entregar WSDL oficial desde SII
473 474
         $location = isset(self::$config['wsdl'][$servicio]) ? self::$config['wsdl'][$servicio] : self::$config['wsdl']['*'];
@@ -496,10 +497,12 @@  discard block
 block discarded – undo
496 497
             $retry = (int)$args;
497 498
             $args = null;
498 499
         }
499
-        if (!$retry)
500
-            $retry = self::$retry;
501
-        if ($args and !is_array($args))
502
-            $args = [$args];
500
+        if (!$retry) {
501
+                    $retry = self::$retry;
502
+        }
503
+        if ($args and !is_array($args)) {
504
+                    $args = [$args];
505
+        }
503 506
         if (!self::$verificar_ssl) {
504 507
             if (self::getAmbiente()==self::PRODUCCION) {
505 508
                 $msg = Estado::get(Estado::ENVIO_SSL_SIN_VERIFICAR);
@@ -736,10 +739,11 @@  discard block
 block discarded – undo
736 739
     public static function getAmbiente($ambiente = null)
737 740
     {
738 741
         if ($ambiente===null) {
739
-            if (defined('_LibreDTE_CERTIFICACION_'))
740
-                $ambiente = (int)_LibreDTE_CERTIFICACION_;
741
-            else
742
-                $ambiente = self::$ambiente;
742
+            if (defined('_LibreDTE_CERTIFICACION_')) {
743
+                            $ambiente = (int)_LibreDTE_CERTIFICACION_;
744
+            } else {
745
+                            $ambiente = self::$ambiente;
746
+            }
743 747
         }
744 748
         return $ambiente;
745 749
     }
@@ -765,8 +769,9 @@  discard block
 block discarded – undo
765 769
     {
766 770
         // solicitar token
767 771
         $token = \sasco\LibreDTE\Sii\Autenticacion::getToken($Firma);
768
-        if (!$token)
769
-            return false;
772
+        if (!$token) {
773
+                    return false;
774
+        }
770 775
         // definir ambiente y servidor
771 776
         $ambiente = self::getAmbiente($ambiente);
772 777
         $servidor = self::$config['servidor'][$ambiente];
@@ -795,8 +800,9 @@  discard block
 block discarded – undo
795 800
         }
796 801
         // realizar consulta curl
797 802
         $response = curl_exec($curl);
798
-        if (!$response)
799
-            return false;
803
+        if (!$response) {
804
+                    return false;
805
+        }
800 806
         // cerrar sesión curl
801 807
         curl_close($curl);
802 808
         // entregar datos del archivo CSV
@@ -807,10 +813,12 @@  discard block
 block discarded – undo
807 813
         for ($i=1; $i<$n_lines; $i++) {
808 814
             $row = str_getcsv($lines[$i], ';', '');
809 815
             unset($lines[$i]);
810
-            if (!isset($row[5]))
811
-                continue;
812
-            for ($j=0; $j<6; $j++)
813
-                $row[$j] = trim($row[$j]);
816
+            if (!isset($row[5])) {
817
+                            continue;
818
+            }
819
+            for ($j=0; $j<6; $j++) {
820
+                            $row[$j] = trim($row[$j]);
821
+            }
814 822
             $row[1] = utf8_decode($row[1]);
815 823
             $row[4] = strtolower($row[4]);
816 824
             $row[5] = strtolower($row[5]);
Please login to merge, or discard this patch.
lib/XML.php 3 patches
Doc Comments   +6 added lines, -5 removed lines patch added patch discarded remove patch
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     {
Please login to merge, or discard this patch.
Braces   +42 added lines, -30 removed lines patch added patch discarded remove patch
@@ -120,8 +120,9 @@  discard block
 block discarded – undo
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
             ['&amp;', '&#38;', '&lt;', '&#60;', '&gt;', '&#62', '&quot;', '&#34;', '&apos;', '&#39;'],
@@ -174,8 +175,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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]=='\'' ? '&apos;' : ($xml[$i]=='"' ? '&quot;' : $xml[$i]);
372 384
             } else {
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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]=='<')
Please login to merge, or discard this patch.
lib/Sii/Folios.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -254,7 +254,7 @@
 block discarded – undo
254 254
 
255 255
     /**
256 256
      * Método que indica si el CAF es de certificación o no
257
-     * @return bool =true si los folios son del ambiente de certificación, =null si no se pudo determinar
257
+     * @return boolean|null =true si los folios son del ambiente de certificación, =null si no se pudo determinar
258 258
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
259 259
      * @version 2015-10-30
260 260
      */
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
         // validar firma del SII sobre los folios
64 64
         $firma = $this->getFirma();
65 65
         $idk = $this->getIDK();
66
-        if ($firma === false || $idk === false) {
66
+        if ($firma===false || $idk===false) {
67 67
             return false;
68 68
         }
69 69
         $pub_key = \sasco\LibreDTE\Sii::cert($idk);
70
-        if ($pub_key === false || openssl_verify($this->xml->getFlattened('/AUTORIZACION/CAF/DA'), base64_decode($firma), $pub_key)!==1) {
70
+        if ($pub_key===false || openssl_verify($this->xml->getFlattened('/AUTORIZACION/CAF/DA'), base64_decode($firma), $pub_key)!==1) {
71 71
             \sasco\LibreDTE\Log::write(
72 72
                 \sasco\LibreDTE\Estado::FOLIOS_ERROR_FIRMA,
73 73
                 \sasco\LibreDTE\Estado::get(\sasco\LibreDTE\Estado::FOLIOS_ERROR_FIRMA)
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
             );
99 99
             return false;
100 100
         }
101
-        return $plain === $plain_firmado;
101
+        return $plain===$plain_firmado;
102 102
     }
103 103
 
104 104
     /**
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
     public function getCertificacion()
262 262
     {
263 263
         $idk = $this->getIDK();
264
-        return $idk ?  $idk === 100 : null;
264
+        return $idk ? $idk===100 : null;
265 265
     }
266 266
 
267 267
     /**
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
         }
278 278
         $d1 = new \DateTime($this->getFechaAutorizacion());
279 279
         $d2 = new \DateTime(date('Y-m-d'));
280
-        $meses = $d1->diff($d2)->m + ($d1->diff($d2)->y*12);
281
-        return $meses <= 18;
280
+        $meses = $d1->diff($d2)->m+($d1->diff($d2)->y * 12);
281
+        return $meses<=18;
282 282
     }
283 283
 
284 284
     /**
Please login to merge, or discard this patch.