Page MenuHomePhorge

D1504.1775390981.diff
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

D1504.1775390981.diff

diff --git a/src/app/Wallet.php b/src/app/Wallet.php
--- a/src/app/Wallet.php
+++ b/src/app/Wallet.php
@@ -60,6 +60,22 @@
public function chargeEntitlements($apply = true)
{
+ // This wallet has been created less than a month ago, this is the trial period
+ if ($this->created_at >= Carbon::now()->subMonthsWithoutOverflow(1)) {
+ // Move all the current entitlement's updated_at timestamps forward to one month after
+ // this wallet was created.
+ $freeMonthEnds = $this->created_at->copy()->addMonthsWithoutOverflow(1);
+
+ foreach ($this->entitlements()->get()->fresh() as $entitlement) {
+ if ($entitlement->updated_at < $freeMonthEnds) {
+ $entitlement->updated_at = $freeMonthEnds;
+ $entitlement->save();
+ }
+ }
+
+ return 0;
+ }
+
$charges = 0;
$discount = $this->getDiscountRate();
@@ -80,7 +96,7 @@
continue;
}
- // created more than a month ago -- was it billed?
+ // updated last more than a month ago -- was it billed?
if ($entitlement->updated_at <= Carbon::now()->subMonthsWithoutOverflow(1)) {
$diff = $entitlement->updated_at->diffInMonths(Carbon::now());
@@ -93,7 +109,9 @@
continue;
}
- $entitlement->updated_at = $entitlement->updated_at->copy()->addMonthsWithoutOverflow($diff);
+ $entitlement->updated_at = $entitlement->updated_at->copy()
+ ->addMonthsWithoutOverflow($diff);
+
$entitlement->save();
if ($cost == 0) {
diff --git a/src/database/seeds/production/PackageSeeder.php b/src/database/seeds/production/PackageSeeder.php
--- a/src/database/seeds/production/PackageSeeder.php
+++ b/src/database/seeds/production/PackageSeeder.php
@@ -15,6 +15,7 @@
*/
public function run()
{
+ $skuActiveSync = Sku::firstOrCreate(['title' => 'activesync']);
$skuGroupware = Sku::firstOrCreate(['title' => 'groupware']);
$skuMailbox = Sku::firstOrCreate(['title' => 'mailbox']);
$skuStorage = Sku::firstOrCreate(['title' => 'storage']);
@@ -31,7 +32,8 @@
$skus = [
$skuMailbox,
$skuGroupware,
- $skuStorage
+ $skuStorage,
+ $skuActiveSync
];
$package->skus()->saveMany($skus);

File Metadata

Mime Type
text/plain
Expires
Sun, Apr 5, 12:09 PM (1 d, 15 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18833412
Default Alt Text
D1504.1775390981.diff (2 KB)

Event Timeline