Nuevo models
This commit is contained in:
22
src/nuevo/Common/Banco.php
Normal file
22
src/nuevo/Common/Banco.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Common;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property string descripcion
|
||||
*
|
||||
*/
|
||||
class Banco extends NewModel
|
||||
{
|
||||
protected static $_table = 'bancos';
|
||||
|
||||
//
|
||||
public function cuentas()
|
||||
{
|
||||
return $this->has_many(\Incoviba\nuevo\Inmobiliaria\Cuenta::class, 'banco_id')->findMany();
|
||||
}
|
||||
}
|
27
src/nuevo/Common/Comuna.php
Normal file
27
src/nuevo/Common/Comuna.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Common;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property string descripcion
|
||||
* @property Provincia provincia_id
|
||||
*
|
||||
*/
|
||||
class Comuna extends NewModel
|
||||
{
|
||||
protected static $_table = 'comunas';
|
||||
|
||||
//
|
||||
public function provincia()
|
||||
{
|
||||
return $this->belongs_to(Provincia::class, 'provincia_id')->findOne();
|
||||
}
|
||||
public function direcciones()
|
||||
{
|
||||
return $this->has_many(Direccion::class, 'comuna_id')->findMany();
|
||||
}
|
||||
}
|
24
src/nuevo/Common/Direccion.php
Normal file
24
src/nuevo/Common/Direccion.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Common;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property string calle
|
||||
* @property string numero
|
||||
* @property string extra
|
||||
* @property Comuna comuna_id
|
||||
*
|
||||
*/
|
||||
class Direccion extends NewModel
|
||||
{
|
||||
protected static $_table = 'direcciones';
|
||||
|
||||
public function comuna()
|
||||
{
|
||||
return $this->belongs_to(Comuna::class, 'comuna_id')->findOne();
|
||||
}
|
||||
}
|
33
src/nuevo/Common/M2.php
Normal file
33
src/nuevo/Common/M2.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Common;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property double util
|
||||
* @property double logia
|
||||
* @property double terraza
|
||||
* @property double cubierta
|
||||
* @property double terreno
|
||||
*
|
||||
*/
|
||||
class M2 extends NewModel
|
||||
{
|
||||
protected static $_table = 'm2s';
|
||||
|
||||
public function unidades()
|
||||
{
|
||||
return $this->has_many(\Incoviba\nuevo\Proyecto\UnidadProyecto::class, 'm2_id')->findMany();
|
||||
}
|
||||
public function vendibles()
|
||||
{
|
||||
return $this->util + $this->logia + $this->terraza / 2 + $this->cubierta / 3;
|
||||
}
|
||||
public function total()
|
||||
{
|
||||
return $this->util + $this->logia + $this->terraza + $this->cubierta;
|
||||
}
|
||||
}
|
27
src/nuevo/Common/Provincia.php
Normal file
27
src/nuevo/Common/Provincia.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Common;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property string descripcion
|
||||
* @property Region region_id
|
||||
*
|
||||
*/
|
||||
class Provincia extends NewModel
|
||||
{
|
||||
protected static $_table = 'provincias';
|
||||
|
||||
//
|
||||
public function region()
|
||||
{
|
||||
return $this->belongs_to(Region::class, 'region_id')->findOne();
|
||||
}
|
||||
public function comunas()
|
||||
{
|
||||
return $this->has_many(Comuna::class, 'provincia_id')->findMany();
|
||||
}
|
||||
}
|
24
src/nuevo/Common/Region.php
Normal file
24
src/nuevo/Common/Region.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Common;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property string descripcion
|
||||
* @property string nombre
|
||||
* @property string numeral
|
||||
* @property int orden
|
||||
*
|
||||
*/
|
||||
class Region extends NewModel
|
||||
{
|
||||
protected static $_table = 'regiones';
|
||||
|
||||
public function provincias()
|
||||
{
|
||||
return $this->has_many(Provincia::class, 'region_id')->findMany();
|
||||
}
|
||||
}
|
33
src/nuevo/Common/UF.php
Normal file
33
src/nuevo/Common/UF.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Common;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property Date fecha
|
||||
* @property double valor
|
||||
*
|
||||
*/
|
||||
class UF extends NewModel
|
||||
{
|
||||
protected static $_table = 'ufs';
|
||||
|
||||
protected static $_id_column = 'fecha';
|
||||
protected static $_timestamps = false;
|
||||
|
||||
//public $incrementing = false;
|
||||
|
||||
public function getValor()
|
||||
{
|
||||
$fecha = Carbon::parse($this->fecha, config('app.timezone'));
|
||||
$uf = uf($fecha);
|
||||
|
||||
if ($uf != null) {
|
||||
$this->valor = $uf->uf->value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
47
src/nuevo/Inmobiliaria/Agente.php
Normal file
47
src/nuevo/Inmobiliaria/Agente.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Inmobiliaria;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
use Incoviba\nuevo\Common\Direccion;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property int rut
|
||||
* @property char dv
|
||||
* @property string razon_social
|
||||
* @property string nombre
|
||||
* @property Representante representante_rut
|
||||
* @property int telefono
|
||||
* @property string correo
|
||||
* @property string giro
|
||||
* @property Direccion direccion_id
|
||||
* @property TipoAgente tipo_agente_id
|
||||
*
|
||||
*/
|
||||
class Agente extends NewModel
|
||||
{
|
||||
protected static $_table = 'agentes';
|
||||
//
|
||||
public function representante()
|
||||
{
|
||||
return $this->belongsTo(Representante::class, 'representante_rut', 'rut')->findOne();
|
||||
}
|
||||
public function direccion()
|
||||
{
|
||||
return $this->belongsTo(Direccion::class, 'direccion_id')->findOne();
|
||||
}
|
||||
public function tipo()
|
||||
{
|
||||
return $this->belongsTo(TipoAgente::class, 'tipo_agente_id')->findOne();
|
||||
}
|
||||
public function contratos()
|
||||
{
|
||||
return $this->hasMany(Contrato::class, 'agente_id')->findMany();
|
||||
}
|
||||
public function comision($inmobiliaria_rut)
|
||||
{
|
||||
return $this->hasMany(Contrato::class, 'agente_id')->where('inmobiliaria_rut', $inmobiliaria_rut)->sum('valor');
|
||||
}
|
||||
}
|
21
src/nuevo/Inmobiliaria/CategoriaCuentaContable.php
Normal file
21
src/nuevo/Inmobiliaria/CategoriaCuentaContable.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Inmobiliaria;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property string descripcion
|
||||
*
|
||||
*/
|
||||
class CategoriaCuentaContable extends NewModel
|
||||
{
|
||||
protected static $_table = 'categoria_cuenta_contables';
|
||||
|
||||
public function cuentas()
|
||||
{
|
||||
return $this->hasMany(CuentaContable::class, 'categoria_id')->findMany();
|
||||
}
|
||||
}
|
36
src/nuevo/Inmobiliaria/Cobro.php
Normal file
36
src/nuevo/Inmobiliaria/Cobro.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Inmobiliaria;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
use Incoviba\Common\Definition\hasEstado;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property Contrato contrato_id
|
||||
* @property TipoCobro tipo_cobro_id
|
||||
* @property Date fecha
|
||||
* @property string identificador
|
||||
* @property int valor
|
||||
* @property int iva
|
||||
* @property string glosa
|
||||
* @property double uf
|
||||
*
|
||||
*/
|
||||
class Cobro extends NewModel
|
||||
{
|
||||
use hasEstado;
|
||||
|
||||
protected static $_table = 'cobros';
|
||||
|
||||
//
|
||||
public function contrato()
|
||||
{
|
||||
return $this->belongsTo(Contrato::class, 'contrato_id')->findOne();
|
||||
}
|
||||
public function tipo()
|
||||
{
|
||||
return $this->belongsTo(TipoCobro::class, 'tipo_cobro_id')->findOne();
|
||||
}
|
||||
}
|
37
src/nuevo/Inmobiliaria/Contrato.php
Normal file
37
src/nuevo/Inmobiliaria/Contrato.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Inmobiliaria;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property Inmobiliaria inmobiliaria_rut
|
||||
* @property Agente agente_id
|
||||
* @property TipoContrato tipo_contrato_id
|
||||
* @property int valor
|
||||
*
|
||||
*/
|
||||
class Contrato extends NewModel
|
||||
{
|
||||
protected static $_table = 'contrato';
|
||||
|
||||
//
|
||||
public function inmobiliaria()
|
||||
{
|
||||
return $this->belongsTo(Inmobiliaria::class, 'inmobiliaria_rut', 'rut')->findOne();
|
||||
}
|
||||
public function agente()
|
||||
{
|
||||
return $this->belongsTo(Agente::class, 'agente_id')->findOne();
|
||||
}
|
||||
public function tipo()
|
||||
{
|
||||
return $this->belongsTo(TipoContrato::class, 'tipo_contrato_id')->findOne();
|
||||
}
|
||||
public function cobros()
|
||||
{
|
||||
return $this->hasMany(Cobro::class, 'contrato_id')->findMany();
|
||||
}
|
||||
}
|
31
src/nuevo/Inmobiliaria/Cuenta.php
Normal file
31
src/nuevo/Inmobiliaria/Cuenta.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Inmobiliaria;
|
||||
|
||||
use Incoviba\nuevo\Common\Banco;
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property int cuenta
|
||||
* @property Banco banco_id
|
||||
* @property Inmobiliaria inmobiliaria_rut
|
||||
* @property string usuario
|
||||
* @property string password
|
||||
*
|
||||
*/
|
||||
class Cuenta extends NewModel
|
||||
{
|
||||
protected static $_table = 'cuentas';
|
||||
|
||||
//
|
||||
public function inmobiliaria()
|
||||
{
|
||||
return $this->belongsTo(Inmobiliaria::class, 'inmobiliaria_rut', 'rut')->findOne();
|
||||
}
|
||||
public function banco()
|
||||
{
|
||||
return $this->belongsTo(Banco::class, 'banco_id')->findOne();
|
||||
}
|
||||
}
|
44
src/nuevo/Inmobiliaria/CuentaContable.php
Normal file
44
src/nuevo/Inmobiliaria/CuentaContable.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Inmobiliaria;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property Inmobiliaria inmobiliaria_rut
|
||||
* @property string descripcion
|
||||
* @property CategoriaCuentaContable categoria_id
|
||||
*
|
||||
*/
|
||||
class CuentaContable extends NewModel
|
||||
{
|
||||
protected static $_table = 'cuenta_contables';
|
||||
|
||||
public function inmobiliaria()
|
||||
{
|
||||
return $this->belongsTo(Inmobiliaria::class, 'inmobiliaria_rut', 'rut')->findOne();
|
||||
}
|
||||
public function categoria()
|
||||
{
|
||||
return $this->belongsTo(CategoriaCuentaContable::class, 'categoria_id')->findOne();
|
||||
}
|
||||
public function cargos()
|
||||
{
|
||||
return $this->hasMany(TransaccionContable::class, 'cuenta_de')->findMany();
|
||||
}
|
||||
public function abonos()
|
||||
{
|
||||
return $this->hasMany(TransaccionContable::class, 'cuenta_para')->findMany();
|
||||
}
|
||||
public function transacciones()
|
||||
{
|
||||
$transacciones = model(TransaccionContable::class)->whereAnyIs([['cuenta_de', $this->id], ['cuenta_para', $this->id]])->orderByAsc('fecha')->findMany();
|
||||
return $transacciones;
|
||||
}
|
||||
public function unidades()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
26
src/nuevo/Inmobiliaria/EstadoCobro.php
Normal file
26
src/nuevo/Inmobiliaria/EstadoCobro.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Inmobiliaria;
|
||||
|
||||
use Incoviba\Common\Alias\NewEstado;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property Cobro cobro_id
|
||||
* @property TipoEstadoCobro estado_id
|
||||
*
|
||||
*/
|
||||
class EstadoCobro extends NewEstado
|
||||
{
|
||||
protected static $_table = 'estado_cobros';
|
||||
|
||||
//
|
||||
public function cobro()
|
||||
{
|
||||
return $this->belongsTo(Cobro::class, 'cobro_id')->findOne();
|
||||
}
|
||||
public function estado()
|
||||
{
|
||||
return $this->belongsTo(TipoEstadoCobro::class, 'estado_id')->findOne();
|
||||
}
|
||||
}
|
50
src/nuevo/Inmobiliaria/Inmobiliaria.php
Normal file
50
src/nuevo/Inmobiliaria/Inmobiliaria.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Inmobiliaria;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
use Incoviba\nuevo\Common\Direccion;
|
||||
use Incoviba\nuevo\Proyecto\Proyecto;
|
||||
use Incoviba\Common\Definition\hasRUT;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
*
|
||||
* @property int rut
|
||||
* @property char dv
|
||||
* @property string nombre
|
||||
* @property string razon_social
|
||||
* @property Direccion direccion_id
|
||||
* @property Representante representante_rut
|
||||
* @property boolean estado
|
||||
*
|
||||
*/
|
||||
class Inmobiliaria extends NewModel
|
||||
{
|
||||
use hasRUT;
|
||||
|
||||
protected static $_table = 'inmobiliarias';
|
||||
|
||||
public function direccion()
|
||||
{
|
||||
return $this->belongs_to(Direccion::class, 'direccion_id')->findOne();
|
||||
}
|
||||
public function representante()
|
||||
{
|
||||
return $this->belongs_to(Representante::class, 'representante_rut', 'rut')->findOne();
|
||||
}
|
||||
public function estado()
|
||||
{
|
||||
return ($estado != 0);
|
||||
}
|
||||
|
||||
public function proyectos()
|
||||
{
|
||||
return $this->has_many(Proyecto::class, 'inmobiliaria_rut', 'rut')->findMany();
|
||||
}
|
||||
public function inversionistas()
|
||||
{
|
||||
return $this->has_many_through(Socio::class, Participacion::class, 'socio_id', 'inmobiliaria_rut', 'rut')->findMany();
|
||||
}
|
||||
}
|
||||
?>
|
27
src/nuevo/Inmobiliaria/Participacion.php
Normal file
27
src/nuevo/Inmobiliaria/Participacion.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Inmobiliaria;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property Inmobiliaria inmobiliaria_rut
|
||||
* @property Socio socio_rut
|
||||
* @property double participacion
|
||||
*
|
||||
*/
|
||||
class Participacion extends NewModel
|
||||
{
|
||||
protected static $_table = 'participaciones';
|
||||
|
||||
public function inmobiliaria()
|
||||
{
|
||||
return $this->belongsTo(Inmobiliaria::class, 'inmobiliaria_rut', 'rut')->findOne();
|
||||
}
|
||||
public function socio()
|
||||
{
|
||||
return $this->belongsTo(Socio::class, 'socio_rut', 'rut')->findOne();
|
||||
}
|
||||
}
|
56
src/nuevo/Inmobiliaria/Representante.php
Normal file
56
src/nuevo/Inmobiliaria/Representante.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Inmobiliaria;
|
||||
|
||||
use Incoviba\nuevo\Common\Direccion;
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
use Incoviba\Common\Definition\hasRUT;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int rut
|
||||
* @property char dv
|
||||
* @property string nombres
|
||||
* @property string apellidos
|
||||
* @property int telefono
|
||||
* @property Direccion direccion_id
|
||||
*
|
||||
*/
|
||||
class Representante extends NewModel
|
||||
{
|
||||
use hasRUT;
|
||||
|
||||
protected static $_table = 'representantes';
|
||||
|
||||
public function direccion()
|
||||
{
|
||||
return $this->belongsTo(Direccion::class, 'direccion_id')->findMany();
|
||||
}
|
||||
public function nombreCompleto()
|
||||
{
|
||||
return $this->nombres . ' ' . $this->apellidos;
|
||||
}
|
||||
|
||||
public function inmobiliarias()
|
||||
{
|
||||
return $this->hasMany(Inmobiliaria::class, 'representante_rut', 'rut')->findMany();
|
||||
}
|
||||
public function agentes()
|
||||
{
|
||||
return $this->hasMany(Agente::class, 'representante_rut', 'rut')->findMany();
|
||||
}
|
||||
public function apelativo()
|
||||
{
|
||||
if ($this->sexo == 'f') {
|
||||
return 'doña';
|
||||
}
|
||||
return 'don';
|
||||
}
|
||||
public function articulo()
|
||||
{
|
||||
if ($this->sexo == 'f') {
|
||||
return 'la';
|
||||
}
|
||||
return 'el';
|
||||
}
|
||||
}
|
23
src/nuevo/Inmobiliaria/Socio.php
Normal file
23
src/nuevo/Inmobiliaria/Socio.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Inmobiliaria;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int rut
|
||||
* @property char dv
|
||||
* @property string nombre
|
||||
*
|
||||
*/
|
||||
class Socio extends NewModel
|
||||
{
|
||||
protected static $_table = 'socios';
|
||||
protected static $_id_column = 'rut';
|
||||
|
||||
public function participaciones()
|
||||
{
|
||||
return $this->hasMany(Participacion::class, 'socio_rut', 'rut')->findMany();
|
||||
}
|
||||
}
|
22
src/nuevo/Inmobiliaria/TipoAgente.php
Normal file
22
src/nuevo/Inmobiliaria/TipoAgente.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Inmobiliaria;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property string descripcion
|
||||
*
|
||||
*/
|
||||
class TipoAgente extends NewModel
|
||||
{
|
||||
protected static $_table = 'tipo_agentes';
|
||||
|
||||
//
|
||||
public function agentes()
|
||||
{
|
||||
return $this->hasMany(Agente::class, 'tipo_agente_id')->findMany();
|
||||
}
|
||||
}
|
22
src/nuevo/Inmobiliaria/TipoCobro.php
Normal file
22
src/nuevo/Inmobiliaria/TipoCobro.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Inmobiliaria;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property string descripcion
|
||||
*
|
||||
*/
|
||||
class TipoCobro extends NewModel
|
||||
{
|
||||
protected static $_table = 'tipo_cobros';
|
||||
|
||||
//
|
||||
public function cobros()
|
||||
{
|
||||
return $this->hasMany(Cobro::class, 'tipo_cobro_id')->findMany();
|
||||
}
|
||||
}
|
22
src/nuevo/Inmobiliaria/TipoContrato.php
Normal file
22
src/nuevo/Inmobiliaria/TipoContrato.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Inmobiliaria;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property string descripcion
|
||||
*
|
||||
*/
|
||||
class TipoContrato extends NewModel
|
||||
{
|
||||
protected static $_table = 'tipo_contratos';
|
||||
|
||||
//
|
||||
public function contratos()
|
||||
{
|
||||
return $this->hasMany(Contrato::class)->findMany();
|
||||
}
|
||||
}
|
22
src/nuevo/Inmobiliaria/TipoEstadoCobro.php
Normal file
22
src/nuevo/Inmobiliaria/TipoEstadoCobro.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Inmobiliaria;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property string descripcion
|
||||
*
|
||||
*/
|
||||
class TipoEstadoCobro extends NewModel
|
||||
{
|
||||
protected static $_table = 'tipo_estado_cobros';
|
||||
|
||||
//
|
||||
public function estados()
|
||||
{
|
||||
return $this->hasMany(EstadoCobro::class, 'estado_id')->findMany();
|
||||
}
|
||||
}
|
46
src/nuevo/Inmobiliaria/TransaccionContable.php
Normal file
46
src/nuevo/Inmobiliaria/TransaccionContable.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Inmobiliaria;
|
||||
|
||||
use Incoviba\nuevo\Common\UF;
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property Cuenta cuenta_de
|
||||
* @property Cuenta cuenta_para
|
||||
* @property int valor
|
||||
* @property Date fecha
|
||||
* @property string glosa
|
||||
*
|
||||
*/
|
||||
|
||||
class TransaccionContable extends NewModel
|
||||
{
|
||||
protected static $_table = 'transaccion_contables';
|
||||
|
||||
public function de()
|
||||
{
|
||||
return $this->belongsTo(CuentaContable::class, 'cuenta_de');
|
||||
}
|
||||
public function para()
|
||||
{
|
||||
return $this->belongsTo(CuentaContable::class, 'cuenta_para');
|
||||
}
|
||||
|
||||
public function valor($tipo = 'pesos')
|
||||
{
|
||||
if ($tipo == 'ufs') {
|
||||
$uf = model(UF::class)->where('fecha', $this->fecha)->findOne();
|
||||
if (!$uf) {
|
||||
$uf = model(UF::class)->create();
|
||||
$uf->fecha = $this->fecha;
|
||||
$uf->getValor();
|
||||
$uf->save();
|
||||
}
|
||||
return ($this->valor / $uf->valor) ?: 0;
|
||||
}
|
||||
return $this->valor;
|
||||
}
|
||||
}
|
25
src/nuevo/Proyecto/EstadoProyecto.php
Normal file
25
src/nuevo/Proyecto/EstadoProyecto.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Proyecto;
|
||||
|
||||
use Incoviba\Common\Alias\NewEstado;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property Proyecto proyecto_id
|
||||
* @property TipoEstadoProyecto estado_id
|
||||
*
|
||||
*/
|
||||
class EstadoProyecto extends NewEstado
|
||||
{
|
||||
protected static $_table = 'estado_proyectos';
|
||||
|
||||
public function proyecto()
|
||||
{
|
||||
return $this->belongsTo(Proyecto::class, 'proyecto_id')->findOne();
|
||||
}
|
||||
public function estado()
|
||||
{
|
||||
return $this->belongsTo(TipoEstadoProyecto::class, 'estado_id')->findOne();
|
||||
}
|
||||
}
|
22
src/nuevo/Proyecto/Etapa.php
Normal file
22
src/nuevo/Proyecto/Etapa.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Proyecto;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property string descripcion
|
||||
* @property int orden
|
||||
*
|
||||
*/
|
||||
class Etapa extends NewModel
|
||||
{
|
||||
protected static $_table = 'etapas';
|
||||
|
||||
public function tipos()
|
||||
{
|
||||
return $this->hasMany(TipoEstadoProyecto::class, 'etapa_id')->findMany();
|
||||
}
|
||||
}
|
27
src/nuevo/Proyecto/Participe.php
Normal file
27
src/nuevo/Proyecto/Participe.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Proyecto;
|
||||
|
||||
use Incoviba\Common\Definition\hasRUT;
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property string nombre
|
||||
*
|
||||
*/
|
||||
class Participe extends NewModel
|
||||
{
|
||||
use hasRUT;
|
||||
|
||||
protected static $_table = 'participes';
|
||||
|
||||
public function proyectos()
|
||||
{
|
||||
return $this->hasManyThrough(Proyecto::class, ProyectoParticipe::class, 'proyecto_id', 'participe_rut', 'rut')->findMany();
|
||||
}
|
||||
public function participaciones()
|
||||
{
|
||||
return $this->hasMany(ProyectoParticipe::class, 'participe_rut', 'rut')->findMany();
|
||||
}
|
||||
}
|
132
src/nuevo/Proyecto/Proyecto.php
Normal file
132
src/nuevo/Proyecto/Proyecto.php
Normal file
@ -0,0 +1,132 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Proyecto;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
use Incoviba\nuevo\Inmobiliaria\Inmobiliaria;
|
||||
use Incoviba\nuevo\Common\Direccion;
|
||||
use Incoviba\Common\Definition\hasEstado;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property string nombre
|
||||
* @property string nombre_completo
|
||||
* @property Inmobiliaria inmobiliaria_rut
|
||||
* @property Direccion direccion_id
|
||||
* @property boolean portal
|
||||
* @property string descripcion
|
||||
*
|
||||
*/
|
||||
class Proyecto extends NewModel
|
||||
{
|
||||
use hasEstado;
|
||||
|
||||
protected static $_table = 'proyectos';
|
||||
|
||||
public function inmobiliaria()
|
||||
{
|
||||
return $this->belongsTo(Inmobiliaria::class, 'inmobiliaria_rut', 'rut')->findOne();
|
||||
}
|
||||
public function direccion()
|
||||
{
|
||||
return $this->belongsTo(Direccion::class, 'direccion_id')->findOne();
|
||||
}
|
||||
|
||||
public function participaciones()
|
||||
{
|
||||
return $this->hasMany(ProyectoParticipe::class, 'proyecto_id')->findMany();
|
||||
}
|
||||
public function participes()
|
||||
{
|
||||
return $this->hasManyThrough(Participe::class, ProyectoParticipe::class, 'proyecto_id', 'participe_rut', 'rut')->findMany();
|
||||
}
|
||||
public function unidades()
|
||||
{
|
||||
return $this->hasMany(UnidadProyecto::class, 'proyecto_id')->findMany();
|
||||
}
|
||||
public function cantidad($tipo = 'departamento')
|
||||
{
|
||||
$total = 0;
|
||||
$unidades = $this->unidades;
|
||||
foreach ($unidades as $unidad) {
|
||||
if ($unidad->tipo->descripcion == $tipo) {
|
||||
$total += $unidad->unidades->count();
|
||||
}
|
||||
}
|
||||
return $total;
|
||||
}
|
||||
public function unidadesPrincipales()
|
||||
{
|
||||
if ($this->tipoUnidades()) {
|
||||
return $this->cantidad('departamento');
|
||||
} else {
|
||||
return $this->cantidad('casa');
|
||||
}
|
||||
}
|
||||
public function pisos()
|
||||
{
|
||||
$max_piso = 0;
|
||||
$unidades = $this->unidades;
|
||||
foreach ($unidades as $unidad) {
|
||||
$piso = $unidad->unidades->max('piso');
|
||||
if ($max_piso < $piso) {
|
||||
$max_piso = $piso;
|
||||
}
|
||||
}
|
||||
return $max_piso;
|
||||
}
|
||||
public function m2Construidos()
|
||||
{
|
||||
$total = 0;
|
||||
$unidades = $this->unidades;
|
||||
foreach ($unidades as $unidad) {
|
||||
$total += $unidad->m2->total() * $unidad->unidades->count();
|
||||
}
|
||||
return $total;
|
||||
}
|
||||
public function tipoUnidades()
|
||||
{
|
||||
return (!$this->unidades->isEmpty() and $this->unidades[0]->tipo->descripcion == 'departamento');
|
||||
}
|
||||
public function ventas()
|
||||
{
|
||||
$ventas = [];
|
||||
foreach ($this->unidades as $up) {
|
||||
foreach ($up->unidades as $u) {
|
||||
if (isset($u->propiedad)) {
|
||||
$ventas->add($u->propiedad->venta);
|
||||
}
|
||||
}
|
||||
}
|
||||
$ventas = sort($ventas, function($a, $b) {
|
||||
return $a->propiedad->unidadPrincipal->numeracion - $b->propiedad->unidadPrincipal->numeracion;
|
||||
});
|
||||
return $ventas;
|
||||
}
|
||||
public function ventasActivas()
|
||||
{
|
||||
$ventas = $this->ventas();
|
||||
$output = [];
|
||||
foreach ($ventas as $venta) {
|
||||
$estado = $venta->ultimoEstado()->estado->descripcion;
|
||||
if ($estado == 'promesado' or $estado == 'escriturado' or $estado == 'entregado') {
|
||||
$output []= $venta;
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
public function pVendido()
|
||||
{
|
||||
return $this->ventasActivas()->count() / $this->unidadesPrincipales();
|
||||
}
|
||||
public function m2Vendidos()
|
||||
{
|
||||
$ventas = $this->ventasActivas();
|
||||
$sum = 0;
|
||||
foreach ($ventas as $venta) {
|
||||
$sum += $venta->propiedad->unidadPrincipal->unidadProyecto->m2->vendibles();
|
||||
}
|
||||
return $sum;
|
||||
}
|
||||
}
|
27
src/nuevo/Proyecto/ProyectoParticipe.php
Normal file
27
src/nuevo/Proyecto/ProyectoParticipe.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Proyecto;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property Proyecto proyecto_id
|
||||
* @property Participe participe_rut
|
||||
* @property double participacion
|
||||
*
|
||||
*/
|
||||
class ProyectoParticipe extends NewModel
|
||||
{
|
||||
protected static $_table = 'proyecto_participes';
|
||||
|
||||
public function proyecto()
|
||||
{
|
||||
$this->belongsTo(Proyecto::class, 'proyecto_id')->findOne();
|
||||
}
|
||||
public function participe()
|
||||
{
|
||||
$this->belongsTo(Participe::class, 'participe_rut', 'rut')->findOne();
|
||||
}
|
||||
}
|
75
src/nuevo/Proyecto/Tema.php
Normal file
75
src/nuevo/Proyecto/Tema.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Proyecto;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
use Incoviba\old\Proyecto\Proyecto as P;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int $id
|
||||
* @property Proyecto $proyecto_id
|
||||
* @property string texto
|
||||
* @property DateTime inicio
|
||||
* @property DateTime cierre
|
||||
*
|
||||
*/
|
||||
class Tema extends NewModel
|
||||
{
|
||||
protected static $_table = 'temas';
|
||||
|
||||
public function proyecto()
|
||||
{
|
||||
$proyecto = $this->belongsTo(Proyecto::class)->findOne();
|
||||
if ($proyecto) {
|
||||
return $proyecto;
|
||||
}
|
||||
return $this->belongsTo(P::class)->findOne();
|
||||
}
|
||||
public function inicio()
|
||||
{
|
||||
return Carbon::parse($this->inicio, config('app.timezone'));
|
||||
}
|
||||
public function cierre()
|
||||
{
|
||||
return Carbon::parse($this->cierre, config('app.timezone'));
|
||||
}
|
||||
public function texto()
|
||||
{
|
||||
$text = $this->texto;
|
||||
$text = explode("\n", $text);
|
||||
foreach ($text as &$line) {
|
||||
$line = trim(rtrim($line, '.')) . '.';
|
||||
if ($line != ltrim($line, '-')) {
|
||||
$line = ' ' . $line;
|
||||
}
|
||||
}
|
||||
$text = implode('<br />', $text);
|
||||
|
||||
preg_match_all('/\[\[.*\]\]/', $text, $matches);
|
||||
$search = [];
|
||||
$replace = [];
|
||||
if (count($matches[0]) > 0) {
|
||||
foreach ($matches[0] as $match) {
|
||||
$search []= $match;
|
||||
list($model, $where, $value) = explode(':', str_replace(['[',']'], ['', ''], $match));
|
||||
$class = '\\Incoviba\\old\\' . $model;
|
||||
$obj = model($class)->where($where, $value)->findOne();
|
||||
|
||||
$str = $value;
|
||||
if ($obj->venta()) {
|
||||
$str = '<a href="';
|
||||
$str .= url('', ['p' => 'ventas', 'a' => 'show', 'venta' => $obj->venta()->id]);
|
||||
$str .= '">' . $value . '</a>';
|
||||
}
|
||||
$replace []= $str;
|
||||
}
|
||||
}
|
||||
|
||||
$text = str_replace($search, $replace, $text);
|
||||
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
?>
|
28
src/nuevo/Proyecto/TipoEstadoProyecto.php
Normal file
28
src/nuevo/Proyecto/TipoEstadoProyecto.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Proyecto;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property string descripcion
|
||||
* @property int orden
|
||||
* @property Etapa etapa_id
|
||||
*
|
||||
*/
|
||||
class TipoEstadoProyecto extends NewModel
|
||||
{
|
||||
protected static $_table = 'tipo_estado_proyectos';
|
||||
|
||||
public function etapa()
|
||||
{
|
||||
return $this->belongsTo(Etapa::class, 'etapa_id')->findOne();
|
||||
}
|
||||
|
||||
public function estados()
|
||||
{
|
||||
return $this->hasMany(EstadoProyecto::class, 'estado_id')->findMany();
|
||||
}
|
||||
}
|
21
src/nuevo/Proyecto/TipoUnidad.php
Normal file
21
src/nuevo/Proyecto/TipoUnidad.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Proyecto;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property string descripcion
|
||||
*
|
||||
*/
|
||||
class TipoUnidad extends NewModel
|
||||
{
|
||||
protected static $_table = 'tipo_unidades';
|
||||
|
||||
public function unidades()
|
||||
{
|
||||
return $this->hasMany(UnidadProyecto::class, 'tipo_id')->findMany();
|
||||
}
|
||||
}
|
50
src/nuevo/Proyecto/UnidadProyecto.php
Normal file
50
src/nuevo/Proyecto/UnidadProyecto.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Proyecto;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
use Incoviba\nuevo\Common\M2;
|
||||
use Incoviba\nuevo\Venta\Unidad;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property Proyecto proyecto_id
|
||||
* @property TipoUnidad tipo_id
|
||||
* @property string nombre
|
||||
* @property string tipologia
|
||||
* @property M2 m2_id
|
||||
* @property string descripcion
|
||||
*
|
||||
*/
|
||||
class UnidadProyecto extends NewModel
|
||||
{
|
||||
protected static $_table = 'unidad_proyectos';
|
||||
|
||||
public function proyecto()
|
||||
{
|
||||
return $this->belongsTo(Proyecto::class, 'proyecto_id')->findOne();
|
||||
}
|
||||
public function m2()
|
||||
{
|
||||
return $this->belongsTo(M2::class, 'm2_id')->findOne();
|
||||
}
|
||||
public function tipo()
|
||||
{
|
||||
return $this->belongsTo(TipoUnidad::class, 'tipo_id')->findOne();
|
||||
}
|
||||
public function unidades()
|
||||
{
|
||||
return $this->hasMany(Unidad::class, 'unidad_proyecto_id')->findMany();
|
||||
}
|
||||
public function orientaciones()
|
||||
{
|
||||
$orientaciones = [];
|
||||
foreach ($this->unidades as $unidad) {
|
||||
if (array_search($unidad->orientacion, $orientaciones) === false) {
|
||||
$orientaciones []= $unidad->orientacion;
|
||||
}
|
||||
}
|
||||
return $orientaciones;
|
||||
}
|
||||
}
|
59
src/nuevo/Venta/Cierre.php
Normal file
59
src/nuevo/Venta/Cierre.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
use Incoviba\nuevo\Inmobiliaria\Agente;
|
||||
use Carbon\Carbon;
|
||||
use Incoviba\nuevo\Proyecto\Proyecto;
|
||||
use Incoviba\Common\Definition\hasEstado;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int $id
|
||||
* @property Proyecto $proyecto_id
|
||||
* @property Agente $agente_id
|
||||
* @property Propietario $propietario_rut
|
||||
* @property Reserva $reserva_id
|
||||
* @property date $fecha
|
||||
* @property double $valor
|
||||
* @property double $pie
|
||||
* @property double $credito
|
||||
*
|
||||
*/
|
||||
class Cierre extends NewModel
|
||||
{
|
||||
use hasEstado;
|
||||
|
||||
protected static $_table = 'cierres';
|
||||
|
||||
public function proyecto()
|
||||
{
|
||||
return $this->belongsTo(Proyecto::class, 'proyecto_id')->findOne();
|
||||
}
|
||||
public function agente()
|
||||
{
|
||||
return $this->belongsTo(Agente::class, 'agente_id')->findOne();
|
||||
}
|
||||
public function propietario()
|
||||
{
|
||||
return $this->belongsTo(Propietario::class, 'propietario_rut')->findOne();
|
||||
}
|
||||
public function reserva()
|
||||
{
|
||||
return $this->belongsTo(Reserva::class, 'reserva_id')->findOne();
|
||||
}
|
||||
public function fecha()
|
||||
{
|
||||
return Carbon::parse($this->fecha, config('app.timezone'));
|
||||
}
|
||||
public function pie($type = 'ufs')
|
||||
{
|
||||
if ($type == 'ufs') {
|
||||
return $this->pie;
|
||||
}
|
||||
$uf = uf($this->fecha());
|
||||
return $this->pie * $uf->uf->value;
|
||||
}
|
||||
}
|
||||
?>
|
23
src/nuevo/Venta/Comentario.php
Normal file
23
src/nuevo/Venta/Comentario.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property Venta venta_id
|
||||
* @property string texto
|
||||
* @property boolean estado
|
||||
*
|
||||
*/
|
||||
class Comentario extends NewModel
|
||||
{
|
||||
protected static $_table = 'comentarios';
|
||||
|
||||
public function venta()
|
||||
{
|
||||
return $this->belongsTo(Venta::class, 'venta_id')->findOne();
|
||||
}
|
||||
}
|
27
src/nuevo/Venta/Cuota.php
Normal file
27
src/nuevo/Venta/Cuota.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property Pie pie_id
|
||||
* @property Pago pago_id
|
||||
* @property int numero
|
||||
*
|
||||
*/
|
||||
class Cuota extends NewModel
|
||||
{
|
||||
protected static $_table = 'cuotas';
|
||||
|
||||
public function pie()
|
||||
{
|
||||
return $this->belongsTo(Pie::class, 'pie_id')->findOne();
|
||||
}
|
||||
public function pago()
|
||||
{
|
||||
return $this->belongsTo(Pago::class, 'pago_id')->findOne();
|
||||
}
|
||||
}
|
47
src/nuevo/Venta/Entrega.php
Normal file
47
src/nuevo/Venta/Entrega.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
use Incoviba\Common\Definition\hasEstado;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property Venta venta_id
|
||||
*
|
||||
*/
|
||||
class Entrega extends NewModel
|
||||
{
|
||||
use hasEstado;
|
||||
|
||||
protected static $_table = 'entregas';
|
||||
|
||||
public function venta()
|
||||
{
|
||||
return $this->belongs_to(Venta::class, 'venta_id')->findOne();
|
||||
}
|
||||
|
||||
public function fondos()
|
||||
{
|
||||
return $this->has_many_through(Pago::class, FondoEntrega::class, 'entrega_id', 'pago_id')->findMany();
|
||||
}
|
||||
public function mediciones()
|
||||
{
|
||||
return $this->has_many_through(Medicion::class, MedicionEntrega::class, 'entrega_id', 'medicion_id')->findMany();
|
||||
}
|
||||
public function observaciones()
|
||||
{
|
||||
return $this->has_many_through(Observacion::class, EntregaObservacion::class, 'entrega_id', 'observacion_id')->findMany();
|
||||
}
|
||||
public function observacionesPendientes()
|
||||
{
|
||||
return $this->has_many_through(Observacion::class, EntregaObservacion::class, 'entrega_id', 'observacion_id')
|
||||
->select('observaciones.*')
|
||||
->rawJoin('JOIN (SELECT e1.* FROM (SELECT MAX(id) AS id, observacion_id FROM estado_observaciones GROUP BY observacion_id) e0 JOIN estado_observaciones e1 ON e1.id = e0.id)', ['ep.observacion_id', '=', 'observaciones.id'], 'ep')
|
||||
->leftOuterJoin('tipo_estado_observaciones', ['tipo_estado_observaciones.id', '=', 'ep.tipo_estado_observacion_id'])
|
||||
->where('tipo_estado_observaciones.descripcion', 'ingresada')
|
||||
->findMany();
|
||||
}
|
||||
}
|
||||
?>
|
26
src/nuevo/Venta/EstadoCierre.php
Normal file
26
src/nuevo/Venta/EstadoCierre.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewEstado;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property Cierre $cierre_id
|
||||
* @property TipoEstadoCierre $estado_id
|
||||
*
|
||||
*/
|
||||
class EstadoCierre extends NewEstado
|
||||
{
|
||||
protected static $_table = 'estado_cierres';
|
||||
|
||||
public function cierre()
|
||||
{
|
||||
return $this->belongsTo(Cierre::class)->findOne();
|
||||
}
|
||||
public function estado()
|
||||
{
|
||||
return $this->belongsTo(TipoEstadoCierre::class)->findOne();
|
||||
}
|
||||
}
|
||||
?>
|
26
src/nuevo/Venta/EstadoObservacion.php
Normal file
26
src/nuevo/Venta/EstadoObservacion.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewEstado;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property Observacion observacion_id
|
||||
* @property TipoEstadoObservacion tipo_estado_observacion_id
|
||||
*
|
||||
*/
|
||||
class EstadoObservacion extends NewEstado
|
||||
{
|
||||
protected static $_table = 'estado_observaciones';
|
||||
|
||||
public function observacion()
|
||||
{
|
||||
return $this->belongs_to(Observacion::class, 'observacion_id')->findOne();
|
||||
}
|
||||
public function tipo()
|
||||
{
|
||||
return $this->belongs_to(TipoEstadoObservacion::class, 'tipo_estado_observacion_id')->findOne();
|
||||
}
|
||||
}
|
||||
?>
|
25
src/nuevo/Venta/EstadoPago.php
Normal file
25
src/nuevo/Venta/EstadoPago.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewEstado;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property Pago pago_id
|
||||
* @property TipoEstadoPago estado_id
|
||||
*
|
||||
*/
|
||||
class EstadoPago extends NewEstado
|
||||
{
|
||||
protected static $_table = 'estado_pagos';
|
||||
|
||||
public function pago()
|
||||
{
|
||||
return $this->belongsTo(Pago::class, 'pago_id')->findOne();
|
||||
}
|
||||
public function estado()
|
||||
{
|
||||
return $this->belongsTo(TipoEstadoPago::class, 'estado_id')->findOne();
|
||||
}
|
||||
}
|
27
src/nuevo/Venta/EstadoPostventa.php
Normal file
27
src/nuevo/Venta/EstadoPostventa.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Incoviba\Common\Alias\NewEstado;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property Postventa postventa_id
|
||||
* @property TipoEstadoPostventa tipo_estado_postventa_id
|
||||
*
|
||||
*/
|
||||
class EstadoPostventa extends NewEstado
|
||||
{
|
||||
protected static $_table = 'estado_postventas';
|
||||
|
||||
public function postventa()
|
||||
{
|
||||
return $this->belongs_to(Postventa::class, 'postventa_id')->findOne();
|
||||
}
|
||||
public function tipo()
|
||||
{
|
||||
return $this->belongs_to(TipoEstadoPostventa::class, 'tipo_estado_postventa_id')->findOne();
|
||||
}
|
||||
}
|
||||
?>
|
25
src/nuevo/Venta/EstadoVenta.php
Normal file
25
src/nuevo/Venta/EstadoVenta.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewEstado;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property Venta venta_id
|
||||
* @property TipoEstadoVenta estado_id
|
||||
*
|
||||
*/
|
||||
class EstadoVenta extends NewEstado
|
||||
{
|
||||
protected static $_table = 'estado_ventas';
|
||||
|
||||
public function venta()
|
||||
{
|
||||
return $this->belongsTo(Venta::class, 'venta_id')->findOne();
|
||||
}
|
||||
public function estado()
|
||||
{
|
||||
return $this->belongsTo(TipoEstadoVenta::class, 'estado_id')->findOne();
|
||||
}
|
||||
}
|
31
src/nuevo/Venta/FondoVenta.php
Normal file
31
src/nuevo/Venta/FondoVenta.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property Venta venta_id
|
||||
* @property TipoFondo tipo_id
|
||||
* @property Pago pago_id
|
||||
*
|
||||
*/
|
||||
class FondoVenta extends NewModel
|
||||
{
|
||||
protected static $_table = 'fondo_ventas';
|
||||
|
||||
public function venta()
|
||||
{
|
||||
return $this->belongs_to(Venta::class, 'venta_id')->findOne();
|
||||
}
|
||||
public function tipo()
|
||||
{
|
||||
return $this->belongs_to(TipoFondo::class, 'tipo_id')->findOne();
|
||||
}
|
||||
public function pago()
|
||||
{
|
||||
return $this->belongs_to(Pago::class, 'pago_id')->findOne();
|
||||
}
|
||||
}
|
35
src/nuevo/Venta/FormaPago.php
Normal file
35
src/nuevo/Venta/FormaPago.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property Pie pie_id
|
||||
* @property Pago escritura_id
|
||||
* @property Pago credito_id
|
||||
* @property Pago subsidio_id
|
||||
*
|
||||
*/
|
||||
class FormaPago extends NewModel
|
||||
{
|
||||
protected static $_table = 'forma_pago';
|
||||
|
||||
public function pie()
|
||||
{
|
||||
return $this->belongsTo(Pie::class, 'pie_id')->findOne();
|
||||
}
|
||||
public function escritura()
|
||||
{
|
||||
return $this->belongsTo(Pago::class, 'escritura_id')->findOne();
|
||||
}
|
||||
public function credito()
|
||||
{
|
||||
return $this->belongsTo(Pago::class, 'credito_id')->findOne();
|
||||
}
|
||||
public function subsidio()
|
||||
{
|
||||
return $this->belongs_to(Subsidio::class, 'subsidio_id')->findOne();
|
||||
}
|
||||
}
|
24
src/nuevo/Venta/Medicion.php
Normal file
24
src/nuevo/Venta/Medicion.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property TipoMedicion tipo_medicion_id
|
||||
* @property double valor
|
||||
* @property Date fecha
|
||||
*
|
||||
*/
|
||||
class Medicion extends NewModel
|
||||
{
|
||||
protected static $_table = 'mediciones';
|
||||
|
||||
public function tipoMedicion()
|
||||
{
|
||||
return $this->belongs_to(TipoMedicion::class, 'tipo_medicion_id')->findOne();
|
||||
}
|
||||
}
|
||||
?>
|
20
src/nuevo/Venta/Observacion.php
Normal file
20
src/nuevo/Venta/Observacion.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel as Model;
|
||||
use Incoviba\Common\Definition\hasEstado;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property string text
|
||||
*
|
||||
*/
|
||||
class Observacion extends Model
|
||||
{
|
||||
use hasEstado;
|
||||
|
||||
protected static $_table = 'observaciones';
|
||||
}
|
||||
?>
|
35
src/nuevo/Venta/Pago.php
Normal file
35
src/nuevo/Venta/Pago.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
use Incoviba\nuevo\Common\Banco;
|
||||
use Incoviba\Common\Definition\hasEstado;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property TipoPago tipo_id
|
||||
* @property string identificador
|
||||
* @property int valor
|
||||
* @property Banco banco_id
|
||||
* @property Date fecha
|
||||
* @property double uf
|
||||
* @property string pagador
|
||||
*
|
||||
*/
|
||||
class Pago extends NewModel
|
||||
{
|
||||
use hasEstado;
|
||||
|
||||
protected static $_table = 'pagos';
|
||||
|
||||
public function tipo()
|
||||
{
|
||||
return $this->belongsTo(TipoPago::class, 'tipo_id')->findOne();
|
||||
}
|
||||
public function banco()
|
||||
{
|
||||
return $this->belongsTo(Banco::class, 'banco_id')->findOne();
|
||||
}
|
||||
}
|
39
src/nuevo/Venta/Pie.php
Normal file
39
src/nuevo/Venta/Pie.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property int cuotas
|
||||
* @property double valor
|
||||
* @property Pie asociado_id
|
||||
* @property double uf
|
||||
*
|
||||
*/
|
||||
class Pie extends NewModel
|
||||
{
|
||||
protected static $_table = 'pies';
|
||||
|
||||
public function asociado()
|
||||
{
|
||||
$pie = $this->belongsTo(Pie::class, 'asociado_id');
|
||||
if ($pie) {
|
||||
return $pie->findOne();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public function Cuotas()
|
||||
{
|
||||
return $this->hasMany(Cuota::class, 'pie_id')->findMany();
|
||||
}
|
||||
public function CuotasPagadas()
|
||||
{
|
||||
return $this->hasMany(Cuota::class, 'pie_id')->filter(function($cuota) {
|
||||
$estado = $cuota->pago->ultimoEstado()->estado->descripcion;
|
||||
return ($estado == 'depositado' or $estado == 'abonado');
|
||||
});
|
||||
}
|
||||
}
|
38
src/nuevo/Venta/Postventa.php
Normal file
38
src/nuevo/Venta/Postventa.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Definition\hasEstado;
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property Venta venta_id
|
||||
*
|
||||
*/
|
||||
class Postventa extends NewModel
|
||||
{
|
||||
use hasEstado;
|
||||
|
||||
protected static $_table = 'postventas';
|
||||
|
||||
public function venta()
|
||||
{
|
||||
return $this->belongs_to(Venta::class, 'venta_id')->findOne();
|
||||
}
|
||||
public function observaciones()
|
||||
{
|
||||
return $this->has_many_through(Observacion::class, PostventaObservacion::class, 'postventa_id', 'observacion_id')->findMany();
|
||||
}
|
||||
public function observacionesPendientes()
|
||||
{
|
||||
return $this->has_many_through(Observacion::class, PostventaObservacion::class, 'postventa_id', 'observacion_id')
|
||||
->select('observaciones.*')
|
||||
->rawJoin('JOIN (SELECT e1.* FROM (SELECT MAX(id) AS id, observacion_id FROM estado_observaciones GROUP BY observacion_id) e0 JOIN estado_observaciones e1 ON e1.id = e0.id)', ['ep.observacion_id', '=', 'observaciones.id'], 'ep')
|
||||
->leftOuterJoin('tipo_estado_observaciones', ['tipo_estado_observaciones.id', '=', 'ep.tipo_estado_observacion_id'])
|
||||
->where('tipo_estado_observaciones.descripcion', 'ingresada')
|
||||
->findMany();
|
||||
}
|
||||
}
|
||||
?>
|
27
src/nuevo/Venta/PostventaObservacion.php
Normal file
27
src/nuevo/Venta/PostventaObservacion.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property Postventa postventa_id
|
||||
* @property Observacion observacion_id
|
||||
*
|
||||
*/
|
||||
class PostventaObservacion extends NewModel
|
||||
{
|
||||
protected $_table = 'postventa_observaciones';
|
||||
|
||||
public function postventa()
|
||||
{
|
||||
return $this->belongs_to(Postventa::class, 'postventa_id')->findOne();
|
||||
}
|
||||
public function observacion()
|
||||
{
|
||||
return $this->belongs_to(Observacion::class, 'observacion_id')->findOne();
|
||||
}
|
||||
}
|
||||
?>
|
27
src/nuevo/Venta/Premio.php
Normal file
27
src/nuevo/Venta/Premio.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property Venta venta_id
|
||||
* @property TipoPremio tipo_id
|
||||
* @property double valor
|
||||
*
|
||||
*/
|
||||
class Premio extends NewModel
|
||||
{
|
||||
protected static $_table = 'premios';
|
||||
|
||||
public function venta()
|
||||
{
|
||||
return $this->belongsTo(Venta::class, 'venta_id')->findOne();
|
||||
}
|
||||
public function tipo()
|
||||
{
|
||||
return $this->belongsTo(TipoPremio::class, 'tipo_id')->findOne();
|
||||
}
|
||||
}
|
30
src/nuevo/Venta/Propiedad.php
Normal file
30
src/nuevo/Venta/Propiedad.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property Unidad unidad_id
|
||||
* @property double valor
|
||||
*
|
||||
*/
|
||||
class Propiedad extends NewModel
|
||||
{
|
||||
protected static $_table = 'propiedades';
|
||||
|
||||
public function unidadPrincipal()
|
||||
{
|
||||
return $this->belongsTo(Unidad::class, 'unidad_id')->findOne();
|
||||
}
|
||||
public function unidades()
|
||||
{
|
||||
return $this->hasMany(UnidadPropiedad::class, 'propiedad_id')->findMany();
|
||||
}
|
||||
public function venta()
|
||||
{
|
||||
return $this->hasMany(Venta::class, 'propiedad_id')->findOne();
|
||||
}
|
||||
}
|
71
src/nuevo/Venta/Propietario.php
Normal file
71
src/nuevo/Venta/Propietario.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
use Incoviba\nuevo\Common\Direccion;
|
||||
use Incoviba\Common\Definition\hasRUT;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property string nombres
|
||||
* @property string apellido_paterno
|
||||
* @property string apellido_materno
|
||||
* @property int direccion_id
|
||||
* @property int telefono
|
||||
* @property Propietario representante_rut
|
||||
* @property Propietario otro_rut
|
||||
*
|
||||
*/
|
||||
class Propietario extends NewModel
|
||||
{
|
||||
use hasRUT;
|
||||
|
||||
protected static $_table = 'propietarios';
|
||||
|
||||
public function direccion()
|
||||
{
|
||||
return $this->belongsTo(Direccion::class, 'direccion_id')->findOne();
|
||||
}
|
||||
public function representante()
|
||||
{
|
||||
$prop = $this->belongsTo(Propietario::class, 'representante_rut', 'rut');
|
||||
if ($prop) {
|
||||
return $prop->findOne();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public function otro()
|
||||
{
|
||||
$prop = $this->belongsTo(Propietario::class, 'otro_rut', 'rut');
|
||||
if ($prop) {
|
||||
return $prop->findOne();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function nombreCompleto()
|
||||
{
|
||||
return implode(' ', [$this->nombres, $this->apellido_paterno, $this->apellido_materno]);
|
||||
}
|
||||
|
||||
public function represntado()
|
||||
{
|
||||
$prop = $this->has_many(Propietario::class, 'representante_rut', 'rut');
|
||||
if ($prop) {
|
||||
return $prop->findOne();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public function ventas()
|
||||
{
|
||||
return $this->hasMany(Venta::class, 'propietario_rut', 'rut')->findMany();
|
||||
}
|
||||
public function articulo()
|
||||
{
|
||||
if ($this->sexo == 'f') {
|
||||
return 'la';
|
||||
}
|
||||
return 'el';
|
||||
}
|
||||
}
|
28
src/nuevo/Venta/ProyectoTipoMedicion.php
Normal file
28
src/nuevo/Venta/ProyectoTipoMedicion.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
use Incoviba\nuevo\Proyecto\Proyecto;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property Proyecto proyecto_id
|
||||
* @property TipoMedicion tipo_medicion_id
|
||||
*
|
||||
*/
|
||||
class ProyectoTipoMedicion extends NewModel
|
||||
{
|
||||
protected static $_table = 'proyecto_tipo_mediciones';
|
||||
|
||||
public function proyecto()
|
||||
{
|
||||
return $this->belongs_to(Proyecto::class, 'proyecto_id')->findOne();
|
||||
}
|
||||
public function tipo()
|
||||
{
|
||||
return $this->belongs_to(TipoMedicion::class, 'tipo_medicion_id')->findOne();
|
||||
}
|
||||
}
|
||||
?>
|
30
src/nuevo/Venta/Reserva.php
Normal file
30
src/nuevo/Venta/Reserva.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int $id
|
||||
* @property Unidad $unidad_id
|
||||
*
|
||||
*/
|
||||
class Reserva extends NewModel
|
||||
{
|
||||
protected static $_table = 'reservas';
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Unidad
|
||||
*/
|
||||
public function unidad()
|
||||
{
|
||||
return $this->belongsTo(Unidad::class, 'unidad_id')->findOne();
|
||||
}
|
||||
public function unidades()
|
||||
{
|
||||
return $this->hasMany(UnidadReserva::class, 'reserva_id')->findMany();
|
||||
}
|
||||
}
|
||||
?>
|
10
src/nuevo/Venta/TipoEstadoCierre.php
Normal file
10
src/nuevo/Venta/TipoEstadoCierre.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewTipo;
|
||||
|
||||
class TipoEstadoCierre extends NewTipo
|
||||
{
|
||||
protected static $_table = 'tipo_estado_cierres';
|
||||
}
|
||||
?>
|
10
src/nuevo/Venta/TipoEstadoObservacion.php
Normal file
10
src/nuevo/Venta/TipoEstadoObservacion.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewTipo;
|
||||
|
||||
class TipoEstadoObservacion extends NewTipo
|
||||
{
|
||||
protected static $_table = 'tipo_estado_observaciones';
|
||||
}
|
||||
?>
|
14
src/nuevo/Venta/TipoEstadoPago.php
Normal file
14
src/nuevo/Venta/TipoEstadoPago.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewTipo;
|
||||
|
||||
class TipoEstadoPago extends NewTipo
|
||||
{
|
||||
protected static $_table = 'tipo_estado_pagos';
|
||||
|
||||
public function estados()
|
||||
{
|
||||
return $this->hasMany(EstadoPago::class, 'estado_id')->findMany();
|
||||
}
|
||||
}
|
17
src/nuevo/Venta/TipoEstadoPostventa.php
Normal file
17
src/nuevo/Venta/TipoEstadoPostventa.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewTipo;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property string descripcion
|
||||
*
|
||||
*/
|
||||
class TipoEstadoPostventa extends NewTipo
|
||||
{
|
||||
protected static $_table = 'tipo_estado_postventas';
|
||||
}
|
||||
?>
|
14
src/nuevo/Venta/TipoEstadoVenta.php
Normal file
14
src/nuevo/Venta/TipoEstadoVenta.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewTipo;
|
||||
|
||||
class TipoEstadoVenta extends NewTipo
|
||||
{
|
||||
protected static $_table = 'tipo_estado_ventas';
|
||||
|
||||
public function estados()
|
||||
{
|
||||
return $this->hasMany(EstadoVenta::class, 'estado_id')->findMany();
|
||||
}
|
||||
}
|
14
src/nuevo/Venta/TipoFondo.php
Normal file
14
src/nuevo/Venta/TipoFondo.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewTipo;
|
||||
|
||||
class TipoFondo extends NewTipo
|
||||
{
|
||||
protected static $_table = 'tipo_fondos';
|
||||
|
||||
public function fondos()
|
||||
{
|
||||
return $this->hasMany(FontoVenta::class, 'tipo_id')->findMany();
|
||||
}
|
||||
}
|
10
src/nuevo/Venta/TipoMedicion.php
Normal file
10
src/nuevo/Venta/TipoMedicion.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewTipo;
|
||||
|
||||
class TipoMedicion extends NewTipo
|
||||
{
|
||||
protected static $_table = 'tipo_mediciones';
|
||||
}
|
||||
?>
|
14
src/nuevo/Venta/TipoPago.php
Normal file
14
src/nuevo/Venta/TipoPago.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewTipo;
|
||||
|
||||
class TipoPago extends NewTipo
|
||||
{
|
||||
protected static $_table = 'tipo_pagos';
|
||||
|
||||
public function pagos()
|
||||
{
|
||||
return $this->hasMany(Pago::class, 'tipo_id')->findMany();
|
||||
}
|
||||
}
|
14
src/nuevo/Venta/TipoPremio.php
Normal file
14
src/nuevo/Venta/TipoPremio.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewTipo;
|
||||
|
||||
class TipoPremio extends NewTipo
|
||||
{
|
||||
protected static $_table = 'tipo_premios';
|
||||
|
||||
public function premios()
|
||||
{
|
||||
return $this->hasMany(Premio::class, 'tipo_id')->findMany();
|
||||
}
|
||||
}
|
47
src/nuevo/Venta/Unidad.php
Normal file
47
src/nuevo/Venta/Unidad.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\nuevo\Proyecto\UnidadProyecto;
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
use Incoviba\nuevo\Inmobiliaria\CuentaContable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property UnidadProyecto unidad_proyecto_id
|
||||
* @property int piso
|
||||
* @property string linea
|
||||
* @property string numeracion
|
||||
* @property string orientacion
|
||||
*
|
||||
*/
|
||||
class Unidad extends NewModel
|
||||
{
|
||||
protected static $_table = 'unidades';
|
||||
|
||||
public function unidadProyecto()
|
||||
{
|
||||
return $this->belongsTo(UnidadProyecto::class, 'unidad_proyecto_id')->findOne();
|
||||
}
|
||||
public function uPropiedad()
|
||||
{
|
||||
$up = $this->hasMany(UnidadPropiedad::class, 'unidad_id');
|
||||
if ($up) {
|
||||
return $up->findOne();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public function propiedad()
|
||||
{
|
||||
$prop = $this->hasMany(Propiedad::class, 'unidad_id');
|
||||
if ($prop) {
|
||||
return $prop->findOne();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public function cuentas()
|
||||
{
|
||||
return $this->belongsTo(CuentaContable::class, 'cuenta_unidades', 'unidad_id', 'cuenta_id')->findMany();
|
||||
}
|
||||
}
|
27
src/nuevo/Venta/UnidadPropiedad.php
Normal file
27
src/nuevo/Venta/UnidadPropiedad.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property Propiedad propiedad_id
|
||||
* @property Unidad unidad_id
|
||||
* @property double valor
|
||||
*
|
||||
*/
|
||||
class UnidadPropiedad extends NewModel
|
||||
{
|
||||
protected static $_table = 'unidad_propiedades';
|
||||
|
||||
public function propiedad()
|
||||
{
|
||||
return $this->belongsTo(Propiedad::class, 'propiedad_id')->findOne();
|
||||
}
|
||||
public function unidad()
|
||||
{
|
||||
return $this->belongsTo(Unidad::class, 'unidad_id')->findOne();
|
||||
}
|
||||
}
|
27
src/nuevo/Venta/UnidadReserva.php
Normal file
27
src/nuevo/Venta/UnidadReserva.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int $id
|
||||
* @property Reserva reserva_id
|
||||
* @property Unidad unidad_id
|
||||
*
|
||||
*/
|
||||
class UnidadReserva extends NewModel
|
||||
{
|
||||
protected static $_table = 'unidad_reservas';
|
||||
|
||||
public function reserva()
|
||||
{
|
||||
return $this->belongsTo(Reserva::class, 'reserva_id')->findOne();
|
||||
}
|
||||
public function unidad()
|
||||
{
|
||||
return $this->belongsTo(Unidad::class, 'unidad_id')->findOne();
|
||||
}
|
||||
}
|
||||
?>
|
104
src/nuevo/Venta/Venta.php
Normal file
104
src/nuevo/Venta/Venta.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
namespace Incoviba\nuevo\Venta;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Incoviba\Common\Alias\NewModel;
|
||||
use Incoviba\nuevo\Inmobiliaria\Agente;
|
||||
use Incoviba\Common\Definition\hasEstado;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Aldarien
|
||||
* @property int id
|
||||
* @property Propietario propietario_rut
|
||||
* @property Propiedad propiedad_id
|
||||
* @property FormaPago forma_pago_id
|
||||
* @property Date fecha_promesa
|
||||
* @property double valor_promesa
|
||||
* @property double uf
|
||||
* @property boolean relacionado
|
||||
* @property Agente agente_id
|
||||
* @property DateTime created_at
|
||||
* @property DateTime updated_at
|
||||
*
|
||||
*/
|
||||
class Venta extends NewModel
|
||||
{
|
||||
use hasEstado;
|
||||
|
||||
protected static $_table = 'ventas';
|
||||
|
||||
public function propietario()
|
||||
{
|
||||
return $this->belongs_to(Propietario::class, 'propietario_rut', 'rut')->findOne();
|
||||
}
|
||||
public function propiedad()
|
||||
{
|
||||
return $this->belongs_to(Propiedad::class, 'propiedad_id')->findOne();
|
||||
}
|
||||
public function formaPago()
|
||||
{
|
||||
return $this->belongs_to(FormaPago::class, 'forma_pago_id')->findOne();
|
||||
}
|
||||
public function agente()
|
||||
{
|
||||
$agente = $this->belongs_to(Agente::class, 'agente_id');
|
||||
if ($agente) {
|
||||
return $agente->findOne();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function valor()
|
||||
{
|
||||
return $this->valor_promesa * $this->uf;
|
||||
}
|
||||
public function proyecto()
|
||||
{
|
||||
return $this->propiedad->unidadPrincipal->unidadProyecto->proyecto();
|
||||
}
|
||||
public function comision()
|
||||
{
|
||||
return $this->agente->comision($this->proyecto->inmobiliaria->rut);
|
||||
}
|
||||
public function ufM2()
|
||||
{
|
||||
if (!$this->agente) {
|
||||
return 0;
|
||||
}
|
||||
return ($this->valor_promesa - $this->premios->sum('valor') - $this->comision() - $this->propiedad->unidades->sum('valor')) / $this->propiedad->unidadPrincipal->unidadProyecto->m2->vendibles();
|
||||
}
|
||||
public function fechaPromesa()
|
||||
{
|
||||
return Carbon::parse($this->fecha_promesa, config('app.timezone'));
|
||||
}
|
||||
|
||||
public function premios()
|
||||
{
|
||||
$premios = $this->has_many(Premio::class, 'venta_id');
|
||||
if ($premios) {
|
||||
return $premios->findMany();
|
||||
}
|
||||
return [];
|
||||
}
|
||||
public function comentarios()
|
||||
{
|
||||
$comentarios = $this->has_many(Comentario::class, 'venta_id');
|
||||
if ($comentarios) {
|
||||
return $comentarios->findMany();
|
||||
}
|
||||
return [];
|
||||
}
|
||||
public function fondos()
|
||||
{
|
||||
return $this->has_many(FondoVenta::class, 'venta_id')->findMany();
|
||||
}
|
||||
public function postventas()
|
||||
{
|
||||
$postventas = $this->has_many(Postventa::class, 'venta_id');
|
||||
if ($postventas) {
|
||||
return $postventas->findMany();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user