Cambios en formato
This commit is contained in:
@ -30,19 +30,19 @@ class Factura extends Ideal\Model
|
|||||||
|
|
||||||
public function total(): int
|
public function total(): int
|
||||||
{
|
{
|
||||||
return round($this->venta->valor * $this->uf->valor * $this->proporcion);
|
return $this->venta->valor * $this->uf->valor * $this->proporcion;
|
||||||
}
|
}
|
||||||
public function bruto(): int
|
public function bruto(): int
|
||||||
{
|
{
|
||||||
return round($this->total() - $this->terreno * $this->proporcion);
|
return $this->total() - $this->terreno * $this->proporcion;
|
||||||
}
|
}
|
||||||
public function iva(): int
|
public function iva(): int
|
||||||
{
|
{
|
||||||
return round($this->bruto() / 1.19 * .19);
|
return $this->neto() * .19;
|
||||||
}
|
}
|
||||||
public function neto(): int
|
public function neto(): int
|
||||||
{
|
{
|
||||||
return round($this->bruto() / 1.19);
|
return $this->bruto() / 1.19;
|
||||||
}
|
}
|
||||||
public function base(): int
|
public function base(): int
|
||||||
{
|
{
|
||||||
@ -83,7 +83,7 @@ class Factura extends Ideal\Model
|
|||||||
'emisor' => [
|
'emisor' => [
|
||||||
'rut' => $this->venta->proyecto()->inmobiliaria()->rut(),
|
'rut' => $this->venta->proyecto()->inmobiliaria()->rut(),
|
||||||
'nombre' => $this->venta->proyecto()->inmobiliaria()->nombreCompleto(),
|
'nombre' => $this->venta->proyecto()->inmobiliaria()->nombreCompleto(),
|
||||||
'direccion' => $this->venta->proyecto()->direccion(),
|
'direccion' => $this->venta->proyecto()->direccion()->simple(),
|
||||||
'comuna' => $this->venta->proyecto()->direccion()->comuna->descripcion
|
'comuna' => $this->venta->proyecto()->direccion()->comuna->descripcion
|
||||||
],
|
],
|
||||||
'receptor' => [
|
'receptor' => [
|
||||||
@ -96,9 +96,12 @@ class Factura extends Ideal\Model
|
|||||||
'unidades' => $this->unidades,
|
'unidades' => $this->unidades,
|
||||||
'detalle' => $this->detalle(),
|
'detalle' => $this->detalle(),
|
||||||
'total' => $this->totales(),
|
'total' => $this->totales(),
|
||||||
'uf' => $this->uf,
|
'uf' => [
|
||||||
'ipc' => $this->ipc,
|
'fecha' => $this->uf->fecha->format('Y-m-d'),
|
||||||
|
'valor' => $this->uf->valor
|
||||||
|
],
|
||||||
'estados' => $this->estados()
|
'estados' => $this->estados()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,11 @@ class Factura extends Ideal\Repository
|
|||||||
try {
|
try {
|
||||||
$result = $this->getDatos($factura->venta->id);
|
$result = $this->getDatos($factura->venta->id);
|
||||||
$factura->fecha = new DateTimeImmutable($result['fecha']);
|
$factura->fecha = new DateTimeImmutable($result['fecha']);
|
||||||
$factura->unidades = array_map(function($datos) {
|
$factura->uf = json_decode($result['uf']);
|
||||||
|
$factura->uf->fecha = new DateTimeImmutable($factura->uf->fecha);
|
||||||
|
$factura->ipc = json_decode($result['ipc']);
|
||||||
|
$factura->ipc->fecha = new DateTimeImmutable($factura->ipc->fecha);
|
||||||
|
$factura->unidades = array_map(function($datos) use ($factura) {
|
||||||
$unidad = $this->unidadRepository->fetchById($datos->unidad_id);
|
$unidad = $this->unidadRepository->fetchById($datos->unidad_id);
|
||||||
return (object) [
|
return (object) [
|
||||||
'unidad' => $unidad,
|
'unidad' => $unidad,
|
||||||
@ -50,8 +54,6 @@ class Factura extends Ideal\Repository
|
|||||||
];
|
];
|
||||||
}, json_decode($result['unidades']));
|
}, json_decode($result['unidades']));
|
||||||
$factura->terreno = $result['terreno'];
|
$factura->terreno = $result['terreno'];
|
||||||
$factura->uf = json_decode($result['uf']);
|
|
||||||
$factura->ipc = json_decode($result['ipc']);
|
|
||||||
} catch (EmptyResult) {}
|
} catch (EmptyResult) {}
|
||||||
|
|
||||||
return $factura;
|
return $factura;
|
||||||
|
Reference in New Issue
Block a user