mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
Adjust discounts
This commit is contained in:
parent
0ff4fe09c7
commit
cef4068d5c
@ -136,17 +136,16 @@ class Company extends Eloquent
|
||||
return false;
|
||||
}
|
||||
|
||||
// after 52 weeks, offer a 50% discount for 3 days
|
||||
$discounts = [
|
||||
52 => [.5, 3],
|
||||
16 => [.5, 3],
|
||||
52 => [.6, 3],
|
||||
16 => [.4, 3],
|
||||
10 => [.25, 5],
|
||||
];
|
||||
|
||||
foreach ($discounts as $weeks => $promo) {
|
||||
list($discount, $validFor) = $promo;
|
||||
$difference = $this->created_at->diffInWeeks();
|
||||
if ($difference >= $weeks) {
|
||||
if ($difference >= $weeks && $discount > $this->discount) {
|
||||
$this->discount = $discount;
|
||||
$this->promo_expires = date_create()->modify($validFor . ' days')->format('Y-m-d');
|
||||
$this->save();
|
||||
|
@ -110,6 +110,12 @@
|
||||
proPrice = proPrice - (proPrice * {{ Auth::user()->account->company->discount }});
|
||||
enterprisePrice = enterprisePrice - (enterprisePrice * {{ Auth::user()->account->company->discount }});
|
||||
@endif
|
||||
if (proPrice % 1) {
|
||||
proPrice = proPrice.toFixed(2);
|
||||
}
|
||||
if (enterprisePrice % 1) {
|
||||
enterprisePrice = enterprisePrice.toFixed(2);
|
||||
}
|
||||
$('#upgrade_pro_price').text(proPrice);
|
||||
$('#upgrade_enterprise_price').text(enterprisePrice);
|
||||
$('span.upgrade_frequency').text(label);
|
||||
|
Loading…
Reference in New Issue
Block a user