1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 12:12:48 +01:00

Adjust discounts

This commit is contained in:
Hillel Coren 2017-07-11 17:37:42 +03:00
parent 967c503134
commit e1d72e9bdc
2 changed files with 9 additions and 4 deletions

View File

@ -131,17 +131,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);