87 lines
2.6 KiB
PHP
87 lines
2.6 KiB
PHP
![]() |
<?php
|
||
|
namespace Incoviba\Model\Venta;
|
||
|
|
||
|
use DateTimeInterface;
|
||
|
use Incoviba\Common\Ideal;
|
||
|
use Incoviba\Model;
|
||
|
|
||
|
class Factura extends Ideal\Model
|
||
|
{
|
||
|
public Model\Venta $venta;
|
||
|
public int $index;
|
||
|
public float $proporcion;
|
||
|
public string $emisorRut;
|
||
|
public string $emisorNombre;
|
||
|
public string $emisorDireccion;
|
||
|
public string $receptorRut;
|
||
|
public string $receptorNombre;
|
||
|
public string $receptorDireccion;
|
||
|
public string $receptorComuna;
|
||
|
public DateTimeInterface $fecha;
|
||
|
public array $unidades;
|
||
|
public int $detalleBase;
|
||
|
public int $detalleTerreno;
|
||
|
public int $detalleNeto;
|
||
|
public int $detalleIva;
|
||
|
public int $detalleBruto;
|
||
|
public float $detalleDescuento;
|
||
|
public int $detalleTotal;
|
||
|
public int $totalNeto;
|
||
|
public int $totalExento;
|
||
|
public int $totalIva;
|
||
|
public int $totalTotal;
|
||
|
public DateTimeInterface $fechaUF;
|
||
|
public float $valorUF;
|
||
|
|
||
|
protected array $estados;
|
||
|
public function estados(): array
|
||
|
{
|
||
|
if (!isset($this->estados)) {
|
||
|
$this->estados = $this->runFactory('estados');
|
||
|
}
|
||
|
return $this->estados ?? [];
|
||
|
}
|
||
|
|
||
|
public function jsonSerialize(): mixed
|
||
|
{
|
||
|
return array_merge(parent::jsonSerialize(), [
|
||
|
'venta_id' => $this->venta->id,
|
||
|
'index' => $this->index,
|
||
|
'proporcion' => $this->proporcion,
|
||
|
'emisor' => [
|
||
|
'rut' => $this->emisorRut,
|
||
|
'nombre' => $this->emisorNombre,
|
||
|
'direccion' => $this->emisorDireccion
|
||
|
],
|
||
|
'receptor' => [
|
||
|
'rut' => $this->receptorRut,
|
||
|
'nombre' => $this->receptorNombre,
|
||
|
'direccion' => $this->receptorDireccion,
|
||
|
'comuna' => $this->receptorComuna
|
||
|
],
|
||
|
'fecha' => $this->fecha->format('Y-m-d'),
|
||
|
'unidades' => $this->unidades,
|
||
|
'detalle' => [
|
||
|
'base' => $this->detalleBase,
|
||
|
'terreno' => $this->detalleTerreno,
|
||
|
'neto' => $this->detalleNeto,
|
||
|
'iva' => $this->detalleIva,
|
||
|
'bruto' => $this->detalleBruto,
|
||
|
'descuento' => $this->detalleDescuento,
|
||
|
'total' => $this->detalleTotal
|
||
|
],
|
||
|
'total' => [
|
||
|
'neto' => $this->totalNeto,
|
||
|
'exento' => $this->totalExento,
|
||
|
'iva' => $this->totalIva,
|
||
|
'total' => $this->totalTotal
|
||
|
],
|
||
|
'uf' => [
|
||
|
'fecha' => $this->fechaUF->format('Y-m-d'),
|
||
|
'valor' => $this->valorUF
|
||
|
],
|
||
|
'estados' => $this->estados()
|
||
|
]);
|
||
|
}
|
||
|
}
|