Se agregar Resciliacion y el n° de departamento al inicio de la linea
FIX: acumulado no pagado
This commit is contained in:
@ -68,7 +68,7 @@ class Resumen
|
|||||||
$cuotas = $venta->pie()->cuotas('fecha', $up_to);
|
$cuotas = $venta->pie()->cuotas('fecha', $up_to);
|
||||||
$ly = $this->startOfYear($up_to);
|
$ly = $this->startOfYear($up_to);
|
||||||
$older = array_reduce($cuotas, function($sum, $item) use ($ly) {
|
$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;
|
return $sum;
|
||||||
}
|
}
|
||||||
if ($item->pago()->fecha() >= $ly) {
|
if ($item->pago()->fecha() >= $ly) {
|
||||||
@ -119,6 +119,13 @@ class Resumen
|
|||||||
}
|
}
|
||||||
return [$this->extractValueDate($venta->subsidio()->pago(), 'Ahorro'), $this->extractValueDate($venta->subsidio()->subsidio(), 'Subsidio')];
|
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)
|
protected function getPagos(Venta $venta, DateTimeInterface $up_to)
|
||||||
{
|
{
|
||||||
$pagos = [];
|
$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)
|
protected function buildLibro(Venta $venta, DateTimeInterface $up_to)
|
||||||
{
|
{
|
||||||
$pagos = $this->getPagos($venta, $up_to);
|
$pagos = $this->getPagos($venta, $up_to);
|
||||||
@ -143,16 +157,15 @@ class Resumen
|
|||||||
$debe = 0;
|
$debe = 0;
|
||||||
$haber = 0;
|
$haber = 0;
|
||||||
foreach ($pagos as $pago) {
|
foreach ($pagos as $pago) {
|
||||||
|
$output []= $this->buildLine($venta, $pago);
|
||||||
if ($pago->valor > 0) {
|
if ($pago->valor > 0) {
|
||||||
$output []= ['', $pago->fecha->format('d/m/Y'), $pago->glosa, '', $pago->valor, $pago->estado];
|
|
||||||
$debe += $pago->valor;
|
$debe += $pago->valor;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$output []= ['', $pago->fecha->format('d/m/Y'), $pago->glosa, -$pago->valor, '', $pago->estado];
|
|
||||||
$haber -= $pago->valor;
|
$haber -= $pago->valor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$output []= ['', '', 'Total', $haber, $debe];
|
$output []= ['', '', '', 'Total', $haber, $debe];
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,15 +176,15 @@ class Resumen
|
|||||||
|
|
||||||
$output = ["Libro Mayor {$ventas[0]->proyecto()->descripcion}", ''];
|
$output = ["Libro Mayor {$ventas[0]->proyecto()->descripcion}", ''];
|
||||||
foreach ($ventas as $venta) {
|
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";
|
$filename = "Contabilidad - Resumen - {$ventas[0]->proyecto()->descripcion} - {$up_to->format('Y-m-d')}.xlsx";
|
||||||
$informe = new Informe();
|
$informe = new Informe();
|
||||||
$informe->createSpreadsheet()
|
$informe->createSpreadsheet()
|
||||||
->addArray($output)
|
->addArray($output)
|
||||||
->formatColumn('C')
|
->formatColumn('E')
|
||||||
->formatColumn('D')
|
->formatColumn('F')
|
||||||
->send($filename);
|
->send($filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user