From cef4068d5c7be7bc1663f0d343cfc2e194252407 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 11 Jul 2017 17:38:28 +0300 Subject: [PATCH] Adjust discounts --- app/Models/Company.php | 7 +++---- resources/views/partials/upgrade_modal.blade.php | 6 ++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Models/Company.php b/app/Models/Company.php index 882831bdd3..42bb4b1a43 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -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(); diff --git a/resources/views/partials/upgrade_modal.blade.php b/resources/views/partials/upgrade_modal.blade.php index 72278a365d..092bbd39a0 100644 --- a/resources/views/partials/upgrade_modal.blade.php +++ b/resources/views/partials/upgrade_modal.blade.php @@ -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);