Ventas->Listado->Ventas
This commit is contained in:
@ -15,4 +15,8 @@ class Comuna extends Model
|
||||
'provincia' => $this->provincia
|
||||
]);
|
||||
}
|
||||
public function __toString(): string
|
||||
{
|
||||
return implode(', ', [$this->descripcion, '' . $this->provincia]);
|
||||
}
|
||||
}
|
||||
|
@ -19,4 +19,18 @@ class Direccion extends Model
|
||||
'comuna' => $this->comuna
|
||||
]);
|
||||
}
|
||||
public function __toString(): string
|
||||
{
|
||||
$array = [
|
||||
implode(' ', [
|
||||
$this->calle,
|
||||
$this->numero
|
||||
])
|
||||
];
|
||||
if ($this->extra !== '') {
|
||||
$array[]= $this->extra;
|
||||
}
|
||||
$array []= '' . $this->comuna;
|
||||
return implode(', ', $array);
|
||||
}
|
||||
}
|
||||
|
@ -15,4 +15,8 @@ class Provincia extends Model
|
||||
'region' => $this->region
|
||||
]);
|
||||
}
|
||||
public function __toString(): string
|
||||
{
|
||||
return implode(', ', [$this->descripcion, '' . $this->region]);
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,15 @@
|
||||
<?php
|
||||
namespace Incoviba\Model;
|
||||
|
||||
use Incoviba\Common\Ideal\Model;
|
||||
use Incoviba\Model\Proyecto\Superficie;
|
||||
use Incoviba\Model\Proyecto\Terreno;
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class Proyecto extends Model
|
||||
class Proyecto extends Ideal\Model
|
||||
{
|
||||
public Inmobiliaria $inmobiliaria;
|
||||
public string $descripcion;
|
||||
public Direccion $direccion;
|
||||
public Terreno $terreno;
|
||||
public Superficie $superficie;
|
||||
public Proyecto\Terreno $terreno;
|
||||
public Proyecto\Superficie $superficie;
|
||||
public float $corredor;
|
||||
public int $pisos;
|
||||
public int $subterraneos;
|
||||
|
@ -17,4 +17,8 @@ class Region extends Model
|
||||
'numeracion' => $this->numeracion ?? 0
|
||||
]);
|
||||
}
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->descripcion;
|
||||
}
|
||||
}
|
||||
|
34
app/src/Model/Venta.php
Normal file
34
app/src/Model/Venta.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace Incoviba\Model;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class Venta extends Ideal\Model
|
||||
{
|
||||
public Venta\Propietario $propietario;
|
||||
public Venta\Propiedad $propiedad;
|
||||
public Venta\FormaPago $formaPago;
|
||||
public DateTimeInterface $fecha;
|
||||
public DateTimeInterface $fechaIngreso;
|
||||
public float $valor;
|
||||
public bool $relacionado;
|
||||
|
||||
public array $estados;
|
||||
public Venta\EstadoVenta $currentEstado;
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
'propietario' => $this->propietario,
|
||||
'propiedad' => $this->propiedad,
|
||||
'forma_pago' => $this->formaPago,
|
||||
'fecha' => $this->fecha->format('Y-m-d'),
|
||||
'fecha_ingreso' => $this->fechaIngreso->format('Y-m-d'),
|
||||
'valor' => $this->valor,
|
||||
'relacionado' => $this->relacionado,
|
||||
'estados' => $this->estados,
|
||||
'current_estado' => $this->currentEstado
|
||||
]);
|
||||
}
|
||||
}
|
8
app/src/Model/Venta/BonoPie.php
Normal file
8
app/src/Model/Venta/BonoPie.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Venta;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class BonoPie extends Ideal\Model
|
||||
{
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Venta;
|
||||
|
||||
use stdClass;
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Model;
|
||||
@ -17,6 +18,28 @@ class Cierre extends Ideal\Model
|
||||
public ?EstadoCierre $current = null;
|
||||
|
||||
public array $unidades = [];
|
||||
public array $valoresCierre = [];
|
||||
|
||||
public function neto(): float
|
||||
{
|
||||
$sum = $this->precio;
|
||||
$bonos = array_filter($this->valoresCierre, function(ValorCierre $valorCierre) {return $valorCierre->tipoValorCierre->descripcion === 'bono pie';});
|
||||
$sum -= array_reduce($bonos, function($sum, ValorCierre $bono) {return $sum + $bono->valor;}, 0);
|
||||
$unidades = array_filter($this->unidades, function(Unidad $unidad) {return $unidad->proyectoTipoUnidad->tipoUnidad->descripcion !== 'departamento';});
|
||||
$sum -= array_reduce($unidades, function($sum, Unidad $unidad) {return $sum + ($unidad->currentPrecio->valor ?? 0);});
|
||||
return $sum;
|
||||
}
|
||||
|
||||
public function principal(): stdClass
|
||||
{
|
||||
$unidades = array_filter($this->unidades, function(Unidad $unidad) {return $unidad->proyectoTipoUnidad->tipoUnidad->descripcion === 'departamento';});
|
||||
$output = [
|
||||
'descripcion' => implode(' - ', array_map(function(Unidad $unidad) {return $unidad->descripcion;}, $unidades)),
|
||||
'vendible' => array_reduce($unidades, function($sum, Unidad $unidad) {return $sum + $unidad->proyectoTipoUnidad->vendible();}, 0),
|
||||
'precio' => array_reduce($unidades, function($sum, Unidad $unidad) {return $sum + $unidad->currentPrecio->valor;}, 0)
|
||||
];
|
||||
return (object) $output;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
@ -28,7 +51,8 @@ class Cierre extends Ideal\Model
|
||||
'propietario' => $this->propietario->rut,
|
||||
'estados' => $this->estados,
|
||||
'estado_cierre' => $this->current,
|
||||
'unidades' => $this->unidades
|
||||
'unidades' => $this->unidades,
|
||||
'valores_cierre' => $this->valoresCierre
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
7
app/src/Model/Venta/Credito.php
Normal file
7
app/src/Model/Venta/Credito.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Venta;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class Credito extends Ideal\Model
|
||||
{}
|
21
app/src/Model/Venta/Entrega.php
Normal file
21
app/src/Model/Venta/Entrega.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Venta;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class Entrega extends Ideal\Model
|
||||
{
|
||||
public DateTimeInterface $fecha;
|
||||
public ?Pago $operacion;
|
||||
public ?Pago $reserva;
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
'fecha' => $this->fecha->format('Y-m-d'),
|
||||
'operacion' => $this->operacion,
|
||||
'reserva' => $this->reserva
|
||||
]);
|
||||
}
|
||||
}
|
7
app/src/Model/Venta/Escritura.php
Normal file
7
app/src/Model/Venta/Escritura.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Venta;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class Escritura extends Ideal\Model
|
||||
{}
|
22
app/src/Model/Venta/EstadoVenta.php
Normal file
22
app/src/Model/Venta/EstadoVenta.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Venta;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Model;
|
||||
|
||||
class EstadoVenta extends Ideal\Model
|
||||
{
|
||||
public Model\Venta $venta;
|
||||
public TipoEstadoVenta $tipoEstadoVenta;
|
||||
public DateTimeInterface $fecha;
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
'venta_id' => $this->venta->id,
|
||||
'tipo_estado_venta' => $this->tipoEstadoVenta,
|
||||
'fecha' => $this->fecha->format('Y-m-d')
|
||||
]);
|
||||
}
|
||||
}
|
24
app/src/Model/Venta/FormaPago.php
Normal file
24
app/src/Model/Venta/FormaPago.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Venta;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
class FormaPago implements JsonSerializable
|
||||
{
|
||||
public ?Pie $pie;
|
||||
public ?BonoPie $bonoPie;
|
||||
public ?Credito $credito;
|
||||
public ?Escritura $escritura;
|
||||
public ?Subsidio $subsidio;
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return [
|
||||
'pie' => $this->pie ?? null,
|
||||
'bono_pie' => $this->bonoPie ?? null,
|
||||
'credito' => $this->credito ?? null,
|
||||
'escritura' => $this->escritura ?? null,
|
||||
'subsidio' => $this->subsidio ?? null
|
||||
];
|
||||
}
|
||||
}
|
47
app/src/Model/Venta/Propiedad.php
Normal file
47
app/src/Model/Venta/Propiedad.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Venta;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class Propiedad extends Ideal\Model
|
||||
{
|
||||
public array $unidades;
|
||||
|
||||
public function departamentos(): array
|
||||
{
|
||||
return array_filter($this->unidades, function(Unidad $unidad) {return $unidad->proyectoTipoUnidad->tipoUnidad->descripcion === 'departamento';});
|
||||
}
|
||||
public function estacionamientos(): array
|
||||
{
|
||||
return array_filter($this->unidades, function(Unidad $unidad) {return $unidad->proyectoTipoUnidad->tipoUnidad->descripcion === 'estacionamiento';});
|
||||
}
|
||||
public function bodegas(): array
|
||||
{
|
||||
return array_filter($this->unidades, function(Unidad $unidad) {return $unidad->proyectoTipoUnidad->tipoUnidad->descripcion === 'bodega';});
|
||||
}
|
||||
|
||||
public function summary(): string
|
||||
{
|
||||
return implode(' - ', array_merge(
|
||||
array_map(function(Unidad $unidad) {
|
||||
return $unidad->descripcion;
|
||||
}, $this->departamentos()),
|
||||
array_map(function(Unidad $unidad) {
|
||||
return "E{$unidad->descripcion}";
|
||||
}, $this->estacionamientos()),
|
||||
array_map(function(Unidad $unidad) {
|
||||
return "B{$unidad->descripcion}";
|
||||
}, $this->bodegas())
|
||||
));
|
||||
}
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return [
|
||||
'departamentos' => $this->departamentos(),
|
||||
'estacionamientos' => $this->estacionamientos(),
|
||||
'bodegas' => $this->bodegas(),
|
||||
'summary' => $this->summary()
|
||||
];
|
||||
}
|
||||
}
|
18
app/src/Model/Venta/Subsidio.php
Normal file
18
app/src/Model/Venta/Subsidio.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Venta;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class Subsidio extends Ideal\Model
|
||||
{
|
||||
public Pago $ahorro;
|
||||
public Pago $subsidio;
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
'ahorro' => $this->ahorro,
|
||||
'subsidio' => $this->subsidio
|
||||
]);
|
||||
}
|
||||
}
|
16
app/src/Model/Venta/TipoEstadoVenta.php
Normal file
16
app/src/Model/Venta/TipoEstadoVenta.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Venta;
|
||||
|
||||
use Incoviba\Model\Tipo;
|
||||
|
||||
class TipoEstadoVenta extends Tipo
|
||||
{
|
||||
public bool $activa;
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
'activa' => $this->activa
|
||||
]);
|
||||
}
|
||||
}
|
7
app/src/Model/Venta/TipoValorCierre.php
Normal file
7
app/src/Model/Venta/TipoValorCierre.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Venta;
|
||||
|
||||
use Incoviba\Model\Tipo;
|
||||
|
||||
class TipoValorCierre extends Tipo
|
||||
{}
|
@ -12,6 +12,9 @@ class Unidad extends Ideal\Model
|
||||
public ?string $orientacion = '';
|
||||
public Model\Proyecto\ProyectoTipoUnidad $proyectoTipoUnidad;
|
||||
|
||||
public array $precios = [];
|
||||
public ?Precio $currentPrecio = null;
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
|
20
app/src/Model/Venta/ValorCierre.php
Normal file
20
app/src/Model/Venta/ValorCierre.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace Incoviba\Model\Venta;
|
||||
|
||||
use Incoviba\Common\Ideal;
|
||||
|
||||
class ValorCierre extends Ideal\Model
|
||||
{
|
||||
public Cierre $cierre;
|
||||
public TipoValorCierre $tipoValorCierre;
|
||||
public float $valor;
|
||||
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), [
|
||||
'cierre_id' => $this->cierre->id,
|
||||
'tipo_valor_cierre' => $this->tipoValorCierre,
|
||||
'valor' => $this->valor
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user