From 82beb3b1c4cfa19c0b152c3db8555f19a492edc9 Mon Sep 17 00:00:00 2001 From: Aldarien Date: Thu, 2 Jan 2020 16:53:13 -0300 Subject: [PATCH] Fechas y abandonar --- src/old/Venta/Cierre.php | 19 ++++++++++++++++++- src/old/Venta/Venta.php | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/old/Venta/Cierre.php b/src/old/Venta/Cierre.php index b2f1971..38cf04d 100644 --- a/src/old/Venta/Cierre.php +++ b/src/old/Venta/Cierre.php @@ -305,10 +305,27 @@ class Cierre extends Model $estado->save(); } } + public function abandonar(\DateTime $fecha) { + $tipo = model(TipoEstadoCierre::class)->where('descripcion', 'abandonado')->findOne(); + $data = [ + 'cierre' => $this->id, + 'tipo' => $tipo->id + ]; + $estado = (new Factory(EstadoCierre::class))->where($data)->find(); + if (!$estado) { + $data['fecha'] = $fecha->format('Y-m-d'); + $estado = model(EstadoCierre::class)->create($data); + $estado->setContainer($this->container); + $estado->save(); + } + } protected $promesa; public function promesa() { - if ($this->promesa == null) { + if (!$this->unidadPrincipal()) { + $this->promesa = false; + } + if ($this->promesa === null) { $propiedad = model(Propiedad::class)->where('unidad_principal', $this->unidadPrincipal()->unidad)->findOne(); if (!$propiedad) { $this->promesa = false; diff --git a/src/old/Venta/Venta.php b/src/old/Venta/Venta.php index 549911a..3d7e63f 100644 --- a/src/old/Venta/Venta.php +++ b/src/old/Venta/Venta.php @@ -75,7 +75,7 @@ class Venta extends Model } public function fecha() { - return Carbon::parse($this->fecha, new \DateTimeZone(config('app.timezone'))); + return Carbon::parse($this->fecha, $this->container->get('settings')->app->timezone); } public function proyecto() {