@@ -102,10 +102,12 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function agregar(array $detalle, $normalizar = true) |
104 | 104 | { |
105 | - if ($normalizar) |
|
106 | - $this->normalizarDetalle($detalle); |
|
107 | - if (!$detalle['TpoDoc']) |
|
108 | - return false; |
|
105 | + if ($normalizar) { |
|
106 | + $this->normalizarDetalle($detalle); |
|
107 | + } |
|
108 | + if (!$detalle['TpoDoc']) { |
|
109 | + return false; |
|
110 | + } |
|
109 | 111 | $this->detalles[] = $detalle; |
110 | 112 | return true; |
111 | 113 | } |
@@ -183,8 +185,9 @@ discard block |
||
183 | 185 | } |
184 | 186 | // calcular valores que no se hayan entregado |
185 | 187 | if (isset($detalle['FctProp'])) { |
186 | - if ($detalle['IVAUsoComun']===false) |
|
187 | - $detalle['IVAUsoComun'] = round($detalle['MntNeto'] * ($detalle['TasaImp']/100)); |
|
188 | + if ($detalle['IVAUsoComun']===false) { |
|
189 | + $detalle['IVAUsoComun'] = round($detalle['MntNeto'] * ($detalle['TasaImp']/100)); |
|
190 | + } |
|
188 | 191 | } else if (!$detalle['MntIVA'] and !is_array($detalle['IVANoRec']) and $detalle['TasaImp'] and $detalle['MntNeto']) { |
189 | 192 | $detalle['MntIVA'] = round($detalle['MntNeto'] * ($detalle['TasaImp']/100)); |
190 | 193 | } |
@@ -194,8 +197,9 @@ discard block |
||
194 | 197 | } |
195 | 198 | // normalizar IVA no recuperable |
196 | 199 | if (!empty($detalle['IVANoRec'])) { |
197 | - if (!isset($detalle['IVANoRec'][0])) |
|
198 | - $detalle['IVANoRec'] = [$detalle['IVANoRec']]; |
|
200 | + if (!isset($detalle['IVANoRec'][0])) { |
|
201 | + $detalle['IVANoRec'] = [$detalle['IVANoRec']]; |
|
202 | + } |
|
199 | 203 | // si son múltiples iva no recuperable se arma arreglo real |
200 | 204 | if (strpos($detalle['IVANoRec'][0]['CodIVANoRec'], ',')) { |
201 | 205 | $CodIVANoRec = explode(',', $detalle['IVANoRec'][0]['CodIVANoRec']); |
@@ -212,8 +216,9 @@ discard block |
||
212 | 216 | } |
213 | 217 | // normalizar otros impuestos |
214 | 218 | if (!empty($detalle['OtrosImp'])) { |
215 | - if (!isset($detalle['OtrosImp'][0])) |
|
216 | - $detalle['OtrosImp'] = [$detalle['OtrosImp']]; |
|
219 | + if (!isset($detalle['OtrosImp'][0])) { |
|
220 | + $detalle['OtrosImp'] = [$detalle['OtrosImp']]; |
|
221 | + } |
|
217 | 222 | // si son múltiples impuestos se arma arreglo real |
218 | 223 | if (strpos($detalle['OtrosImp'][0]['CodImp'], ',')) { |
219 | 224 | $CodImp = explode(',', $detalle['OtrosImp'][0]['CodImp']); |
@@ -531,8 +536,9 @@ discard block |
||
531 | 536 | 'TipoEnvio' => 'TOTAL', |
532 | 537 | 'FolioNotificacion' => false, |
533 | 538 | ], $caratula); |
534 | - if ($this->caratula['TipoEnvio']=='ESPECIAL') |
|
535 | - $this->caratula['FolioNotificacion'] = null; |
|
539 | + if ($this->caratula['TipoEnvio']=='ESPECIAL') { |
|
540 | + $this->caratula['FolioNotificacion'] = null; |
|
541 | + } |
|
536 | 542 | $this->id = 'LibreDTE_LIBRO_'.$this->caratula['TipoOperacion'].'_'.str_replace('-', '', $this->caratula['RutEmisorLibro']).'_'.str_replace('-', '', $this->caratula['PeriodoTributario']).'_'.date('U'); |
537 | 543 | } |
538 | 544 | |
@@ -546,8 +552,9 @@ discard block |
||
546 | 552 | public function generar($incluirDetalle = true) |
547 | 553 | { |
548 | 554 | // si ya se había generado se entrega directamente |
549 | - if ($this->xml_data) |
|
550 | - return $this->xml_data; |
|
555 | + if ($this->xml_data) { |
|
556 | + return $this->xml_data; |
|
557 | + } |
|
551 | 558 | // generar totales de DTE y sus montos |
552 | 559 | $TotalesPeriodo = $this->getResumen(); |
553 | 560 | $ResumenPeriodo = $TotalesPeriodo ? ['TotalesPeriodo'=>$TotalesPeriodo] : false; |
@@ -712,8 +719,9 @@ discard block |
||
712 | 719 | $manual = []; |
713 | 720 | if (isset($this->toArray()['LibroCompraVenta']['EnvioLibro']['ResumenPeriodo']['TotalesPeriodo'])) { |
714 | 721 | $totales = $this->toArray()['LibroCompraVenta']['EnvioLibro']['ResumenPeriodo']['TotalesPeriodo']; |
715 | - if (!isset($totales[0])) |
|
716 | - $totales = [$totales]; |
|
722 | + if (!isset($totales[0])) { |
|
723 | + $totales = [$totales]; |
|
724 | + } |
|
717 | 725 | foreach ($totales as $total) { |
718 | 726 | if (isset($total['TpoDoc']) and in_array($total['TpoDoc'], [35, 38, 48])) { |
719 | 727 | $manual[$total['TpoDoc']] = array_merge($this->total_default, $total); |
@@ -733,8 +741,9 @@ discard block |
||
733 | 741 | $manual = []; |
734 | 742 | if (isset($this->toArray()['LibroCompraVenta']['EnvioLibro']['ResumenPeriodo']['TotalesPeriodo'])) { |
735 | 743 | $totales = $this->toArray()['LibroCompraVenta']['EnvioLibro']['ResumenPeriodo']['TotalesPeriodo']; |
736 | - if (!isset($totales[0])) |
|
737 | - $totales = [$totales]; |
|
744 | + if (!isset($totales[0])) { |
|
745 | + $totales = [$totales]; |
|
746 | + } |
|
738 | 747 | foreach ($totales as $total) { |
739 | 748 | if (in_array($total['TpoDoc'], [39, 41])) { |
740 | 749 | $manual[$total['TpoDoc']] = array_merge($this->total_default, $total); |