FIX: format in excel

This commit is contained in:
Juan Pablo Vial
2022-03-07 22:38:29 -03:00
parent fbce7089a8
commit 517276da1d
2 changed files with 9 additions and 6 deletions

View File

@ -119,10 +119,6 @@ class Resumen
});
}
protected function formatValue(float $value)
{
return number_format($value, 0, ',', '.');
}
protected function buildLibro(Venta $venta, DateTimeInterface $up_to)
{
$pagos = $this->getPagos($venta, $up_to);
@ -131,11 +127,11 @@ class Resumen
$haber = 0;
foreach ($pagos as $pago) {
if ($pago->valor > 0) {
$output []= ['', $pago->fecha->format('d/m/Y'), '', $this->formatValue($pago->valor)];
$output []= ['', $pago->fecha->format('d/m/Y'), '', $pago->valor];
$debe += $pago->valor;
}
else {
$output []= ['', $pago->fecha->format('d/m/Y'), $this->formatValue(-$pago->valor), ''];
$output []= ['', $pago->fecha->format('d/m/Y'), -$pago->valor, ''];
$haber -= $pago->valor;
}
}
@ -156,6 +152,8 @@ class Resumen
$informe = new Informe();
$informe->createSpreadsheet()
->addArray($output)
->formatColumn('C')
->formatColumn('D')
->send($filename);
return;

View File

@ -38,6 +38,11 @@ class Informe
$this->spreadsheet->getActiveSheet()->fromArray($this->formatArray($data), null, $start);
return $this;
}
public function formatColumn(string $column)
{
$this->spreadsheet->getActiveSheet()->getStyle("{$column}:{$column}")->setFormatCode('#,##0');
return $this;
}
public function send(string $filename)
{
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');