Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F119150122
D1504.1776169987.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D1504.1776169987.diff
View Options
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,11 @@
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)) {
+ return 0;
+ }
+
$charges = 0;
$discount = $this->getDiscountRate();
@@ -82,6 +87,21 @@
// created more than a month ago -- was it billed?
if ($entitlement->updated_at <= Carbon::now()->subMonthsWithoutOverflow(1)) {
+ // Take in to account the first month is free of charge
+ if ($this->created_at->isSameDay($entitlement->updated_at)) {
+ $entitlement->updated_at = $entitlement->updated_at->copy()
+ ->addMonthsWithoutOverflow(1);
+
+ $entitlement->save();
+
+ $entitlementTransactions[] = $entitlement->createTransaction(
+ \App\Transaction::ENTITLEMENT_BILLED,
+ 0
+ );
+
+ continue;
+ }
+
$diff = $entitlement->updated_at->diffInMonths(Carbon::now());
$cost = (int) ($entitlement->cost * $discount * $diff);
@@ -93,7 +113,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
Details
Attached
Mime Type
text/plain
Expires
Tue, Apr 14, 12:33 PM (2 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18855147
Default Alt Text
D1504.1776169987.diff (2 KB)
Attached To
Mode
D1504: Establish a month of free trial
Attached
Detach File
Event Timeline