Guardar factura
This commit is contained in:
@ -13,11 +13,11 @@ class Factura extends Ideal\Model
|
||||
public float $proporcion;
|
||||
public Model\Persona $cliente;
|
||||
|
||||
public DateTimeInterface $fecha;
|
||||
public array $unidades; // [[unidad, descripcion, precio, prorrateo]]
|
||||
public int $terreno;
|
||||
public object $uf; // [fecha, valor]
|
||||
public object $ipc; // [fecha, valor]
|
||||
public ?DateTimeInterface $fecha = null;
|
||||
public ?array $unidades = null; // [[unidad, descripcion, precio, prorrateo]]
|
||||
public ?int $terreno = null;
|
||||
public ?object $uf = null; // [fecha, valor]
|
||||
public ?object $ipc = null; // [fecha, valor]
|
||||
|
||||
protected array $estados;
|
||||
public function estados(): array
|
||||
@ -28,23 +28,23 @@ class Factura extends Ideal\Model
|
||||
return $this->estados ?? [];
|
||||
}
|
||||
|
||||
public function total(): int
|
||||
public function total(): float
|
||||
{
|
||||
return $this->venta->valor * $this->uf->valor * $this->proporcion;
|
||||
}
|
||||
public function bruto(): int
|
||||
public function bruto(): float
|
||||
{
|
||||
return $this->total() - $this->terreno * $this->proporcion;
|
||||
}
|
||||
public function iva(): int
|
||||
public function iva(): float
|
||||
{
|
||||
return $this->neto() * .19;
|
||||
}
|
||||
public function neto(): int
|
||||
public function neto(): float
|
||||
{
|
||||
return $this->bruto() / 1.19;
|
||||
}
|
||||
public function base(): int
|
||||
public function base(): float
|
||||
{
|
||||
return $this->neto() + $this->terreno * $this->proporcion;
|
||||
}
|
||||
@ -59,7 +59,7 @@ class Factura extends Ideal\Model
|
||||
'total' => $this->total(),
|
||||
'descuento' => array_reduce($this->unidades, function($sum, $unidad) {
|
||||
return $sum + $unidad->prorrateo * $this->proporcion;
|
||||
})
|
||||
}, 0)
|
||||
];
|
||||
}
|
||||
public function totales(): array
|
||||
@ -89,18 +89,17 @@ class Factura extends Ideal\Model
|
||||
'receptor' => [
|
||||
'rut' => $this->cliente->rutCompleto(),
|
||||
'nombre' => $this->cliente->nombreCompleto(),
|
||||
'direccion' => $this->cliente->datos()->direccion->simple(),
|
||||
'comuna' => $this->cliente->datos()->direccion->comuna->descripcion
|
||||
'direccion' => $this->cliente->datos()->direccion?->simple(),
|
||||
'comuna' => $this->cliente->datos()->direccion?->comuna->descripcion
|
||||
],
|
||||
'fecha' => $this->fecha->format('Y-m-d'),
|
||||
'fecha' => $this->fecha?->format('Y-m-d'),
|
||||
'unidades' => $this->unidades,
|
||||
'detalle' => $this->detalle(),
|
||||
'total' => $this->totales(),
|
||||
'uf' => [
|
||||
'fecha' => $this->uf->fecha->format('Y-m-d'),
|
||||
'valor' => $this->uf->valor
|
||||
'fecha' => $this->uf?->fecha->format('Y-m-d'),
|
||||
'valor' => $this->uf?->valor
|
||||
],
|
||||
'estados' => $this->estados()
|
||||
]);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user