Relaciones
This commit is contained in:
@ -583,7 +583,7 @@ class Proyecto extends Model {
|
|||||||
}
|
}
|
||||||
$f = Carbon::today($this->container->get('settings')->app->timezone);
|
$f = Carbon::today($this->container->get('settings')->app->timezone);
|
||||||
$cuotas['hoy'] = $this->container->get('model')->find(Venta::class)
|
$cuotas['hoy'] = $this->container->get('model')->find(Venta::class)
|
||||||
->select('COUNT(cuota.id) AS cantidad')
|
->select([['COUNT(cuota.id)', 'cantidad', 'expr']])
|
||||||
->join([
|
->join([
|
||||||
['propiedad', 'propiedad.id', 'venta.propiedad'],
|
['propiedad', 'propiedad.id', 'venta.propiedad'],
|
||||||
['unidad', 'unidad.id', 'propiedad.unidad_principal'],
|
['unidad', 'unidad.id', 'propiedad.unidad_principal'],
|
||||||
@ -611,7 +611,7 @@ class Proyecto extends Model {
|
|||||||
}
|
}
|
||||||
$f = Carbon::today($this->container->get('settings')->app->timezone);
|
$f = Carbon::today($this->container->get('settings')->app->timezone);
|
||||||
$cuotas['pendientes'] = $this->container->get('model')->find(Cuota::class)
|
$cuotas['pendientes'] = $this->container->get('model')->find(Cuota::class)
|
||||||
->select('COUNT(cuota.id) AS cantidad')
|
->select([['COUNT(cuota.id)', 'cantidad', 'expr']])
|
||||||
->join([
|
->join([
|
||||||
['venta', 'cuota.pie', 'venta.pie'],
|
['venta', 'cuota.pie', 'venta.pie'],
|
||||||
['propiedad', 'propiedad.id', 'venta.propiedad'],
|
['propiedad', 'propiedad.id', 'venta.propiedad'],
|
||||||
@ -642,7 +642,7 @@ class Proyecto extends Model {
|
|||||||
->join([
|
->join([
|
||||||
['venta', 'cuota.pie', 'venta.pie'],
|
['venta', 'cuota.pie', 'venta.pie'],
|
||||||
['propiedad', 'propiedad.id', 'venta.propiedad'],
|
['propiedad', 'propiedad.id', 'venta.propiedad'],
|
||||||
['unidad', 'unidad.id', 'cuota.pago'],
|
['unidad', 'unidad.id', 'propiedad.unidad_principal'],
|
||||||
['pago', 'pago.id', 'cuota.pago'],
|
['pago', 'pago.id', 'cuota.pago'],
|
||||||
['JOIN (SELECT e1.* FROM (SELECT pago, MAX(id) AS id FROM estado_pago GROUP BY pago) e0 JOIN estado_pago e1 ON e1.id = e0.id)', 'ep.pago', 'pago.id', 'alias' => 'ep', 'type' => 'raw']
|
['JOIN (SELECT e1.* FROM (SELECT pago, MAX(id) AS id FROM estado_pago GROUP BY pago) e0 JOIN estado_pago e1 ON e1.id = e0.id)', 'ep.pago', 'pago.id', 'alias' => 'ep', 'type' => 'raw']
|
||||||
])
|
])
|
||||||
@ -824,7 +824,11 @@ class Proyecto extends Model {
|
|||||||
;
|
;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->cierres[$vigentes] = $orm->findMany();
|
$cierres = $orm->findMany();
|
||||||
|
foreach ($cierres as &$cierre) {
|
||||||
|
$cierre->setContainer($this->container);
|
||||||
|
}
|
||||||
|
$this->cierres[$vigentes] = $cierres;
|
||||||
}
|
}
|
||||||
return $this->cierres[$vigentes];
|
return $this->cierres[$vigentes];
|
||||||
}
|
}
|
||||||
|
@ -21,25 +21,33 @@ use Incoviba\Common\Alias\OldModel as Model;
|
|||||||
*/
|
*/
|
||||||
class Cuota extends Model
|
class Cuota extends Model
|
||||||
{
|
{
|
||||||
public function pago()
|
protected $pago_obj;
|
||||||
{
|
public function pago()
|
||||||
return $this->belongs_to(Pago::class, 'pago')->findOne();
|
{
|
||||||
}
|
if ($this->pago_obj === null) {
|
||||||
public function pie()
|
$this->pago_obj = $this->setRelationship(Pago::class, 'id', 'pago')->one();
|
||||||
{
|
}
|
||||||
return $this->belongs_to(Pie::class, 'pie')->findOne();
|
return $this->pago_obj;
|
||||||
}
|
}
|
||||||
public function uf()
|
protected $pie_obj;
|
||||||
{
|
public function pie()
|
||||||
if ($this->uf == 0) {
|
{
|
||||||
$uf = $this->pago()->uf();
|
if ($this->pie_obj === null) {
|
||||||
if ($uf == 1) {
|
$this->pie_obj = $this->setRelationship(Pie::class, 'id', 'pie')->one();
|
||||||
$uf = $this->pie()->uf();
|
}
|
||||||
}
|
return $this->pie_obj;
|
||||||
$this->uf = $uf;
|
}
|
||||||
}
|
public function uf()
|
||||||
return $this->uf;
|
{
|
||||||
}
|
if ($this->uf == 0) {
|
||||||
|
$uf = $this->pago()->uf();
|
||||||
|
if ($uf == 1) {
|
||||||
|
$uf = $this->pie()->uf();
|
||||||
|
}
|
||||||
|
$this->uf = $uf;
|
||||||
|
}
|
||||||
|
return $this->uf;
|
||||||
|
}
|
||||||
public function valor($tipo = 'pesos')
|
public function valor($tipo = 'pesos')
|
||||||
{
|
{
|
||||||
$valor = $this->pago()->valor;
|
$valor = $this->pago()->valor;
|
||||||
|
Reference in New Issue
Block a user