1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Adjust discounts

This commit is contained in:
Hillel Coren 2017-07-11 17:38:28 +03:00
parent 0ff4fe09c7
commit cef4068d5c
2 changed files with 9 additions and 4 deletions

View File

@ -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();

View File

@ -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);