From 2f369c4e5e610e3b5b4402d92cc317fa8c099d65 Mon Sep 17 00:00:00 2001 From: Aldarien Date: Tue, 8 Mar 2022 10:58:38 -0300 Subject: [PATCH] =?UTF-8?q?Se=20agregar=20Resciliacion=20y=20el=20n=C2=B0?= =?UTF-8?q?=20de=20departamento=20al=20inicio=20de=20la=20linea=20FIX:=20a?= =?UTF-8?q?cumulado=20no=20pagado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/Informe/Contabilidad/Resumen.php | 27 +++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/app/Service/Informe/Contabilidad/Resumen.php b/app/Service/Informe/Contabilidad/Resumen.php index e13a7f8..8911cc0 100644 --- a/app/Service/Informe/Contabilidad/Resumen.php +++ b/app/Service/Informe/Contabilidad/Resumen.php @@ -68,7 +68,7 @@ class Resumen $cuotas = $venta->pie()->cuotas('fecha', $up_to); $ly = $this->startOfYear($up_to); $older = array_reduce($cuotas, function($sum, $item) use ($ly) { - if ($item->pago()->estado()->tipo()->active != 1 || strtolower($item->pago()->estado()->tipo()->descripcion) != 'no pagado') { + if ($item->pago()->estado()->tipo()->active != 1 or strtolower($item->pago()->estado()->tipo()->descripcion) == 'no pagado') { return $sum; } if ($item->pago()->fecha() >= $ly) { @@ -119,6 +119,13 @@ class Resumen } return [$this->extractValueDate($venta->subsidio()->pago(), 'Ahorro'), $this->extractValueDate($venta->subsidio()->subsidio(), 'Subsidio')]; } + protected function getResciliacion(Venta $venta, DateTimeInterface $up_to) + { + if ($venta->resciliacion == null) { + return $this->defaultValueDate($up_to, 'Resciliacion'); + } + return $this->extractValueDate($venta->resciliacion()->pago(), 'Resciliacion'); + } protected function getPagos(Venta $venta, DateTimeInterface $up_to) { $pagos = []; @@ -133,6 +140,13 @@ class Resumen }); } + protected function buildLine(Venta $venta, $pago) + { + if ($pago->valor > 0) { + return ['', $venta->unidad->descripcion(), $pago->fecha->format('d/m/Y'), $pago->glosa, '', $pago->valor, $pago->estado]; + } + return ['', $venta->unidad->descripcion(), $pago->fecha->format('d/m/Y'), $pago->glosa, -$pago->valor, '', $pago->estado]; + } protected function buildLibro(Venta $venta, DateTimeInterface $up_to) { $pagos = $this->getPagos($venta, $up_to); @@ -143,16 +157,15 @@ class Resumen $debe = 0; $haber = 0; foreach ($pagos as $pago) { + $output []= $this->buildLine($venta, $pago); if ($pago->valor > 0) { - $output []= ['', $pago->fecha->format('d/m/Y'), $pago->glosa, '', $pago->valor, $pago->estado]; $debe += $pago->valor; } else { - $output []= ['', $pago->fecha->format('d/m/Y'), $pago->glosa, -$pago->valor, '', $pago->estado]; $haber -= $pago->valor; } } - $output []= ['', '', 'Total', $haber, $debe]; + $output []= ['', '', '', 'Total', $haber, $debe]; return $output; } @@ -163,15 +176,15 @@ class Resumen $output = ["Libro Mayor {$ventas[0]->proyecto()->descripcion}", '']; foreach ($ventas as $venta) { - $output = array_merge($output, $this->buildLibro($venta, $up_to), [''], ['']); + $output = array_merge($output, $this->buildLibro($venta, $up_to)); } $filename = "Contabilidad - Resumen - {$ventas[0]->proyecto()->descripcion} - {$up_to->format('Y-m-d')}.xlsx"; $informe = new Informe(); $informe->createSpreadsheet() ->addArray($output) - ->formatColumn('C') - ->formatColumn('D') + ->formatColumn('E') + ->formatColumn('F') ->send($filename); } }