This commit is contained in:
2021-11-30 18:04:41 -03:00
parent 87323b22d8
commit f589ff960b
56 changed files with 1960 additions and 0 deletions

13
src/Common/Banco.php Normal file
View File

@ -0,0 +1,13 @@
<?php
namespace Incoviba\Common;
use Incoviba\API\Common\Alias\Model;
/**
* @property int $id
* @property string $nombre
*/
class Banco extends Model {
public static $_table = 'banco';
protected static $fields = ['nombre'];
}

14
src/Common/Comuna.php Normal file
View File

@ -0,0 +1,14 @@
<?php
namespace Incoviba\Common;
use Incoviba\API\Common\Alias\Model;
/**
* @property int $id
* @property string $descripcion
* @property Provincia $provincia
*/
class Comuna extends Model {
public static $_table = 'comuna';
protected static $fields = ['descripcion', 'provincia'];
}

24
src/Common/Direccion.php Normal file
View File

@ -0,0 +1,24 @@
<?php
namespace Incoviba\Common;
use Incoviba\API\Common\Alias\Model;
/**
* @property int $id
* @property string $calle
* @property int $numero
* @property string $extra
* @property Comuna $comuna
*/
class Direccion extends Model {
public static $_table = 'direccion';
protected static $fields = ['calle', 'numero', 'extra', 'comuna'];
protected ?Comuna $comuna_o;
public function comuna(): ?Comuna {
if ($this->comuna_o === null) {
$this->comuna_o = $this->childOf(Comuna::class, [Model::SELF_KEY => 'comuna']);
}
return $this->comuna_o;
}
}

29
src/Common/Provincia.php Normal file
View File

@ -0,0 +1,29 @@
<?php
namespace Incoviba\Common;
use Incoviba\API\Common\Alias\Model;
/**
* @property int $id
* @property string $descripcion
* @property Region $region
*/
class Provincia extends Model {
public static $_table = 'provincia';
protected static $fields = ['descripcion', 'region'];
protected ?Region $region_o;
public function region(): ?Region {
if ($this->region_o === null) {
$this->region_o = $this->childOf(Region::class, [Model::SELF_KEY => 'region']);
}
return $this->region_o;
}
protected ?array $comunas;
public function comunas(): ?array {
if ($this->comunas === null) {
$this->comunas = $this->parentOf(Comuna::class, [Model::CHILD_KEY => 'provincia']);
}
return $this->comunas;
}
}

23
src/Common/Region.php Normal file
View File

