mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 06:14:31 -04: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) {
|
foreach ($discounts as $weeks => $promo) {
|
||||||
list($discount, $validFor) = $promo;
|
list($discount, $validFor) = $promo;
|
||||||
$difference = $this->created_at->diffInWeeks();
|
$difference = $this->created_at->diffInWeeks();
|
||||||
if ($difference >= $weeks && $discount > $this->discount) {
|
if ($difference >= $weeks) {
|
||||||
$this->discount = $discount;
|
$this->discount = $discount;
|
||||||
$this->promo_expires = date_create()->modify($validFor . ' days')->format('Y-m-d');
|
$this->promo_expires = date_create()->modify($validFor . ' days')->format('Y-m-d');
|
||||||
$this->save();
|
$this->save();
|
||||||
@ -189,7 +189,7 @@ class Company extends Eloquent
|
|||||||
public function applyDiscount($amount)
|
public function applyDiscount($amount)
|
||||||
{
|
{
|
||||||
$this->discount = $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()
|
public function applyFreeYear()
|
||||||
|
@ -48,6 +48,9 @@ class AccountRepository
|
|||||||
if (env('PARTNER_CAMPAIGN') && hash_equals(Input::get('utm_campaign'), env('PARTNER_CAMPAIGN'))) {
|
if (env('PARTNER_CAMPAIGN') && hash_equals(Input::get('utm_campaign'), env('PARTNER_CAMPAIGN'))) {
|
||||||
$company->applyFreeYear();
|
$company->applyFreeYear();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$company->applyDiscount(.5);
|
||||||
|
session()->flash('warning', $company->present()->promoMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$company->save();
|
$company->save();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user