mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 10:17:30 -04:00
Adjust discounts
This commit is contained in:
parent
967c503134
commit
e1d72e9bdc
@ -131,17 +131,16 @@ class Company extends Eloquent
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// after 52 weeks, offer a 50% discount for 3 days
|
|
||||||
$discounts = [
|
$discounts = [
|
||||||
52 => [.5, 3],
|
52 => [.6, 3],
|
||||||
16 => [.5, 3],
|
16 => [.4, 3],
|
||||||
10 => [.25, 5],
|
10 => [.25, 5],
|
||||||
];
|
];
|
||||||
|
|
||||||
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) {
|
if ($difference >= $weeks && $discount > $this->discount) {
|
||||||
$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();
|
||||||
|
@ -110,6 +110,12 @@
|
|||||||
proPrice = proPrice - (proPrice * {{ Auth::user()->account->company->discount }});
|
proPrice = proPrice - (proPrice * {{ Auth::user()->account->company->discount }});
|
||||||
enterprisePrice = enterprisePrice - (enterprisePrice * {{ Auth::user()->account->company->discount }});
|
enterprisePrice = enterprisePrice - (enterprisePrice * {{ Auth::user()->account->company->discount }});
|
||||||
@endif
|
@endif
|
||||||
|
if (proPrice % 1) {
|
||||||
|
proPrice = proPrice.toFixed(2);
|
||||||
|
}
|
||||||
|
if (enterprisePrice % 1) {
|
||||||
|
enterprisePrice = enterprisePrice.toFixed(2);
|
||||||
|
}
|
||||||
$('#upgrade_pro_price').text(proPrice);
|
$('#upgrade_pro_price').text(proPrice);
|
||||||
$('#upgrade_enterprise_price').text(enterprisePrice);
|
$('#upgrade_enterprise_price').text(enterprisePrice);
|
||||||
$('span.upgrade_frequency').text(label);
|
$('span.upgrade_frequency').text(label);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user