Files
modelos/src/nuevo/Venta/Cierre.php

60 lines
1.3 KiB
PHP
Raw Normal View History

2019-12-23 18:01:36 -03:00
<?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;
/**
2020-01-07 12:25:52 -03:00
*
2019-12-23 18:01:36 -03:00
* @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;
2020-01-07 12:25:52 -03:00
2019-12-23 18:01:36 -03:00
protected static $_table = 'cierres';
2020-01-07 12:25:52 -03:00
2019-12-23 18:01:36 -03:00
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()
{
2020-01-07 12:25:52 -03:00
return Carbon::parse($this->fecha, $this->container->get('settings')->app->timezone);
2019-12-23 18:01:36 -03:00
}
public function pie($type = 'ufs')
{
if ($type == 'ufs') {
return $this->pie;
}
2020-01-07 12:25:52 -03:00
$uf = $this->container->get('uf')($this->fecha());
2019-12-23 18:01:36 -03:00
return $this->pie * $uf->uf->value;
}
}
2020-01-07 12:25:52 -03:00
?>