FIX: format in excel
This commit is contained in:
@ -119,10 +119,6 @@ class Resumen
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function formatValue(float $value)
|
|
||||||
{
|
|
||||||
return number_format($value, 0, ',', '.');
|
|
||||||
}
|
|
||||||
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);
|
||||||
@ -131,11 +127,11 @@ class Resumen
|
|||||||
$haber = 0;
|
$haber = 0;
|
||||||
foreach ($pagos as $pago) {
|
foreach ($pagos as $pago) {
|
||||||
if ($pago->valor > 0) {
|
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;
|
$debe += $pago->valor;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$output []= ['', $pago->fecha->format('d/m/Y'), $this->formatValue(-$pago->valor), ''];
|
$output []= ['', $pago->fecha->format('d/m/Y'), -$pago->valor, ''];
|
||||||
$haber -= $pago->valor;
|
$haber -= $pago->valor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,6 +152,8 @@ class Resumen
|
|||||||
$informe = new Informe();
|
$informe = new Informe();
|
||||||
$informe->createSpreadsheet()
|
$informe->createSpreadsheet()
|
||||||
->addArray($output)
|
->addArray($output)
|
||||||
|
->formatColumn('C')
|
||||||
|
->formatColumn('D')
|
||||||
->send($filename);
|
->send($filename);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -38,6 +38,11 @@ class Informe
|
|||||||
$this->spreadsheet->getActiveSheet()->fromArray($this->formatArray($data), null, $start);
|
$this->spreadsheet->getActiveSheet()->fromArray($this->formatArray($data), null, $start);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
public function formatColumn(string $column)
|
||||||
|
{
|
||||||
|
$this->spreadsheet->getActiveSheet()->getStyle("{$column}:{$column}")->setFormatCode('#,##0');
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
public function send(string $filename)
|
public function send(string $filename)
|
||||||
{
|
{
|
||||||
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||||
|
Reference in New Issue
Block a user