Se agregar Resciliacion y el n° de departamento al inicio de la linea

FIX: acumulado no pagado
This commit is contained in:
2022-03-08 10:58:38 -03:00
parent 27ace68b1d
commit 2f369c4e5e

View File

@ -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);
}
}