@ -0,0 +1,23 @@
<?php
namespace Incoviba\Common;
use Incoviba\API\Common\Alias\Model;
/**
* @property int $id
* @property string $descripcion
* @property string $numeral
* @property int $numeracion
*/
class Region extends Model {
public static $_table = 'region';
protected static $fields = ['descripcion', 'numeral', 'numeracion'];
protected ?array $provincias;
public function provincias(): ?array {
if ($this->provincias === null) {
$this->provincias = $this->parentOf(Provincia::class, [Model::CHILD_KEY => 'region']);
}
return $this->provincias;
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace Incoviba\Inmobiliaria;
use Incoviba\API\Common\Alias\Model;
use Incoviba\Common\Banco;
use Incoviba\Proyecto\Proyecto;
/**
* @property int $rut
* @property string $dv
* @property string $razon
* @property string $abreviacion
* @property string $cuenta
* @property Banco $banco
* @property TipoSociedad $sociedad
*/
class Inmobiliaria extends Model {
public static $_table = 'inmobiliaria';
public static $_id_column = ['rut'];
protected static $fields = ['rut', 'dv', 'razon', 'abreviacion', 'cuenta'];
protected $banco_o;
public function banco() {
if ($this->banco_o === null) {
$this->banco_o = $this->childOf(Banco::class, [Model::SELF_KEY => 'banco']);
}
return $this->banco_o;
}
protected $sociedad_o;
public function sociedad() {
if ($this->sociedad_o === null) {
$this->sociedad_o = $this->childOf(TipoSociedad::class, [Model::SELF_KEY => 'sociedad']);
}
return $this->sociedad_o;
}
protected $proyectos;
public function proyectos(): ?array {
if ($this->proyectos === null) {
$this->proyectos = $this->parentOf(Proyecto::class, [Model::CHILD_KEY => 'inmobiliaria', Model::SELF_KEY => 'rut']);
}
return $this->proyectos;
}
}

View File

@ -0,0 +1,9 @@
<?php
namespace Incoviba\Inmobiliaria;
use Incoviba\API\Common\Alias\Model;
class TipoSociedad extends Model {
public static $_table = 'tipo_sociedad';
protected static $fields = ['descripcion', 'abreviacion'];
}

40
src/Proyecto/Proyecto.php Normal file
View File

@ -0,0 +1,40 @@
<?php
namespace Incoviba\Proyecto;
use Incoviba\API\Common\Alias\Model;
use Incoviba\Common\Direccion;
use Incoviba\Inmobiliaria\Inmobiliaria;
/**
* @property int $id
* @property Inmobiliaria $inmobiliaria
* @property string $descripcion
* @property Direccion $direccion
* @property double $superficie_terreno
* @property double $valor_terreno;
* @property double $corredor;
* @property double $superficie_sobre_terreno;
* @property double $superficie_bajo_terreno;
* @property int $pisos;
* @property int $subterraneos;
*/
class Proyecto extends Model {
public static $_table = 'proyecto';
protected static $fields = ['inmobiliaria', 'descripcion', 'direccion', 'superficie_terreno', 'valor_terreno',
'corredor', 'superficie_sobre_terreno', 'superficie_bajo_terreno', 'pisos', 'subterraneos'];
protected $direccion_o;
public function direccion() {
if ($this->direccion_o === null) {
$this->direccion_o = $this->childOf(Direccion::class, [Model::SELF_KEY => 'direccion']);
}
return $this->direccion_o;
}
protected $inmobiliaria_o;
public function inmobiliaria() {
if ($this->inmobiliaria_o === null) {
$this->inmobiliaria_o = $this->childOf(Inmobiliaria::class, [Model::SELF_KEY => 'inmobiliaria', Model::PARENT_KEY => 'rut']);
}
return $this->inmobiliaria_o;
}
}

6
src/Venta/Agente.php Normal file
View File

@ -0,0 +1,6 @@
<?php
namespace Incoviba\Venta;
use Incoviba\API\Common\Alias\Model;
class Agente extends Model {}

6
src/Venta/BonoPie.php Normal file
View File

@ -0,0 +1,6 @@
<?php
namespace Incoviba\Venta;
use Incoviba\API\Common\Alias\Model;
class BonoPie extends Model {}

6
src/Venta/Credito.php Normal file
View File

@ -0,0 +1,6 @@
<?php
namespace Incoviba\Venta;
use Incoviba\API\Common\Alias\Model;
class Credito extends Model {}

6
src/Venta/Entrega.php Normal file
View File

@ -0,0 +1,6 @@
<?php
namespace Incoviba\Venta;
use Incoviba\API\Common\Alias\Model;
class Entrega extends Model {}

6
src/Venta/Escritura.php Normal file
View File

@ -0,0 +1,6 @@
<?php
namespace Incoviba\Venta;
use Incoviba\API\Common\Alias\Model;
class Escritura extends Model {}

View File

@ -0,0 +1,6 @@
<?php
namespace Incoviba\Venta;
use Incoviba\API\Common\Alias\Model;
class EstadoVenta extends Model {}

6
src/Venta/Pago.php Normal file
View File

@ -0,0 +1,6 @@
<?php
namespace Incoviba\Venta;
use Incoviba\API\Common\Alias\Model;
class Pago extends Model {}

6
src/Venta/Pie.php Normal file
View File

@ -0,0 +1,6 @@
<?php
namespace Incoviba\Venta;
use Incoviba\API\Common\Alias\Model;
class Pie extends Model {}

6
src/Venta/Promocion.php Normal file
View File

@ -0,0 +1,6 @@
<?php
namespace Incoviba\Venta;
use Incoviba\API\Common\Alias\Model;
class Promocion extends Model {}

6
src/Venta/Propiedad.php Normal file
View File

@ -0,0 +1,6 @@
<?php
namespace Incoviba\Venta;
use Incoviba\API\Common\Alias\Model;
class Propiedad extends Model {}

31
src/Venta/Propietario.php Normal file
View File

@ -0,0 +1,31 @@
<?php
namespace Incoviba\Venta;
use Incoviba\API\Common\Alias\Model;
use Incoviba\Common\Direccion;
class Propietario extends Model {
public static $_table = 'propietario';
public static $_id_column = ['rut'];
protected $direccion_o;
public function direccion() {
if ($this->direccion_o === null) {
$this->direccion_o = $this->childOf(Direccion::class, [Model::SELF_KEY => 'direccion']);
}
return $this->direccion_o;
}
public function nombreCompleto() {
return implode(' ', [
$this->nombres,
$this->apellidos()
]);
}
public function apellidos() {
return implode(' ', [
$this->apellido_paterno,
$this->apellido_materno
]);
}
}

View File

@ -0,0 +1,6 @@
<?php
namespace Incoviba\Venta;
use Incoviba\API\Common\Alias\Model;
class Resciliacion extends Model {}

6
src/Venta/Subsidio.php Normal file
View File

@ -0,0 +1,6 @@
<?php
namespace Incoviba\Venta;
use Incoviba\API\Common\Alias\Model;
class Subsidio extends Model {}

144
src/Venta/Venta.php Normal file
View File

@ -0,0 +1,144 @@
<?php
namespace Incoviba\Venta;
use DateTime;
use Incoviba\API\Common\Alias\Model;
/**
* @property int $id
* @property Propietario $propietario
* @property Propiedad $propiedad
* @property ?Pie $pie
* @property ?BonoPie $bono_pie
* @property ?Credito $credito
* @property ?Escritura $escritura
* @property ?Subsidio $subsidio
* @property ?DateTime $escriturado
* @property ?Entrega $entrga
* @property ?DateTime $entregado
* @property DateTime $fecha
* @property double $valor_uf
* @property int $estado
* @property ?DateTime $fecha_entrega
* @property int $avalchile
* @property Agente $agente
* @property double $uf
* @property int $relacionado
* @property ?Promocion $promocion
* @property ?Resciliacion $resciliacion
* @property ?Pago $devolucion
*/
class Venta extends Model {
public static $_table = 'venta';
protected static $field = ['propietario', 'propiedad', 'pie', 'bono_pie', 'credito', 'escritura', 'subsidio',
'escriturado', 'entrega', 'entregado', 'fecha', 'valor_uf', 'estado', 'fecha_entrega', 'avalchile', 'agente', 'uf',
'relacionado', 'promocion', 'resciliacion', 'devolucion'];
protected $propietario_o;
public function propietario() {
if ($this->propietario_o === null) {
$this->propietario_o = $this->childOf(Propietario::class, [Model::SELF_KEY => 'propietario', Model::PARENT_KEY => 'rut']);
}
return $this->propietario_o;
}
protected $propiedad_o;
public function propiedad() {
if ($this->propiedad_o === null) {
$this->propiedad_o = $this->childOf(Propiedad::class, [Model::SELF_KEY => 'propiedad']);
}
return $this->propiedad_o;
}
protected $pie_o;
public function pie() {
if($this->pie_o === null) {
$this->pie_o = $this->childOf(Pie::class, [Model::SELF_KEY => 'pie']);
}
return $this->pie_o;
}
protected $bono;
public function bono() {
if ($this->bono === null) {
$this->bono = $this->childOf(BonoPie::class, [Model::SELF_KEY => 'bono_pie']);
}
return $this->bono;
}
protected $credito_o;
public function credito() {
if ($this->credito_o === null) {
$this->credito_o = $this->childOf(Credito::class, [Model::SELF_KEY => 'credito']);
}
return $this->credito_o;
}
protected $escritura_o;
public function escritura() {
if ($this->escritura_o === null) {
$this->escritura_o = $this->childOf(Escritura::class, [Model::SELF_KEY => 'escritura']);
}
return $this->escritura_o;
}
protected $subsidio_o;
public function subsidio() {
if ($this->subsidio_o === null) {
$this->subsidio_o = $this->childOf(Subsidio::class, [Model::SELF_KEY => 'subsidio']);
}
return $this->subsidio_o;
}
protected $entrega_o;
public function entrega() {
if ($this->entrega_o === null) {
$this->entrega_o = $this->childOf(Entrega::class, [Model::SELF_KEY => 'entrega']);
}
return $this->entrega_o;
}
protected $agente_o;
public function agente() {
if ($this->agente_o === null) {
$this->agente_o = $this->childOf(Agente::class, [Model::SELF_KEY => 'agente']);
}
return $this->agente_o;
}
protected $promocion_o;
public function promocion() {
if ($this->promocion_o === null) {
$this->promocion_o = $this->childOf(Promocion::class, [Model::SELF_KEY => 'promocion']);
}
return $this->promocion_o;
}
protected $resciliacion_o;
public function resciliacion() {
if ($this->resciliacion_o === null) {
$this->resciliacion_o = $this->childOf(Resciliacion::class, [Model::SELF_KEY => 'resciliacion']);
}
return $this->resciliacion_o;
}
protected $devolucion_o;
public function devolucion() {
if ($this->devolucion_o === null) {
$this->devolucion_o = $this->childOf(Pago::class, [Model::SELF_KEY => 'devolucion']);
}
return $this->devolucion_o;
}
protected $estados;
public function estados() {
if ($this->estados === null) {
$this->estados = $this->parentOf(EstadoVenta::class, [Model::CHILD_KEY => 'venta']);
}
return $this->estados;
}
protected $estado;
public function estado() {
if ($this->estado === null) {
$estados = $this->estados();
usort($estados, function ($a, $b) {
$f = $b->fecha - $a->fecha;
if ($f == 0) {
return $b->id - $a->id;
}
return $f;
});
$this->estado = $estados[0];
}
return $this->estado;
}
}