1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Adjust promotions

This commit is contained in:
Hillel Coren 2017-11-28 10:35:20 +02:00
parent f761ff289c
commit 86c718d79f
2 changed files with 5 additions and 2 deletions

View File

@ -140,7 +140,7 @@ class Company extends Eloquent
foreach ($discounts as $weeks => $promo) {
list($discount, $validFor) = $promo;
$difference = $this->created_at->diffInWeeks();
if ($difference >= $weeks && $discount > $this->discount) {
if ($difference >= $weeks) {
$this->discount = $discount;
$this->promo_expires = date_create()->modify($validFor . ' days')->format('Y-m-d');
$this->save();
@ -189,7 +189,7 @@ class Company extends Eloquent
public function applyDiscount($amount)
{
$this->discount = $amount;
$this->promo_expires = date_create()->modify('14 days')->format('Y-m-d');
$this->promo_expires = date_create()->modify('5 days')->format('Y-m-d');
}
public function applyFreeYear()

View File

@ -48,6 +48,9 @@ class AccountRepository
if (env('PARTNER_CAMPAIGN') && hash_equals(Input::get('utm_campaign'), env('PARTNER_CAMPAIGN'))) {
$company->applyFreeYear();
}
} else {
$company->applyDiscount(.5);
session()->flash('warning', $company->present()->promoMessage());
}
$company->save();