mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Adjust promotions
This commit is contained in:
parent
f761ff289c
commit
86c718d79f
@ -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()
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user