From 721c4cd3494b98c33b5316bc84489c39b9849e02 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 1 Jan 2017 20:23:51 +0200 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20apply=20annual=20discount=20if?= =?UTF-8?q?=20during=20the=20year?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Company.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Models/Company.php b/app/Models/Company.php index 680cc92a0838..f1bfd81b9a2b 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -56,13 +56,17 @@ class Company extends Eloquent // handle promos and discounts public function hasActiveDiscount(Carbon $date = null) { - if ( ! $this->discount) { + if ( ! $this->discount || ! $this->discount_expires) { return false; } $date = $date ?: Carbon::today(); - return $this->discount_expires && $this->discount_expires->gt($date); + if ($this->plan_term == PLAN_TERM_MONTHLY) { + return $this->discount_expires->gt($date); + } else { + return $this->discount_expires->subMonths(11)->gt($date); + } } public function discountedPrice($price)