Don’t apply annual discount if during the year

This commit is contained in:
Hillel Coren 2017-01-01 20:23:51 +02:00
parent 396db1dec4
commit 721c4cd349

View File

@ -56,13 +56,17 @@ class Company extends Eloquent
// handle promos and discounts // handle promos and discounts
public function hasActiveDiscount(Carbon $date = null) public function hasActiveDiscount(Carbon $date = null)
{ {
if ( ! $this->discount) { if ( ! $this->discount || ! $this->discount_expires) {
return false; return false;
} }
$date = $date ?: Carbon::today(); $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) public function discountedPrice($price)