59 lines
1.3 KiB
PHP
59 lines
1.3 KiB
PHP
|
<?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;
|
||
|
}
|
||
|
}
|
||
|
?>
|