Nuevo models
This commit is contained in:
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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user