Optimizaciones y funciones
This commit is contained in:
@ -11,19 +11,16 @@ use Incoviba\Common\Alias\OldModel as Model;
|
||||
* @property string nombre
|
||||
*
|
||||
*/
|
||||
class Banco extends Model
|
||||
{
|
||||
public function nombreCompleto()
|
||||
{
|
||||
$str = '';
|
||||
class Banco extends Model {
|
||||
public function nombreCompleto() {
|
||||
$str = [];
|
||||
switch ($this->nombre) {
|
||||
case 'Estado':
|
||||
case 'Chile':
|
||||
case 'Edwards':
|
||||
$str .= 'Banco ';
|
||||
$str []= 'Banco ';
|
||||
}
|
||||
$str .= $this->nombre;
|
||||
return $str;
|
||||
$str []= $this->nombre;
|
||||
return implode('', $str);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -12,11 +12,13 @@ use Incoviba\Common\Alias\OldModel as Model;
|
||||
* @property Provincia provincia
|
||||
*
|
||||
*/
|
||||
class Comuna extends Model
|
||||
{
|
||||
public function provincia()
|
||||
{
|
||||
return $this->belongs_to(Provincia::class, 'provincia')->findOne();
|
||||
class Comuna extends Model {
|
||||
protected $provincia_obj;
|
||||
public function provincia() {
|
||||
if ($this->provincia_obj === null) {
|
||||
$this->provincia_obj = $this->setRelationship(Provincia::class, 'id', 'provincia')->one();
|
||||
//$this->provincia = $this->childOf(Provincia::class, [Model::SELF_KEY => 'provincia'])->one();
|
||||
}
|
||||
return $this->provincia_obj;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -14,23 +14,26 @@ use Incoviba\Common\Alias\OldModel as Model;
|
||||
* @property Comuna comuna
|
||||
*
|
||||
*/
|
||||
class Direccion extends Model
|
||||
{
|
||||
public function comuna()
|
||||
{
|
||||
return $this->belongs_to(Comuna::class, 'comuna')->findOne();
|
||||
class Direccion extends Model {
|
||||
protected $comuna_obj;
|
||||
public function comuna() {
|
||||
if ($this->comuna_obj === null) {
|
||||
$this->comuna_obj = $this->setRelationship(Comuna::class, 'id', 'comuna')->one();
|
||||
}
|
||||
return $this->comuna_obj;
|
||||
//return $this->belongs_to(Comuna::class, 'comuna')->findOne();
|
||||
}
|
||||
|
||||
public function completa($comuna = false)
|
||||
{
|
||||
$str = $this->calle . ' ' . $this->numero;
|
||||
public function completa($comuna = false) {
|
||||
$str = [$this->calle, ' ', $this->numero];
|
||||
if ($this->extra != '') {
|
||||
$str .= ', ' . $this->extra;
|
||||
$str []= ', ';
|
||||
$str []= $this->extra;
|
||||
}
|
||||
if ($comuna) {
|
||||
$str .= ', ' . $this->comuna()->descripcion;
|
||||
$str []= ', ';
|
||||
$str []= $this->comuna()->descripcion;
|
||||
}
|
||||
return $str;
|
||||
return implode('', $str);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -12,15 +12,21 @@ use Incoviba\Common\Alias\OldModel as Model;
|
||||
* @property Region region
|
||||
*
|
||||
*/
|
||||
class Provincia extends Model
|
||||
{
|
||||
public function region()
|
||||
{
|
||||
return $this->belongsTo(Region::class, 'region')->findOne();
|
||||
class Provincia extends Model {
|
||||
protected $region_obj;
|
||||
public function region() {
|
||||
if ($this->region_obj === null) {
|
||||
$this->region_obj = $this->setRelationship(Region::class, 'id', 'region')->one();
|
||||
}
|
||||
public function comunas()
|
||||
{
|
||||
return $this->hasMany(Comuna::class, 'provincia')->findMany();
|
||||
return $this->region_obj;
|
||||
//return $this->belongsTo(Region::class, 'region')->findOne();
|
||||
}
|
||||
protected $comunas;
|
||||
public function comunas() {
|
||||
if ($this->comunas === null) {
|
||||
$this->comunas = $this->setRelationship(Comuna::class, 'provincia', 'id')->many();
|
||||
}
|
||||
return $this->comunas;
|
||||
//return $this->hasMany(Comuna::class, 'provincia')->findMany();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -13,21 +13,19 @@ use Incoviba\Common\Alias\OldModel as Model;
|
||||
* @property int numeracion
|
||||
*
|
||||
*/
|
||||
class Region extends Model
|
||||
{
|
||||
private $provincias = null;
|
||||
private $comunas = null;
|
||||
class Region extends Model {
|
||||
|
||||
public function provincias()
|
||||
{
|
||||
if ($this->provincias == null) {
|
||||
$this->provincias = $this->hasMany(Provincia::class, 'region')->findMany();
|
||||
protected $provincias;
|
||||
public function provincias() {
|
||||
if ($this->provincias === null) {
|
||||
$this->provincias = $this->setRelationship(Provincia::class, 'region', 'id')->many();
|
||||
//$this->provincias = $this->hasMany(Provincia::class, 'region')->findMany();
|
||||
}
|
||||
return $this->provincias;
|
||||
}
|
||||
public function comunas()
|
||||
{
|
||||
if ($this->comunas == null) {
|
||||
protected $comunas;
|
||||
public function comunas() {
|
||||
if ($this->comunas === null) {
|
||||
$provincias = $this->provincias();
|
||||
$comunas = [];
|
||||
foreach ($provincias as $prov) {
|
||||
@ -41,4 +39,3 @@ class Region extends Model
|
||||
return $this->comunas;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -10,14 +10,21 @@ use Incoviba\old\Common\Banco;
|
||||
* @property Banco $banco
|
||||
* @property string $cuenta
|
||||
*/
|
||||
class Cuenta extends Model
|
||||
{
|
||||
public function inmobiliaria()
|
||||
{
|
||||
return $this->belongsTo(Inmobiliaria::class, 'inmobiliaria', 'rut')->findOne();
|
||||
class Cuenta extends Model {
|
||||
protected $inmobiliaria_obj;
|
||||
public function inmobiliaria() {
|
||||
if ($this->inmobiliaria_obj === null) {
|
||||
$this->inmobiliaria_obj = $this->setRelationship(Inmobiliaria::class, 'rut', 'inmobiliaria')->one();
|
||||
}
|
||||
public function banco()
|
||||
{
|
||||
return $this->belongsTo(Banco::class, 'banco')->findOne();
|
||||
return $this->inmobiliaria_obj;
|
||||
//return $this->belongsTo(Inmobiliaria::class, 'inmobiliaria', 'rut')->findOne();
|
||||
}
|
||||
protected $banco_obj;
|
||||
public function banco() {
|
||||
if ($this->banco_obj === null) {
|
||||
$this->banco_obj = $this->setRelationship(Banco::class, 'id', 'banco')->one();
|
||||
}
|
||||
return $this->banco_obj;
|
||||
//return $this->belongsTo(Banco::class, 'banco')->findOne();
|
||||
}
|
||||
}
|
||||
|
@ -18,38 +18,48 @@ use Incoviba\old\Proyecto\Proyecto;
|
||||
* @property TipoSociedad $sociedad
|
||||
*
|
||||
*/
|
||||
class Inmobiliaria extends Model
|
||||
{
|
||||
class Inmobiliaria extends Model {
|
||||
public static $_id_column = 'rut';
|
||||
|
||||
public function banco()
|
||||
{
|
||||
public function banco() {
|
||||
return $this->cuenta()->banco();
|
||||
//return $this->belongsTo(Banco::class, 'banco')->findOne();
|
||||
}
|
||||
public function proyectos()
|
||||
{
|
||||
return $this->hasMany(Proyecto::class, 'inmobiliaria', 'rut')->orderByAsc('descripcion')->findMany();
|
||||
protected $proyectos;
|
||||
public function proyectos() {
|
||||
if ($this->proyectos === null) {
|
||||
$this->proyectos = $this->setRelationship(Proyecto::class, 'inmobiliaria', 'rut')->sort('descripcion')->many();
|
||||
}
|
||||
public function nombre(bool $tipo = false)
|
||||
{
|
||||
return $this->abreviacion . (($tipo) ? ' ' . $this->sociedad()->abreviacion . '.' : '');
|
||||
return $this->proyectos;
|
||||
//return $this->hasMany(Proyecto::class, 'inmobiliaria', 'rut')->orderByAsc('descripcion')->findMany();
|
||||
}
|
||||
public function rut()
|
||||
{
|
||||
public function nombre(bool $tipo = false) {
|
||||
return implode(' ', [
|
||||
$this->abreviacion,
|
||||
(($tipo) ? $this->sociedad()->abreviacion . '.' : '')
|
||||
]);
|
||||
}
|
||||
public function rut() {
|
||||
return format('rut', $this->rut) . '-' . $this->dv;
|
||||
}
|
||||
protected $sociedad_obj;
|
||||
public function sociedad() {
|
||||
return $this->belongsTo(TipoSociedad::class, 'sociedad')->findOne();
|
||||
if ($this->sociedad_obj === null) {
|
||||
$this->sociedad_obj = $this->setRelationship(TipoSociedad::class, 'id', 'sociedad')->one();
|
||||
}
|
||||
return $this->sociedad_obj;
|
||||
//return $this->belongsTo(TipoSociedad::class, 'sociedad')->findOne();
|
||||
}
|
||||
public function razon(bool $tipo = false, bool $abreviado = false) {
|
||||
return $this->razon . (($tipo) ? ' ' . (($abreviado) ? $this->sociedad()->abreviacion . '.' : $this->sociedad()->descripcion) : '');
|
||||
return implode(' ', [
|
||||
$this->razon,
|
||||
(($tipo) ? (($abreviado) ? $this->sociedad()->abreviacion . '.' : $this->sociedad()->descripcion) : '')
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* $data = ['descripcion', 'calle', 'numero', 'extra', 'comuna']
|
||||
*/
|
||||
public function addProyecto(array $data)
|
||||
{
|
||||
public function addProyecto(array $data) {
|
||||
//$proyecto = model(Proyecto::class)->where('inmobiliaria', $this->rut)->where('descripcion', $data['descripcion'])->findOne();
|
||||
$data = [
|
||||
'inmobiliaria' => $this->rut,
|
||||
@ -65,8 +75,7 @@ class Inmobiliaria extends Model
|
||||
$proyecto->save();
|
||||
}
|
||||
}
|
||||
public function removeProyecto(array $data)
|
||||
{
|
||||
public function removeProyecto(array $data) {
|
||||
$proyecto = (new Factory(Proyecto::class))->where([
|
||||
'inmobiliaria' => $this->rut,
|
||||
'descripcion' => $data['descripcion']
|
||||
@ -75,19 +84,26 @@ class Inmobiliaria extends Model
|
||||
$proyecto->delete();
|
||||
}
|
||||
}
|
||||
public function cuenta()
|
||||
{
|
||||
if (count($this->cuentas()) == 0) {
|
||||
protected $cuenta_obj;
|
||||
public function cuenta() {
|
||||
if ($this->cuenta_obj === null) {
|
||||
$this->cuenta_obj = $this->setRelationship(Cuenta::class, 'inmobiliaria', 'rut')->one();
|
||||
}
|
||||
return $this->cuenta_obj;
|
||||
/*if (count($this->cuentas()) == 0) {
|
||||
return false;
|
||||
}
|
||||
return $this->cuentas()[0];
|
||||
return $this->cuentas()[0];*/
|
||||
}
|
||||
public function cuentas()
|
||||
{
|
||||
return $this->hasMany(Cuenta::class, 'inmobiliaria', 'rut')->findMany();
|
||||
protected $cuentas;
|
||||
public function cuentas() {
|
||||
if ($this->cuentas === null) {
|
||||
$this->cuentas = $this->setRelationship(Cuenta::class, 'inmobiliaria', 'rut')->many();
|
||||
}
|
||||
public function addCuenta(array $data)
|
||||
{
|
||||
return $this->cuentas;
|
||||
//return $this->hasMany(Cuenta::class, 'inmobiliaria', 'rut')->findMany();
|
||||
}
|
||||
public function addCuenta(array $data) {
|
||||
if (!is_numeric($data['banco'])) {
|
||||
$banco = (new Factory(Banco::class))->where(['descripcion' => $data['banco']])->find();
|
||||
$data['banco'] = $banco->id;
|
||||
@ -103,8 +119,7 @@ class Inmobiliaria extends Model
|
||||
$cuenta->save();
|
||||
}
|
||||
}
|
||||
public function removeCuenta(array $data)
|
||||
{
|
||||
public function removeCuenta(array $data) {
|
||||
$cuenta = (new Factory(Cuenta::class))->where(['inmobiliaria' => $this->rut]);
|
||||
if (isset($data['cuenta'])) {
|
||||
$cuenta = $cuenta->where(['cuenta' => $data['cuenta']]);
|
||||
@ -121,8 +136,7 @@ class Inmobiliaria extends Model
|
||||
$cuenta->delete();
|
||||
}
|
||||
}
|
||||
public function modify(array $data)
|
||||
{
|
||||
public function modify(array $data) {
|
||||
$fields = ['rut', 'dv', 'razon', 'abreviacion'];
|
||||
foreach ($data as $column => $value) {
|
||||
if (array_search($column, $fields) !== false) {
|
||||
@ -132,4 +146,3 @@ class Inmobiliaria extends Model
|
||||
$this->cuenta()->modify($data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -10,15 +10,21 @@ use Incoviba\Common\Alias\OldModel as Model;
|
||||
* @property int hijo
|
||||
*
|
||||
*/
|
||||
class RelacionInmobiliarias extends Model
|
||||
{
|
||||
public function padre()
|
||||
{
|
||||
return $this->belongsTo(Inmobiliaria::class, 'padre', 'rut')->findOne();
|
||||
class RelacionInmobiliarias extends Model {
|
||||
protected $padre_obj;
|
||||
public function padre() {
|
||||
if ($this->padre_obj === null) {
|
||||
$this->padre_obj = $this->setRelationship(Inmobiliaria::class, 'rut', 'padre')->one();
|
||||
}
|
||||
public function hijo()
|
||||
{
|
||||
return $this->belongsTo(Inmobiliaria::class, 'hijo', 'rut')->findOne();
|
||||
return $this->padre_obj;
|
||||
//return $this->belongsTo(Inmobiliaria::class, 'padre', 'rut')->findOne();
|
||||
}
|
||||
protected $hijo_obj;
|
||||
public function hijo() {
|
||||
if ($this->hijo_obj === null) {
|
||||
$this->hijo_obj = $this->setRelationship(Inmobiliaria::class, 'rut', 'hijo')->one();
|
||||
}
|
||||
return $this->hijo_obj;
|
||||
//return $this->belongsTo(Inmobiliaria::class, 'hijo', 'rut')->findOne();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -20,22 +20,72 @@ use Incoviba\old\Common\Direccion;
|
||||
* @property string abreviacion
|
||||
*
|
||||
*/
|
||||
class Agente extends Model
|
||||
{
|
||||
public function direccion()
|
||||
{
|
||||
return $this->belongs_to(Direccion::class, 'direccion')->findOne();
|
||||
class Agente extends Model {
|
||||
protected $direccion_obj;
|
||||
public function direccion() {
|
||||
if ($this->direccion_obj === null) {
|
||||
$this->direccion_obj = $this->setRelationship(Direccion::class, 'id', 'direccion')->one();
|
||||
}
|
||||
public function tipo()
|
||||
{
|
||||
return $this->belongs_to(TipoAgente::class, 'tipo')->findOne();
|
||||
return $this->direccion_obj;
|
||||
//return $this->belongs_to(Direccion::class, 'direccion')->findOne();
|
||||
}
|
||||
protected $tipo_obj;
|
||||
public function tipo() {
|
||||
if ($this->tipo_obj === null) {
|
||||
$this->tipo_obj = $this->setRelationship(TipoAgente::class, 'id', 'tipo')->one();
|
||||
}
|
||||
return $this->tipo_obj;
|
||||
//return $this->belongs_to(TipoAgente::class, 'tipo')->findOne();
|
||||
}
|
||||
protected $tipos;
|
||||
public function tipos(int $tipo = 0)
|
||||
{
|
||||
if ($tipo == 0) {
|
||||
if ($this->tipos === null) {
|
||||
$this->tipos = [];
|
||||
}
|
||||
if (!isset($this->tipos[$tipo])) {
|
||||
$this->tipos[$tipo] = $this->setRelationship(AgenteTipo::class, 'id', 'agente');
|
||||
if ($tipo != 0) {
|
||||
$this->tipos[$tipo] = $this->tipos[$tipo]->where(['tipo', $tipo]);
|
||||
}
|
||||
$this->tipos[$tipo];
|
||||
}
|
||||
return $this->tipos[$tipo];
|
||||
|
||||
/*if ($tipo == 0) {
|
||||
return $this->hasMany(AgenteTipo::class, 'agente')->findMany();
|
||||
}
|
||||
return $this->hasMany(AgenteTipo::class, 'agente')->where('tipo', $tipo)->findOne();
|
||||
return $this->hasMany(AgenteTipo::class, 'agente')->where('tipo', $tipo)->findOne();*/
|
||||
}
|
||||
protected $proyectos;
|
||||
public function proyectos() {
|
||||
if ($this->proyectos === null) {
|
||||
$proyectos = [];
|
||||
foreach ($this->tipos() as $tipo) {
|
||||
foreach ($tipo->proyectos() as $proyecto) {
|
||||
$proyectos []= $proyecto->proyecto();
|
||||
}
|
||||
}
|
||||
usort($proyectos, function($a, $b) {
|
||||
return strcmp($a->descripcion, $b->descripcion);
|
||||
});
|
||||
$this->proyectos = $proyectos;
|
||||
}
|
||||
return $this->proyectos;
|
||||
}
|
||||
public function hasProyecto(int $id): bool {
|
||||
$proyectos = $this->proyectos();
|
||||
foreach ($proyectos as $proyecto) {
|
||||
if ($proyecto->id == $id) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public function isOperador(): bool {
|
||||
if ($this->tipos(19)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -7,14 +7,21 @@ use Incoviba\Common\Alias\OldModel as Model;
|
||||
* @property Agente $agente
|
||||
* @property TipoAgente $tipo
|
||||
*/
|
||||
class AgenteTipo extends Model
|
||||
{
|
||||
public function agente()
|
||||
{
|
||||
return $this->belongsTo(Agente::class, 'agente')->findOne();
|
||||
class AgenteTipo extends Model {
|
||||
protected $agente_obj;
|
||||
public function agente() {
|
||||
if ($this->agente_obj === null) {
|
||||
$this->agente_obj = $this->setRelationship(Agente::class, 'id', 'agente')->one();
|
||||
}
|
||||
public function tipo()
|
||||
{
|
||||
return $this->belongsTo(TipoAgente::class, 'tipo')->findOne();
|
||||
return $this->agente_obj;
|
||||
//return $this->belongsTo(Agente::class, 'agente')->findOne();
|
||||
}
|
||||
protected $tipo_obj;
|
||||
public function tipo() {
|
||||
if ($this->tipo_obj === null) {
|
||||
$this->tipo_obj = $this->setRelationship(TipoAgente::class, 'id', 'tipo')->one();
|
||||
}
|
||||
return $this->tipo_obj;
|
||||
//return $this->belongsTo(TipoAgente::class, 'tipo')->findOne();
|
||||
}
|
||||
}
|
@ -14,24 +14,25 @@ use Incoviba\Common\Alias\OldModel as Model;
|
||||
* @property double $uf
|
||||
* @property \DateTime $fecha_pagado
|
||||
*/
|
||||
class AvanceConstruccion extends Model
|
||||
{
|
||||
class AvanceConstruccion extends Model {
|
||||
public static $_table = 'avance_construccion';
|
||||
|
||||
public function proyecto()
|
||||
{
|
||||
return $this->belongsTo(Proyecto::class, 'proyecto')->findOne();
|
||||
protected $proyecto_obj;
|
||||
public function proyecto() {
|
||||
if ($this->proyecto_obj === null) {
|
||||
$this->proyecto_obj = $this->setRelationship(Proyecto::class, 'id', 'proyecto')->one();
|
||||
}
|
||||
public function fecha(\DateTime $fecha = null)
|
||||
{
|
||||
return $this->proyecto_obj;
|
||||
//return $this->belongsTo(Proyecto::class, 'proyecto')->findOne();
|
||||
}
|
||||
public function fecha(\DateTime $fecha = null) {
|
||||
if ($fecha == null) {
|
||||
return Carbon::parse($this->fecha, $this->container->get('settings')->app->timezone);
|
||||
}
|
||||
$this->fecha = $fecha->format('Y-m-d');
|
||||
}
|
||||
protected $pagare;
|
||||
public function pagare()
|
||||
{
|
||||
public function pagare() {
|
||||
if ($this->pagare == null) {
|
||||
$this->pagare = $this->hasMany(Pagare::class, 'estado_pago', 'numero')
|
||||
->where('proyecto', $this->proyecto)
|
||||
@ -40,8 +41,7 @@ class AvanceConstruccion extends Model
|
||||
return $this->pagare;
|
||||
}
|
||||
protected $pagares;
|
||||
public function pagares()
|
||||
{
|
||||
public function pagares() {
|
||||
if ($this->pagares == null) {
|
||||
$this->pagares = $this->hasMany(Pagare::class, 'estado_pago', 'numero')
|
||||
->where('proyecto', $this->proyecto)
|
||||
@ -49,8 +49,7 @@ class AvanceConstruccion extends Model
|
||||
}
|
||||
return $this->pagares;
|
||||
}
|
||||
public function uf()
|
||||
{
|
||||
public function uf() {
|
||||
if ($this->uf == 0) {
|
||||
$uf = $this->container->get('uf')($this->fecha());
|
||||
if ($uf->total > 0) {
|
||||
@ -60,22 +59,19 @@ class AvanceConstruccion extends Model
|
||||
}
|
||||
return $this->uf;
|
||||
}
|
||||
public function pagado($tipo = 'ufs')
|
||||
{
|
||||
public function pagado($tipo = 'ufs') {
|
||||
if ($tipo == 'ufs') {
|
||||
return $this->pagado / $this->uf();
|
||||
}
|
||||
return $this->pagado;
|
||||
}
|
||||
public function fechaPago(\DateTime $fecha = null)
|
||||
{
|
||||
public function fechaPago(\DateTime $fecha = null) {
|
||||
if ($fecha == null) {
|
||||
return Carbon::parse($this->fecha_pagado, $this->container->get('settings')->app->timezone);
|
||||
}
|
||||
$this->fecha_pagado = $fecha->format('Y-m-d');
|
||||
}
|
||||
public function edit(array $data)
|
||||
{
|
||||
public function edit(array $data) {
|
||||
foreach ($data as $column => $value) {
|
||||
if (isset($this->$column) and $this->$column != $value) {
|
||||
$this->$column = $value;
|
||||
|
@ -17,19 +17,29 @@ use Incoviba\Common\Alias\OldModel as Model;
|
||||
* @property string glosa
|
||||
*
|
||||
*/
|
||||
class Cobro extends Model
|
||||
{
|
||||
public function proyecto()
|
||||
{
|
||||
return $this->has_one(Proyecto::class);
|
||||
class Cobro extends Model {
|
||||
protected $proyecto_obj;
|
||||
public function proyecto() {
|
||||
if ($this->proyecto_obj === null) {
|
||||
$this->proyecto_obj = $this->setRelationship(Proyecto::class, 'id', 'proyecto')->one();
|
||||
}
|
||||
public function agente()
|
||||
{
|
||||
return $this->has_one(Agente::class);
|
||||
return $this->proyecto_obj;
|
||||
//return $this->has_one(Proyecto::class);
|
||||
}
|
||||
public function tipo()
|
||||
{
|
||||
return $this->has_one(TipoCobro::class);
|
||||
protected $agente_obj;
|
||||
public function agente() {
|
||||
if ($this->agente_obj === null) {
|
||||
$this->agente_obj = $this->setRelationship(Agente::class, 'id', 'agente')->one();
|
||||
}
|
||||
return $this->agente_obj;
|
||||
//return $this->has_one(Agente::class);
|
||||
}
|
||||
protected $tipo_obj;
|
||||
public function tipo() {
|
||||
if ($this->tipo_obj === null) {
|
||||
$this->tipo_obj = $this->setRelationship(TipoCobro::class, 'id', 'tipo')->one();
|
||||
}
|
||||
return $this->tipo_obj;
|
||||
//return $this->has_one(TipoCobro::class);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -29,8 +29,7 @@ use Incoviba\old\Venta\Venta;
|
||||
* @property int $subterraneos
|
||||
*
|
||||
*/
|
||||
class Proyecto extends Model
|
||||
{
|
||||
class Proyecto extends Model {
|
||||
protected $unidades;
|
||||
protected $valores;
|
||||
protected $tipo_unidades;
|
||||
@ -44,16 +43,23 @@ class Proyecto extends Model
|
||||
protected $cuotas;
|
||||
protected $superficies;
|
||||
|
||||
public function inmobiliaria()
|
||||
{
|
||||
return $this->belongs_to(Inmobiliaria::class, 'inmobiliaria', 'rut')->findOne();
|
||||
protected $inmobiliaria_obj;
|
||||
public function inmobiliaria() {
|
||||
if ($this->inmobiliaria_obj === null) {
|
||||
$this->inmobiliaria_obj = $this->setRelationship(Inmobiliaria::class, 'rut', 'inmobiliaria')->one();
|
||||
}
|
||||
public function direccion()
|
||||
{
|
||||
return $this->belongs_to(Direccion::class, 'direccion')->findOne();
|
||||
return $this->inmobiliaria_obj;
|
||||
//return $this->belongs_to(Inmobiliaria::class, 'inmobiliaria', 'rut')->findOne();
|
||||
}
|
||||
public function unidades($tipo = null)
|
||||
{
|
||||
protected $direccion_obj;
|
||||
public function direccion() {
|
||||
if ($this->direccion_obj === null) {
|
||||
$this->direccion_obj = $this->setRelationship(Direccion::class, 'id', 'direccion')->one();
|
||||
}
|
||||
return $this->direccion_obj;
|
||||
//return $this->belongs_to(Direccion::class, 'direccion')->findOne();
|
||||
}
|
||||
public function unidades($tipo = null) {
|
||||
if ($tipo == null) {
|
||||
if (!isset($this->unidades) or !isset($this->unidades->total)) {
|
||||
$unidades = [];
|
||||
@ -97,8 +103,7 @@ class Proyecto extends Model
|
||||
}
|
||||
return $this->unidades->{$tipo};
|
||||
}
|
||||
public function unidadesDisponibles($tipo = null)
|
||||
{
|
||||
public function unidadesDisponibles($tipo = null) {
|
||||
switch ($tipo) {
|
||||
case 1:
|
||||
case 'departamento':
|
||||
@ -188,12 +193,15 @@ class Proyecto extends Model
|
||||
}
|
||||
return $this->unidades->disponibles->{$tipo};
|
||||
}
|
||||
public function proyectoTipoUnidades()
|
||||
{
|
||||
return $this->hasMany(ProyectoTipoUnidad::class, 'proyecto')->orderByAsc('tipo')->findMany();
|
||||
protected $ptus;
|
||||
public function proyectoTipoUnidades() {
|
||||
if ($this->ptus === null) {
|
||||
$this->ptus = $this->setRelationship(ProyectoTipoUnidad::class, 'proyecto', 'id')->sort(['tipo', 'asc'])->many();
|
||||
}
|
||||
public function tipoUnidades()
|
||||
{
|
||||
return $this->ptus;
|
||||
//return $this->hasMany(ProyectoTipoUnidad::class, 'proyecto')->orderByAsc('tipo')->findMany();
|
||||
}
|
||||
public function tipoUnidades() {
|
||||
if (!isset($this->tipos_unidades)) {
|
||||
$tipos = \Model::factory(TipoUnidad::class)
|
||||
->select('tipo_unidad.*')
|
||||
@ -207,8 +215,7 @@ class Proyecto extends Model
|
||||
}
|
||||
return $this->tipos_unidades;
|
||||
}
|
||||
public function ventas($order = 'departamento')
|
||||
{
|
||||
public function ventas($order = 'departamento') {
|
||||
if (!isset($this->ventas)) {
|
||||
$ventas = model(Venta::class)
|
||||
->select('venta.*')
|
||||
@ -236,9 +243,8 @@ class Proyecto extends Model
|
||||
return $this->ventas;
|
||||
}
|
||||
protected $resciliaciones;
|
||||
public function resciliaciones()
|
||||
{
|
||||
if ($this->resciliaciones == null) {
|
||||
public function resciliaciones() {
|
||||
if ($this->resciliaciones === null) {
|
||||
$resciliaciones = model(Venta::class)
|
||||
->select('venta.*')
|
||||
->join('propiedad', ['propiedad.id', '=', 'venta.propiedad'])
|
||||
@ -258,8 +264,7 @@ class Proyecto extends Model
|
||||
}
|
||||
return $this->resciliaciones;
|
||||
}
|
||||
public function escrituras()
|
||||
{
|
||||
public function escrituras() {
|
||||
if (!isset($escrituras)) {
|
||||
$ventas = model(Venta::class)
|
||||
->select('venta.*')
|
||||
@ -279,8 +284,7 @@ class Proyecto extends Model
|
||||
}
|
||||
return $this->escrituras;
|
||||
}
|
||||
public function entregas()
|
||||
{
|
||||
public function entregas() {
|
||||
if (!isset($this->entregas)) {
|
||||
$entregas = [];
|
||||
$escrituras = $this->escrituras();
|
||||
@ -306,12 +310,15 @@ class Proyecto extends Model
|
||||
}
|
||||
return $this->entregas;
|
||||
}
|
||||
public function estados()
|
||||
{
|
||||
return $this->has_many(EstadoProyecto::class, 'proyecto')->orderByAsc('fecha')->findMany();
|
||||
protected $estados;
|
||||
public function estados() {
|
||||
if ($this->estados === null) {
|
||||
$this->estados = $this->setRelationship(EstadoProyecto::class, 'proyecto', 'id')->sort(['fecha', 'asc'])->many();
|
||||
}
|
||||
public function estado()
|
||||
{
|
||||
return $this->estados;
|
||||
//return $this->has_many(EstadoProyecto::class, 'proyecto')->orderByAsc('fecha')->findMany();
|
||||
}
|
||||
public function estado() {
|
||||
if (!isset($this->estado)) {
|
||||
$id = $this->has_many(EstadoProyecto::class, 'proyecto')->max('id');
|
||||
$this->estado = $this->has_many(EstadoProyecto::class, 'proyecto')->findOne($id);
|
||||
@ -319,13 +326,16 @@ class Proyecto extends Model
|
||||
}
|
||||
return $this->estado;
|
||||
}
|
||||
public function avances()
|
||||
{
|
||||
return $this->hasMany(AvanceConstruccion::class, 'proyecto')->orderByAsc('fecha')->findMany();
|
||||
protected $avances;
|
||||
public function avances() {
|
||||
if ($this->avances === null) {
|
||||
$this->avances = $this->setRelationship(AvanceConstruccion::class, 'proyecto', 'id')->sort(['fecha', 'asc'])->many();
|
||||
}
|
||||
return $this->avances;
|
||||
//return $this->hasMany(AvanceConstruccion::class, 'proyecto')->orderByAsc('fecha')->findMany();
|
||||
}
|
||||
protected $avance;
|
||||
public function avance()
|
||||
{
|
||||
public function avance() {
|
||||
if ($this->avance == null and $this->avances()) {
|
||||
$avance = array_reduce($this->avances(), function($carry, $item) {
|
||||
return ($carry += $item->avance);
|
||||
@ -335,8 +345,7 @@ class Proyecto extends Model
|
||||
return $this->avance;
|
||||
}
|
||||
protected $inicio;
|
||||
public function inicio()
|
||||
{
|
||||
public function inicio() {
|
||||
if (!isset($this->inicio) or $this->inicio == null) {
|
||||
$id = $this->has_many(EstadoProyecto::class, 'proyecto')->min('id');
|
||||
$this->inicio = $this->has_many(EstadoProyecto::class, 'proyecto')->findOne($id);
|
||||
@ -344,8 +353,7 @@ class Proyecto extends Model
|
||||
}
|
||||
return $this->inicio;
|
||||
}
|
||||
public function valores()
|
||||
{
|
||||
public function valores() {
|
||||
if (!isset($this->valores)) {
|
||||
$ventas = $this->ventas();
|
||||
|
||||
@ -473,8 +481,7 @@ class Proyecto extends Model
|
||||
|
||||
return $this->valores;
|
||||
}
|
||||
public function agentes()
|
||||
{
|
||||
public function agentes() {
|
||||
if (!isset($this->agentes)) {
|
||||
$this->agentes = \Model::factory(Agente::class)
|
||||
->select('agente.*')
|
||||
@ -485,8 +492,7 @@ class Proyecto extends Model
|
||||
}
|
||||
return $this->agentes;
|
||||
}
|
||||
public function operadores()
|
||||
{
|
||||
public function operadores() {
|
||||
if (!isset($this->operadores)) {
|
||||
$this->operadores = \Model::factory(Agente::class)
|
||||
->select('agente.*')
|
||||
@ -501,8 +507,7 @@ class Proyecto extends Model
|
||||
}
|
||||
return $this->operadores;
|
||||
}
|
||||
public function operadoresVigentes()
|
||||
{
|
||||
public function operadoresVigentes() {
|
||||
return $this->hasMany(ProyectoAgente::class, 'proyecto')
|
||||
->select('proyecto_agente.*')
|
||||
->join('agente_tipo', ['agente_tipo.id', '=', 'proyecto_agente.agente'])
|
||||
@ -511,8 +516,7 @@ class Proyecto extends Model
|
||||
->where('ep.tipo', 1)
|
||||
->findMany();
|
||||
}
|
||||
public function promociones()
|
||||
{
|
||||
public function promociones() {
|
||||
if (!isset($this->promociones)) {
|
||||
$this->promociones = \Model::factory(Promocion::class)
|
||||
->select('promocion.*')
|
||||
@ -527,8 +531,7 @@ class Proyecto extends Model
|
||||
}
|
||||
return $this->promociones;
|
||||
}
|
||||
public function pisos()
|
||||
{
|
||||
public function pisos() {
|
||||
if ($this->pisos == 0) {
|
||||
$pisos = $this->has_many(Unidad::class, 'proyecto')->where('tipo', 1)->max('piso');
|
||||
if (!$pisos) {
|
||||
@ -539,8 +542,7 @@ class Proyecto extends Model
|
||||
}
|
||||
return $this->pisos;
|
||||
}
|
||||
public function cuotasHoy()
|
||||
{
|
||||
public function cuotasHoy() {
|
||||
if (!isset($this->cuotas) or !isset($this->cuotas->hoy)) {
|
||||
$cuotas = [];
|
||||
if (isset($this->cuotas)) {
|
||||
@ -563,8 +565,7 @@ class Proyecto extends Model
|
||||
}
|
||||
return $this->cuotas->hoy;
|
||||
}
|
||||
public function cuotasPendientes()
|
||||
{
|
||||
public function cuotasPendientes() {
|
||||
if (!isset($this->cuotas) or !isset($this->cuotas->pendientes)) {
|
||||
$cuotas = [];
|
||||
if (isset($this->cuotas)) {
|
||||
@ -587,8 +588,7 @@ class Proyecto extends Model
|
||||
}
|
||||
return $this->cuotas->pendientes;
|
||||
}
|
||||
public function cuotasMes()
|
||||
{
|
||||
public function cuotasMes() {
|
||||
if (!isset($this->cuotas) or !isset($this->cuotas->mes)) {
|
||||
$cuotas = [];
|
||||
if (isset($this->cuotas)) {
|
||||
@ -611,16 +611,14 @@ class Proyecto extends Model
|
||||
}
|
||||
return $this->cuotas->mes;
|
||||
}
|
||||
public function tiposMediciones()
|
||||
{
|
||||
public function tiposMediciones() {
|
||||
$tipos = $this->has_many_through(\Incoviba\nuevo\Venta\TipoMedicion::class, \Incoviba\nuevo\Venta\ProyectoTipoMedicion::class, 'proyecto_id', 'tipo_medicion_id');
|
||||
if ($tipos) {
|
||||
return $tipos->orderByAsc('descripcion')->findMany();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public function superficie($tipo = 'total')
|
||||
{
|
||||
public function superficie($tipo = 'total') {
|
||||
if (!isset($this->superficies) or !isset($this->superficies->{$tipo})) {
|
||||
$superficies = [];
|
||||
if (isset($this->superficies)) {
|
||||
@ -675,8 +673,7 @@ class Proyecto extends Model
|
||||
}
|
||||
return $this->superficies->{$tipo};
|
||||
}
|
||||
public function setDireccion(array $data)
|
||||
{
|
||||
public function setDireccion(array $data) {
|
||||
if (!is_numeric($data['comuna'])) {
|
||||
$comuna = model(Comuna::class)->where('descripcion', $data['comuna'])->findOne();
|
||||
$data['comuna'] = $comuna->id;
|
||||
@ -689,16 +686,14 @@ class Proyecto extends Model
|
||||
->findOne();
|
||||
$this->direccion = $direccion->id;
|
||||
}
|
||||
public function addAgente(array $data)
|
||||
{
|
||||
public function addAgente(array $data) {
|
||||
$data = ['agente' => $data['agente'], 'tipo' => $data['tipo']];
|
||||
$agente = (new Factory(AgenteTipo::class))->create($data);
|
||||
$agente->save();
|
||||
$this->agentes []= $agente;
|
||||
}
|
||||
protected $tipologias;
|
||||
public function tipologias()
|
||||
{
|
||||
public function tipologias() {
|
||||
if ($this->tipologias == null) {
|
||||
$pts = $this->proyectoTipoUnidades();
|
||||
$tipologias = [];
|
||||
@ -715,13 +710,16 @@ class Proyecto extends Model
|
||||
}
|
||||
return $this->tipologias;
|
||||
}
|
||||
public function pagares()
|
||||
{
|
||||
return $this->hasMany(Pagare::class, 'proyecto')->findMany();
|
||||
protected $pagares;
|
||||
public function pagares() {
|
||||
if ($this->pagares === null) {
|
||||
$this->pagares = $this->setRelationship(Pagare::class, 'proyecto', 'id')->many();
|
||||
}
|
||||
return $this->pagares;
|
||||
//return $this->hasMany(Pagare::class, 'proyecto')->findMany();
|
||||
}
|
||||
protected $cierres;
|
||||
public function cierres(int $vigentes = 0)
|
||||
{
|
||||
public function cierres(int $vigentes = 0) {
|
||||
if (!isset($this->cierres[$vigentes]) or $this->cierres[$vigentes] == null) {
|
||||
$orm = model(Cierre::class)
|
||||
->select('cierre.*')
|
||||
@ -761,8 +759,13 @@ class Proyecto extends Model
|
||||
}
|
||||
return $this->cierres[$vigentes];
|
||||
}
|
||||
protected $tipos;
|
||||
public function tipos() {
|
||||
return $this->hasMany(ProyectoTipoUnidad::class, 'proyecto')->findMany();
|
||||
if ($this->tipos === null) {
|
||||
$this->tipos = $this->setRelationship(ProyectoTipoUnidad::class, 'proyecto', 'id')->many();
|
||||
}
|
||||
return $this->tipos;
|
||||
//return $this->hasMany(ProyectoTipoUnidad::class, 'proyecto')->findMany();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,12 +14,10 @@ use Incoviba\old\Proyecto\Proyecto;
|
||||
* @property int $relacionado
|
||||
* @property Propietario $propietario
|
||||
*/
|
||||
class Cierre extends Model
|
||||
{
|
||||
class Cierre extends Model {
|
||||
const VIGENTES = 1;
|
||||
const NO_VIGENTES = -1;
|
||||
public static function find(Proyecto $proyecto, Unidad $unidad, float $precio)
|
||||
{
|
||||
public static function find(Proyecto $proyecto, Unidad $unidad, float $precio) {
|
||||
return model(Cierre::class)
|
||||
->select('cierre.*')
|
||||
->join('unidad_cierre', ['unidad_cierre.cierre', '=', 'cierre.id'])
|
||||
@ -27,8 +25,7 @@ class Cierre extends Model
|
||||
->where('unidad_cierre.unidad', $unidad->id)
|
||||
->where('cierre.precio', $precio);
|
||||
}
|
||||
public static function vigentes()
|
||||
{
|
||||
public static function vigentes() {
|
||||
return model(Cierre::class)
|
||||
->select('cierre.*')
|
||||
->join('estado_cierre', ['estado_cierre.cierre', '=', 'cierre.id'])
|
||||
@ -40,8 +37,7 @@ class Cierre extends Model
|
||||
->groupBy('cierre.id')
|
||||
->findMany();
|
||||
}
|
||||
public static function proyectos()
|
||||
{
|
||||
public static function proyectos() {
|
||||
return model(Proyecto::class)
|
||||
->select('proyecto.*')
|
||||
->join('cierre', ['proyecto.id', '=', 'cierre.proyecto'])
|
||||
@ -54,39 +50,52 @@ class Cierre extends Model
|
||||
->findMany();
|
||||
}
|
||||
|
||||
public function proyecto()
|
||||
{
|
||||
return $this->belongsTo(Proyecto::class, 'proyecto')->findOne();
|
||||
protected $proyecto_obj;
|
||||
public function proyecto() {
|
||||
if ($this->proyecto_obj === null) {
|
||||
$this->proyecto_obj = $this->setRelationship(Proyecto::class, 'id', 'proyecto')->one();
|
||||
}
|
||||
public function unidades()
|
||||
{
|
||||
return $this->hasMany(UnidadCierre::class, 'cierre')->where('principal', 0)->findMany();
|
||||
return $this->proyecto_obj;
|
||||
//return $this->belongsTo(Proyecto::class, 'proyecto')->findOne();
|
||||
}
|
||||
public function unidadPrincipal()
|
||||
{
|
||||
return $this->hasMany(UnidadCierre::class, 'cierre')->where('principal', 1)->findOne();
|
||||
protected $unidades;
|
||||
public function unidades() {
|
||||
if ($this->unidades === null) {
|
||||
$this->unidades = $this->setRelationship(UnidadCierre::class, 'cierre', 'id')->where(['principal', 0])->many();
|
||||
}
|
||||
public function fecha(\DateTime $fecha = null)
|
||||
{
|
||||
return $this->unidades;
|
||||
//return $this->hasMany(UnidadCierre::class, 'cierre')->where('principal', 0)->findMany();
|
||||
}
|
||||
protected $principal;
|
||||
public function unidadPrincipal() {
|
||||
if ($this->principal === null) {
|
||||
$this->principal = $this->setRelationship(UnidadCierre::class, 'cierre', 'id')->where(['principal', 1])->one();
|
||||
}
|
||||
return $this->principal;
|
||||
//return $this->hasMany(UnidadCierre::class, 'cierre')->where('principal', 1)->findOne();
|
||||
}
|
||||
public function fecha(\DateTime $fecha = null) {
|
||||
if ($fecha == null) {
|
||||
return Carbon::parse($this->fecha, $this->container->get('settings')->app->timezone);
|
||||
}
|
||||
$this->fecha = $fecha->format('Y-m-d');
|
||||
}
|
||||
public function propietario()
|
||||
{
|
||||
$propietario = $this->belongsTo(Propietario::class, 'propietario');
|
||||
protected $propietario_obj;
|
||||
public function propietario() {
|
||||
if ($this->propietario_obj === null) {
|
||||
$this->propietario_obj = $this->setRelationship(Propietario::class, 'rut', 'propietario')->one();
|
||||
}
|
||||
return $propietario_obj;
|
||||
/*$propietario = $this->belongsTo(Propietario::class, 'propietario');
|
||||
if ($propietario) {
|
||||
return $propietario->findOne();
|
||||
}
|
||||
return false;
|
||||
return false;*/
|
||||
}
|
||||
public function uf_m2()
|
||||
{
|
||||
public function uf_m2() {
|
||||
return $this->neto() / $this->unidadPrincipal()->unidad()->m2();
|
||||
}
|
||||
public function neto()
|
||||
{
|
||||
public function neto() {
|
||||
$valor = $this->precio;
|
||||
foreach ($this->unidades() as $unidad) {
|
||||
$valor -= $unidad->unidad()->precio($this->fecha())->valor;
|
||||
@ -99,24 +108,30 @@ class Cierre extends Model
|
||||
}
|
||||
return $valor;
|
||||
}
|
||||
public function valores()
|
||||
{
|
||||
return $this->hasMany(ValorCierre::class, 'cierre')->findMany();
|
||||
protected $valores;
|
||||
public function valores() {
|
||||
if ($this->valores === null) {
|
||||
$this->valores = $this->setRelationship(ValorCierre::class, 'cierre', 'id')->many();
|
||||
}
|
||||
public function valor($tipo = 'pie')
|
||||
{
|
||||
return $this->valores;
|
||||
//return $this->hasMany(ValorCierre::class, 'cierre')->findMany();
|
||||
}
|
||||
public function valor($tipo = 'pie') {
|
||||
return $this->hasMany(ValorCierre::class, 'cierre')
|
||||
->select('valor_cierre.*')
|
||||
->join('tipo_valor_cierre', ['tipo_valor_cierre.id', '=', 'valor_cierre.tipo'])
|
||||
->where('tipo_valor_cierre.descripcion', $tipo)
|
||||
->findOne();
|
||||
}
|
||||
public function estados()
|
||||
{
|
||||
return $this->hasMany(EstadoCierre::class, 'cierre')->findMany();
|
||||
protected $estados;
|
||||
public function estados() {
|
||||
if ($this->estados === null) {
|
||||
$this->estados = $this->setRelationship(EstadoCierre::class, 'cierre', 'id')->many();
|
||||
}
|
||||
public function estado(\DateTime $fecha = null)
|
||||
{
|
||||
return $this->estados;
|
||||
//return $this->hasMany(EstadoCierre::class, 'cierre')->findMany();
|
||||
}
|
||||
public function estado(\DateTime $fecha = null) {
|
||||
if ($fecha == null) {
|
||||
$estado = $this->hasMany(EstadoCierre::class, 'cierre')->orderByDesc('id')->findOne();
|
||||
if ($estado->tipo()->vigente == 1 and $this->oldest()) {
|
||||
@ -136,8 +151,7 @@ class Cierre extends Model
|
||||
}
|
||||
return $estado;
|
||||
}
|
||||
public function new(\DateTime $fecha)
|
||||
{
|
||||
public function new(\DateTime $fecha) {
|
||||
$this->save();
|
||||
$tipo = model(TipoEstadoCierre::class)->where('descripcion', 'revisado')->findOne();
|
||||
$data = [
|
||||
@ -199,22 +213,19 @@ class Cierre extends Model
|
||||
$estado->save();
|
||||
});
|
||||
}
|
||||
public function addUnidad(array $data)
|
||||
{
|
||||
public function addUnidad(array $data) {
|
||||
$data['cierre'] = $this->id;
|
||||
$unidad = model(UnidadCierre::class)->create($data);
|
||||
$unidad->save();
|
||||
}
|
||||
public function addValor(array $data)
|
||||
{
|
||||
public function addValor(array $data) {
|
||||
$data['cierre'] = $this->id;
|
||||
$tipo = model(TipoValorCierre::class)->where('descripcion', $data['tipo'])->findOne();
|
||||
$data['tipo'] = $tipo->id;
|
||||
$valor = model(ValorCierre::class)->create($data);
|
||||
$valor->save();
|
||||
}
|
||||
public static function evaluar($precio_neto, $unidad, $fecha, $relacionado = false)
|
||||
{
|
||||
public static function evaluar($precio_neto, $unidad, $fecha, $relacionado = false) {
|
||||
$precio_oferta = round($precio_neto, 2);
|
||||
$precio_lista = round($unidad->precio($fecha)->valor * (($relacionado) ? (1 - 0.06) : 1), 2);
|
||||
if ($precio_oferta >= $precio_lista) {
|
||||
@ -222,8 +233,7 @@ class Cierre extends Model
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function guardar(object $input)
|
||||
{
|
||||
public function guardar(object $input) {
|
||||
$this->proyecto = $input->proyecto->id;
|
||||
$this->precio = $input->precio;
|
||||
$this->fecha = $input->fecha->format('Y-m-d');
|
||||
@ -277,8 +287,7 @@ class Cierre extends Model
|
||||
$this->addValor($data);
|
||||
}
|
||||
}
|
||||
public function aprobar(\DateTime $fecha)
|
||||
{
|
||||
public function aprobar(\DateTime $fecha) {
|
||||
$tipo = model(TipoEstadoCierre::class)->where('descripcion', 'aprobado')->findOne();
|
||||
$data = [
|
||||
'cierre' => $this->id,
|
||||
@ -291,8 +300,7 @@ class Cierre extends Model
|
||||
$estado->save();
|
||||
}
|
||||
}
|
||||
public function rechazar(\DateTime $fecha)
|
||||
{
|
||||
public function rechazar(\DateTime $fecha) {
|
||||
$tipo = model(TipoEstadoCierre::class)->where('descripcion', 'rechazado')->findOne();
|
||||
$data = [
|
||||
'cierre' => $this->id,
|
||||
@ -320,8 +328,7 @@ class Cierre extends Model
|
||||
}
|
||||
}
|
||||
protected $promesa;
|
||||
public function promesa()
|
||||
{
|
||||
public function promesa() {
|
||||
if (!$this->unidadPrincipal()) {
|
||||
$this->promesa = false;
|
||||
}
|
||||
|
@ -15,7 +15,5 @@ use Incoviba\Common\Alias\OldModel as Model;
|
||||
* @property int pago_reserva
|
||||
*
|
||||
*/
|
||||
class Entrega extends Model
|
||||
{
|
||||
class Entrega extends Model {
|
||||
}
|
||||
?>
|
||||
|
@ -24,23 +24,26 @@ use Incoviba\old\Proyecto\ProyectoTipoUnidad;
|
||||
* @property float valor
|
||||
*
|
||||
*/
|
||||
class Unidad extends Model
|
||||
{
|
||||
public function proyecto()
|
||||
{
|
||||
$proyecto = $this->belongs_to(Proyecto::class, 'proyecto')->findOne();
|
||||
class Unidad extends Model {
|
||||
protected $proyecto_obj;
|
||||
public function proyecto() {
|
||||
if ($this->proyecto_obj === null) {
|
||||
$this->proyecto_obj = $this->setRelationship(Proyecto::class, 'id', 'proyecto')->one();
|
||||
}
|
||||
return $this->proyecto_obj;
|
||||
/*$proyecto = $this->belongs_to(Proyecto::class, 'proyecto')->findOne();
|
||||
$proyecto->setContainer($this->container);
|
||||
return $proyecto;
|
||||
return $proyecto;*/
|
||||
}
|
||||
protected $propiedad;
|
||||
public function propiedad()
|
||||
{
|
||||
if ($this->propiedad == null) {
|
||||
$this->propiedad = $this->hasMany(PropiedadUnidad::class, 'unidad')->findOne();
|
||||
public function propiedad() {
|
||||
if ($this->propiedad === null) {
|
||||
$this->propiedad = $this->setRelationship(PropiedadUnidad::class, 'unidad', 'id')->one();
|
||||
//$this->propiedad = $this->hasMany(PropiedadUnidad::class, 'unidad')->findOne();
|
||||
}
|
||||
return $this->propiedad;
|
||||
|
||||
if ($this->tipo()->descripcion == 'departamento') {
|
||||
/*if ($this->tipo()->descripcion == 'departamento') {
|
||||
$propiedad = $this->has_one(Propiedad::class, 'unidad_principal');
|
||||
if ($propiedad) {
|
||||
return $propiedad->findOne();
|
||||
@ -86,15 +89,18 @@ class Unidad extends Model
|
||||
return $propiedad;
|
||||
}
|
||||
return null;
|
||||
}*/
|
||||
}
|
||||
protected $tipo_obj;
|
||||
public function tipo() {
|
||||
if ($this->tipo_obj === null) {
|
||||
$this->tipo_obj = $this->setRelationship(TipoUnidad::class, 'id', 'tipo')->one();
|
||||
}
|
||||
public function tipo()
|
||||
{
|
||||
return $this->belongs_to(TipoUnidad::class, 'tipo')->findOne();
|
||||
return $this->tipo_obj;
|
||||
//return $this->belongs_to(TipoUnidad::class, 'tipo')->findOne();
|
||||
}
|
||||
private $venta = null;
|
||||
public function venta()
|
||||
{
|
||||
public function venta() {
|
||||
if ($this->venta == null) {
|
||||
$propiedad = $this->propiedad();
|
||||
if ($propiedad) {
|
||||
@ -107,8 +113,7 @@ class Unidad extends Model
|
||||
return $this->venta;
|
||||
}
|
||||
private $m2t = null;
|
||||
public function m2($tipo = 'vendible')
|
||||
{
|
||||
public function m2($tipo = 'vendible') {
|
||||
if ($this->m2t == null or !isset($this->m2t->{$tipo})) {
|
||||
if ($this->m2t == null) {
|
||||
$this->m2t = [];
|
||||
@ -121,12 +126,15 @@ class Unidad extends Model
|
||||
}
|
||||
return $this->m2t->{$tipo};
|
||||
}
|
||||
public function precios()
|
||||
{
|
||||
return $this->hasMany(Precio::class, 'unidad')->findMany();
|
||||
protected $precios;
|
||||
public function precios() {
|
||||
if ($this->precios === null) {
|
||||
$this->precios = $this->setRelationship(Precio::class, 'unidad', 'id')->many();
|
||||
}
|
||||
public function precio($fecha = null)
|
||||
{
|
||||
return $this->precios;
|
||||
//return $this->hasMany(Precio::class, 'unidad')->findMany();
|
||||
}
|
||||
public function precio($fecha = null) {
|
||||
if ($fecha == null) {
|
||||
return \model(Precio::class)
|
||||
->select('precio.*')
|
||||
@ -145,8 +153,7 @@ class Unidad extends Model
|
||||
->orderByDesc('ep.id')
|
||||
->findOne();
|
||||
}
|
||||
public function setPrecio($fecha, $valor)
|
||||
{
|
||||
public function setPrecio($fecha, $valor) {
|
||||
$exists = false;
|
||||
// Dejar valores antiguos reemplazados (estado = 'reemplazado')
|
||||
foreach ($this->precios() as $precio) {
|
||||
@ -175,9 +182,13 @@ class Unidad extends Model
|
||||
$precio = model(Precio::class)->create($data);
|
||||
$precio->new($fecha);
|
||||
}
|
||||
public function tipologia()
|
||||
{
|
||||
return $this->belongsTo(ProyectoTipoUnidad::class, 'pt')->findOne();
|
||||
protected $tipologia;
|
||||
public function tipologia() {
|
||||
if ($this->tipologia === null) {
|
||||
$this->tipologia = $this->setRelationship(ProyectoTipoUnidad::class, 'id', 'pt')->one();
|
||||
}
|
||||
return $this->tipologia;
|
||||
//return $this->belongsTo(ProyectoTipoUnidad::class, 'pt')->findOne();
|
||||
}
|
||||
protected $is_vendida;
|
||||
public function isVendida() {
|
||||
@ -241,4 +252,3 @@ class Unidad extends Model
|
||||
return $this->linea;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -31,8 +31,7 @@ use Incoviba\old\Proyecto\ProyectoAgente;
|
||||
* @property Pago resciliacion
|
||||
*
|
||||
*/
|
||||
class Venta extends Model
|
||||
{
|
||||
class Venta extends Model {
|
||||
protected $saldo;
|
||||
protected $uf;
|
||||
protected $anticipo;
|
||||
@ -42,61 +41,84 @@ class Venta extends Model
|
||||
protected $promociones;
|
||||
protected $valor_corredora;
|
||||
|
||||
public function propietario()
|
||||
{
|
||||
return $this->belongs_to(Propietario::class, 'propietario', 'rut')->findOne();
|
||||
protected $propietario_obj;
|
||||
public function propietario() {
|
||||
if ($this->propietario_obj === null) {
|
||||
$this->propietario_obj = $this->setRelationship(Propietario::class, 'rut', 'propietario')->one();
|
||||
}
|
||||
public function propiedad()
|
||||
{
|
||||
$propiedad = $this->belongs_to(Propiedad::class, 'propiedad')->findOne();
|
||||
return $this->propietario_obj;
|
||||
//return $this->belongs_to(Propietario::class, 'propietario', 'rut')->findOne();
|
||||
}
|
||||
protected $propiedad_obj;
|
||||
public function propiedad() {
|
||||
if ($this->propiedad_obj === null) {
|
||||
$this->propiedad_obj = $this->setRelationship(Propiedad::class, 'id', 'propiedad')->one();
|
||||
}
|
||||
return $this->propiedad_obj;
|
||||
/*$propiedad = $this->belongs_to(Propiedad::class, 'propiedad')->findOne();
|
||||
$propiedad->setContainer($this->container);
|
||||
return $propiedad;
|
||||
return $propiedad;*/
|
||||
}
|
||||
public function bonoPie()
|
||||
{
|
||||
$bono = $this->belongs_to(BonoPie::class, 'bono_pie');
|
||||
protected $bono_obj;
|
||||
public function bonoPie() {
|
||||
if ($this->bono_obj === null) {
|
||||
$this->bono_obj = $this->setRelationship(BonoPie::class, 'id', 'bono_pie')->one();
|
||||
}
|
||||
return $this->bono_obj;
|
||||
/*$bono = $this->belongs_to(BonoPie::class, 'bono_pie');
|
||||
if ($bono) {
|
||||
return $bono->findOne();
|
||||
}
|
||||
return null;
|
||||
return null;*/
|
||||
}
|
||||
public function pie()
|
||||
{
|
||||
$pie = $this->belongs_to(Pie::class, 'pie');
|
||||
protected $pie_obj;
|
||||
public function pie() {
|
||||
if ($this->pie_obj === null) {
|
||||
$this->pie_obj = $this->setRelationship(Pie::class, 'id', 'pie')->one();
|
||||
}
|
||||
return $this->pie_obj;
|
||||
/*$pie = $this->belongs_to(Pie::class, 'pie');
|
||||
if ($pie) {
|
||||
return $pie->findOne();
|
||||
}
|
||||
return null;
|
||||
return null;*/
|
||||
}
|
||||
public function entrega()
|
||||
{
|
||||
if ($this->entrega != '0') {
|
||||
protected $entrega_obj;
|
||||
public function entrega() {
|
||||
if ($this->entrega_obj === null) {
|
||||
$this->entrega_obj = $this->setRelationship(Entrega::class, 'id', 'entrega')->one();
|
||||
}
|
||||
return $this->entrega_obj;
|
||||
/*if ($this->entrega != '0') {
|
||||
return $this->belongs_to(Entrega::class, 'entrega')->findOne();
|
||||
}
|
||||
return null;
|
||||
return null;*/
|
||||
}
|
||||
public function fecha()
|
||||
{
|
||||
public function fecha(\DateTime $fecha = null) {
|
||||
if ($fecha == null) {
|
||||
return Carbon::parse($this->fecha, $this->container->get('settings')->app->timezone);
|
||||
}
|
||||
public function proyecto()
|
||||
{
|
||||
$this->fecha = $fecha->format('Y-m-d');
|
||||
}
|
||||
public function proyecto() {
|
||||
return $this->propiedad()->unidad()->proyecto();
|
||||
}
|
||||
public function unidad()
|
||||
{
|
||||
public function unidad() {
|
||||
return $this->propiedad()->unidad();
|
||||
}
|
||||
public function agente()
|
||||
{
|
||||
$agente = $this->belongs_to(ProyectoAgente::class, 'agente');
|
||||
protected $agente_obj;
|
||||
public function agente() {
|
||||
if ($this->agente_obj === null) {
|
||||
$this->agente_obj = $this->setRelationship(ProyectoAgente::class, 'id', 'agente')->one();
|
||||
}
|
||||
return $this->agente_obj;
|
||||
/*$agente = $this->belongs_to(ProyectoAgente::class, 'agente');
|
||||
if ($agente) {
|
||||
return $agente->findOne();
|
||||
}
|
||||
return null;
|
||||
return null;*/
|
||||
}
|
||||
public function comision()
|
||||
{
|
||||
public function comision() {
|
||||
if (!isset($this->comision)) {
|
||||
$pa = $this->agente();
|
||||
if ($pa and $pa->agente()->tipo == 19) {
|
||||
@ -107,8 +129,7 @@ class Venta extends Model
|
||||
}
|
||||
return $this->comision;
|
||||
}
|
||||
public function valorComision()
|
||||
{
|
||||
public function valorComision() {
|
||||
$bono_pie = $this->bonoPie();
|
||||
if ($this->bono_pie != 0) {
|
||||
$bono_pie = $bono_pie->pago()->valor('ufs');
|
||||
@ -146,8 +167,7 @@ class Venta extends Model
|
||||
}
|
||||
return $this->valor_unidades;
|
||||
}
|
||||
public function valorEstacionamientos()
|
||||
{
|
||||
public function valorEstacionamientos() {
|
||||
$estacionamientos = $this->propiedad()->estacionamientos();
|
||||
$sum = 0;
|
||||
foreach ($estacionamientos as $estacionamiento) {
|
||||
@ -155,8 +175,7 @@ class Venta extends Model
|
||||
}
|
||||
return $sum;
|
||||
}
|
||||
public function valorBodegas()
|
||||
{
|
||||
public function valorBodegas() {
|
||||
$bodegas = $this->propiedad()->bodegas();
|
||||
$sum = 0;
|
||||
foreach ($bodegas as $bodega) {
|
||||
@ -164,12 +183,10 @@ class Venta extends Model
|
||||
}
|
||||
return $sum;
|
||||
}
|
||||
public function valorEstacionamientosYBodegas()
|
||||
{
|
||||
public function valorEstacionamientosYBodegas() {
|
||||
return $this->valorEstacionamientos() + $this->valorBodegas();
|
||||
}
|
||||
public function valorCorredora()
|
||||
{
|
||||
public function valorCorredora() {
|
||||
if ($this->valor_corredora == null) {
|
||||
$bono_pie = $this->bonoPie();
|
||||
if ($this->bono_pie != 0) {
|
||||
@ -188,8 +205,7 @@ class Venta extends Model
|
||||
}
|
||||
return $this->valor_corredora;
|
||||
}
|
||||
public function valorFinal()
|
||||
{
|
||||
public function valorFinal() {
|
||||
if (!isset($this->valor_neto)) {
|
||||
$comision = $this->valorComision();
|
||||
$bono_pie = $this->bonoPie();
|
||||
@ -211,76 +227,101 @@ class Venta extends Model
|
||||
}
|
||||
return $this->valor_neto;
|
||||
}
|
||||
public function uf_m2()
|
||||
{
|
||||
public function uf_m2() {
|
||||
$m2 = array_reduce($this->propiedad()->departamentos(), function($sum, $item) {
|
||||
return $sum + $item->m2();
|
||||
});
|
||||
return $this->valorFinal() / $m2;
|
||||
}
|
||||
public function escritura()
|
||||
{
|
||||
$escritura = $this->belongs_to(Escritura::class, 'escritura');
|
||||
protected $escritura_obj;
|
||||
public function escritura() {
|
||||
if ($this->escritura_obj === null) {
|
||||
$this->escritura_obj = $this->setRelationship(Escritura::class, 'id', 'escritura')->one();
|
||||
}
|
||||
return $this->escritura_obj;
|
||||
/*$escritura = $this->belongs_to(Escritura::class, 'escritura');
|
||||
if ($escritura) {
|
||||
return $escritura->findOne();
|
||||
}
|
||||
return null;
|
||||
return null;*/
|
||||
}
|
||||
public function credito()
|
||||
{
|
||||
$credito = $this->belongs_to(Credito::class, 'credito');
|
||||
protected $credito_obj;
|
||||
public function credito() {
|
||||
if ($this->credito_obj === null) {
|
||||
$this->credito_obj = $this->setRelationship(Credito::class, 'id', 'credito')->one();
|
||||
}
|
||||
return $this->credito_obj;
|
||||
/*$credito = $this->belongs_to(Credito::class, 'credito');
|
||||
if ($credito) {
|
||||
return $credito->findOne();
|
||||
}
|
||||
return null;
|
||||
return null;*/
|
||||
}
|
||||
public function comentarios()
|
||||
{
|
||||
return $this->has_many(Comentario::class, 'venta')->findMany();
|
||||
protected $comentarios;
|
||||
public function comentarios() {
|
||||
if ($this->comentarios === null) {
|
||||
$this->comentarios = $this->setRelationship(Comentario::class, 'venta', 'id')->many();
|
||||
}
|
||||
public function subsidio()
|
||||
{
|
||||
$subsidio = $this->belongs_to(Subsidio::class, 'subsidio');
|
||||
return $this->comentarios;
|
||||
//return $this->has_many(Comentario::class, 'venta')->findMany();
|
||||
}
|
||||
protected $subsidio_obj;
|
||||
public function subsidio() {
|
||||
if ($this->subsidio_obj === null) {
|
||||
$this->subsidio_obj = $this->setRelationship(Subsidio::class, 'id', 'subsidio')->one();
|
||||
}
|
||||
return $this->subsidio_obj;
|
||||
/*$subsidio = $this->belongs_to(Subsidio::class, 'subsidio');
|
||||
if ($subsidio) {
|
||||
return $subsidio->findOne();
|
||||
}
|
||||
return null;
|
||||
return null;*/
|
||||
}
|
||||
|
||||
public function resciliacion()
|
||||
{
|
||||
$res = $this->belongs_to(Pago::class, 'resciliacion');
|
||||
protected $resciliacion_obj;
|
||||
public function resciliacion() {
|
||||
if ($this->resciliacion_obj === null) {
|
||||
$this->resciliacion_obj = $this->setRelationship(Pago::class, 'id', 'resciliacion')->one();
|
||||
}
|
||||
return $this->resciliacion_obj;
|
||||
/*$res = $this->belongs_to(Pago::class, 'resciliacion');
|
||||
if ($res) {
|
||||
return $res->findOne();
|
||||
}
|
||||
return null;
|
||||
return null;*/
|
||||
}
|
||||
public function postventas()
|
||||
{
|
||||
$postventas = $this->has_many(\Incoviba\nuevo\Venta\Postventa::class, 'venta_id');
|
||||
protected $postventas;
|
||||
public function postventas() {
|
||||
if ($this->postventas === null) {
|
||||
$this->postventas = $this->setRelationship(Postventa::class, 'venta_id', 'id')->many();
|
||||
}
|
||||
return $this->postventas;
|
||||
/*$postventas = $this->has_many(\Incoviba\nuevo\Venta\Postventa::class, 'venta_id');
|
||||
if ($postventas) {
|
||||
return $postventas->findMany();
|
||||
}
|
||||
return null;
|
||||
return null;*/
|
||||
}
|
||||
public function promociones()
|
||||
{
|
||||
public function promociones() {
|
||||
if ($this->promociones == null) {
|
||||
$pvs = model(PromocionVenta::class)->where('venta', $this->id)->findMany();
|
||||
$this->promociones = $pvs;
|
||||
}
|
||||
return $this->promociones;
|
||||
}
|
||||
public function devolucion()
|
||||
{
|
||||
$devolucion = $this->belongsTo(Pago::class, 'devolucion');
|
||||
protected $devolucion_obj;
|
||||
public function devolucion() {
|
||||
if ($this->devolucion_obj === null) {
|
||||
$this->devolucion_obj = $this->setRelationship(Pago::class, 'id', 'devolucion')->one();
|
||||
}
|
||||
return $this->devolucion_obj;
|
||||
/*$devolucion = $this->belongsTo(Pago::class, 'devolucion');
|
||||
if ($devolucion) {
|
||||
return $devolucion->findOne();
|
||||
}
|
||||
return null;
|
||||
return null;*/
|
||||
}
|
||||
public function anticipo($tipo = 'ufs')
|
||||
{
|
||||
public function anticipo($tipo = 'ufs') {
|
||||
if (!isset($this->anticipo[$tipo])) {
|
||||
$anticipo = 0;
|
||||
if ($this->pie != 0) {
|
||||
@ -304,8 +345,7 @@ class Venta extends Model
|
||||
|
||||
return $this->anticipo[$tipo];
|
||||
}
|
||||
public function saldo($tipo = 'ufs')
|
||||
{
|
||||
public function saldo($tipo = 'ufs') {
|
||||
if (!isset($this->saldo[$tipo])) {
|
||||
if ($tipo == 'pesos') {
|
||||
$this->saldo[$tipo] = $this->saldo() * $this->uf();
|
||||
@ -341,16 +381,14 @@ class Venta extends Model
|
||||
|
||||
return $this->saldo[$tipo];
|
||||
}
|
||||
public function valor($tipo = 'ufs')
|
||||
{
|
||||
public function valor($tipo = 'ufs') {
|
||||
if ($tipo == 'ufs') {
|
||||
return $this->valor_uf;
|
||||
}
|
||||
return $this->valor_uf * $this->uf();
|
||||
}
|
||||
protected $valores;
|
||||
public function valorPagado($tipo = 'ufs')
|
||||
{
|
||||
public function valorPagado($tipo = 'ufs') {
|
||||
if ($this->valores == null or !isset($this->valores->pagado->ufs)) {
|
||||
$valores = [];
|
||||
if (isset($this->valores)) {
|
||||
@ -365,8 +403,7 @@ class Venta extends Model
|
||||
}
|
||||
return $this->valores->pagado->{$tipo};
|
||||
}
|
||||
public function valorAbonado($tipo = 'ufs')
|
||||
{
|
||||
public function valorAbonado($tipo = 'ufs') {
|
||||
if ($this->valores == null or !isset($this->valores->abonado->{$tipo})) {
|
||||
$valores = [];
|
||||
if (isset($this->valores)) {
|
||||
@ -381,8 +418,7 @@ class Venta extends Model
|
||||
}
|
||||
return $this->valores->abonado->{$tipo};
|
||||
}
|
||||
public function pagado($tipo = 'ufs')
|
||||
{
|
||||
public function pagado($tipo = 'ufs') {
|
||||
if (!isset($this->pagado[$tipo])) {
|
||||
if (abs($this->saldo()) / $this->valor() > 0.01 or $tipo == 'pesos') {
|
||||
$total = 0;
|
||||
@ -408,16 +444,14 @@ class Venta extends Model
|
||||
}
|
||||
return $this->pagado[$tipo];
|
||||
}
|
||||
public function pieReajustado($tipo = 'ufs')
|
||||
{
|
||||
public function pieReajustado($tipo = 'ufs') {
|
||||
if (abs($this->saldo()) / $this->valor() > 0.01) {
|
||||
return $this->pie()->valorPagado($tipo);
|
||||
}
|
||||
$valor = $this->pie()->valorPagado($tipo) - $this->saldo($tipo);
|
||||
return $valor;
|
||||
}
|
||||
public function uf()
|
||||
{
|
||||
public function uf() {
|
||||
if ($this->uf == null) {
|
||||
$f = $this->fecha();
|
||||
$uf = $this->container->get('uf')($f);
|
||||
@ -429,8 +463,7 @@ class Venta extends Model
|
||||
|
||||
return $this->uf;
|
||||
}
|
||||
public function pagos($estado = 0)
|
||||
{
|
||||
public function pagos($estado = 0) {
|
||||
$results = [];
|
||||
if ($this->pie != 0) {
|
||||
$results = array_merge($results, $this->pie()->pagos($estado));
|
||||
@ -450,8 +483,7 @@ class Venta extends Model
|
||||
});
|
||||
return $results;
|
||||
}
|
||||
public function new()
|
||||
{
|
||||
public function new() {
|
||||
parent::save();
|
||||
$tipo = model(TipoEstadoVenta::class)->where('descripcion', 'vigente')->findOne();
|
||||
$data = [
|
||||
@ -462,12 +494,15 @@ class Venta extends Model
|
||||
$estado = model(EstadoVenta::class)->create($data);
|
||||
$estado->save();
|
||||
}
|
||||
public function estados()
|
||||
{
|
||||
return $this->hasMany(EstadoVenta::class, 'venta')->findMany();
|
||||
protected $estados;
|
||||
public function estados() {
|
||||
if ($this->estados === null) {
|
||||
$this->estados = $this->setRelationship(EstadoVenta::class, 'venta', 'id')->many();
|
||||
}
|
||||
public function estado($estado = null)
|
||||
{
|
||||
return $this->estados;
|
||||
//return $this->hasMany(EstadoVenta::class, 'venta')->findMany();
|
||||
}
|
||||
public function estado($estado = null) {
|
||||
if ($estado == null) {
|
||||
return model(EstadoVenta::class)
|
||||
->select('estado_venta.*')
|
||||
@ -483,8 +518,7 @@ class Venta extends Model
|
||||
->orderByDesc('estado_venta.fecha')
|
||||
->findOne();
|
||||
}
|
||||
public function firmar(Carbon $fecha)
|
||||
{
|
||||
public function firmar(Carbon $fecha) {
|
||||
$estado = $this->estado();
|
||||
if ($estado->tipo()->descripcion == 'firmado por inmobiliaria') {
|
||||
return true;
|
||||
@ -498,8 +532,7 @@ class Venta extends Model
|
||||
$estado = model(EstadoVenta::class)->create($data)->save();
|
||||
return true;
|
||||
}
|
||||
public function archivar(Carbon $fecha)
|
||||
{
|
||||
public function archivar(Carbon $fecha) {
|
||||
$estado = $this->estado();
|
||||
if ($estado->estado()->tipo()->descripcion == 'archivado') {
|
||||
return true;
|
||||
@ -514,4 +547,3 @@ class Venta extends Model
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user