From b8babf2906ff1dbbb738a470c251b4757b8bd6c8 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Mon, 7 Mar 2022 23:49:26 -0300 Subject: [PATCH] Clean up --- app/Controller/Informes.php | 103 +------------------ app/Service/Informe/Contabilidad/Resumen.php | 7 -- 2 files changed, 1 insertion(+), 109 deletions(-) diff --git a/app/Controller/Informes.php b/app/Controller/Informes.php index 43862a2..cdace2c 100644 --- a/app/Controller/Informes.php +++ b/app/Controller/Informes.php @@ -561,108 +561,7 @@ class Informes $service = new Resumen(); $service->build($id, new \DateTimeImmutable($fecha)); - - return; - - $proyecto = model(Proyecto::class)->findOne($id); - $mes = null; - if ($fecha != null) { - $mes = Carbon::parse($fecha)->addMonths(1)->subDays(1); - } - - $ventas = $proyecto->ventas(); - - usort($ventas, function($a, $b) { - return $a->fecha()->timestamp - $b->fecha()->timestamp; - }); - - $name = 'Contabilidad'; - $hoy = Carbon::now(config('app.timezone')); - $filename = str_replace('ñ', 'n', $name . ' - ' . $proyecto->descripcion . ' - ' . $hoy->format('Y-m-d') . '.xls'); - $informe = new PHPExcel($name, $filename); - - $columnas = [ - 'Propietario', - ['name' => 'Departamento', 'style' => 'general_number'], - ['name' => 'Estacionamientos', 'style' => 'number'], - ['name' => 'Bodegas', 'style' => 'number'], - 'Fecha Venta', - ['name' => 'Mes', 'style' => 'mes'], - 'Tipo', - ['name' => 'm² Ponderados', 'style' => 'amount'], - ['name' => 'Valor Promesa', 'style' => 'amount'], - ['name' => 'Pie [UF]', 'style' => 'amount'], - ['name' => 'Pie [$]', 'style' => 'amount'], - ['name' => 'Abono Escritura', 'style' => 'amount'], - ['name' => 'Crédito', 'style' => 'amount'], - ['name' => 'Cuotas', 'style' => 'number'], - ['name' => 'Cuotas Pagadas', 'style' => 'number'], - ['name' => 'Pie Pagado [UF]', 'style' => 'amount'], - ['name' => 'Pie Pagado [$]', 'style' => 'amount'] - ]; - $informe->addColumns($columnas); - - $data = []; - foreach ($ventas as $venta) { - $info = []; - $info['Propietario'] = mb_strtoupper($venta->propietario()->nombreCompleto()); - $info['Departamento'] = $venta->unidad()->descripcion; - $ests = []; - if ($venta->propiedad()->estacionamientos != '') { - $es = $venta->propiedad()->estacionamientos(); - foreach ($es as $e) { - $ests []= $e->descripcion; - } - } - $info['Estacionamientos'] = implode(', ', $ests); - $bods = []; - if ($venta->propiedad()->bodegas != '') { - $bs = $venta->propiedad()->bodegas(); - foreach ($bs as $b) { - $bods []= $b->descripcion; - } - } - $info['Bodegas'] = implode(', ', $bods); - $info['Fecha Venta'] = $venta->fecha()->format('d.m.Y'); - $info['Mes'] = $venta->fecha()->format('M-y'); - $info['Tipo'] = $venta->unidad()->abreviacion; - $info['m² Ponderados'] = $venta->unidad()->m2('vendible'); - $info['Valor Promesa'] = $venta->valor_uf; - $info['Pie [UF]'] = 0; - $info['Pie [$]'] = 0; - $info['Abono Escritura'] = 0; - $info['Crédito'] = 0; - $info['Cuotas'] = 0; - $info['Cuotas Pagadas'] = 0; - $info['Pie Pagado [UF]'] = 0; - $info['Pie Pagado [$]'] = 0; - if ($venta->pie()) { - $info['Pie [UF]'] = $venta->pie()->valor; - $info['Pie [$]'] = $venta->pie()->valorPesos(); - $info['Abono Escritura'] = ($venta->escritura != 0) ? $venta->escritura()->valor('ufs') : ($venta->valor_uf - $venta->pie()->valor - (($venta->credito != 0) ? $venta->credito()->pago()->valor('ufs') : 0)); - $info['Crédito'] = ($venta->credito != 0) ? $venta->credito()->pago()->valor('ufs') : 0; - $info['Cuotas'] = $venta->pie()->cuotas; - $info['Cuotas Pagadas'] = count($venta->pie()->pagadas($mes)); - $info['Pie Pagado [UF]'] = $venta->pie()->valorPagado('uf', $mes); - $info['Pie Pagado [$]'] = $venta->pie()->valorPagado('pesos', $mes); - } - - $data []= $info; - } - $informe->addData($data); - - $totals = [ - 'Departamento' => 'count', - 'Estacionamientos' => 'count', - 'Bodegas' => 'count', - 'm² Ponderados' => 'sum', - 'Valor Promesa' => 'sum', - 'Pie' => 'sum', - 'Pie Pagado' => 'sum' - ]; - $informe->addTotals($totals); - - return $informe->informe(); + return ''; } else { $proyectos = model(Proyecto::class)->order_by_asc('descripcion')->find_many(); return view('informes.resumen_contabilidad', compact('proyectos')); diff --git a/app/Service/Informe/Contabilidad/Resumen.php b/app/Service/Informe/Contabilidad/Resumen.php index a0b1167..66f9e10 100644 --- a/app/Service/Informe/Contabilidad/Resumen.php +++ b/app/Service/Informe/Contabilidad/Resumen.php @@ -170,12 +170,5 @@ class Resumen ->formatColumn('C') ->formatColumn('D') ->send($filename); - return; - - header("Content-Type: text/csv; charset=utf-8"); - header('Content-Disposition: attachment; filename="' . $filename . '"'); - header('Cache-Control: max-age=0'); - - file_put_contents('php://output', implode(PHP_EOL, $output)); } }