Page MenuHomePhorge

D1096.1775191534.diff
No OneTemporary

Authored By
Unknown
Size
6 KB
Referenced Files
None
Subscribers
None

D1096.1775191534.diff

diff --git a/src/app/Wallet.php b/src/app/Wallet.php
--- a/src/app/Wallet.php
+++ b/src/app/Wallet.php
@@ -68,12 +68,12 @@
}
// This entitlement was created, or billed last, less than a month ago.
- if ($entitlement->updated_at > Carbon::now()->subMonths(1)) {
+ if ($entitlement->updated_at > Carbon::now()->subMonthsWithoutOverflow(1)) {
continue;
}
// created more than a month ago -- was it billed?
- if ($entitlement->updated_at <= Carbon::now()->subMonths(1)) {
+ if ($entitlement->updated_at <= Carbon::now()->subMonthsWithoutOverflow(1)) {
$diff = $entitlement->updated_at->diffInMonths(Carbon::now());
$charges += $entitlement->cost * $diff;
@@ -83,7 +83,7 @@
continue;
}
- $entitlement->updated_at = $entitlement->updated_at->copy()->addMonths($diff);
+ $entitlement->updated_at = $entitlement->updated_at->copy()->addMonthsWithoutOverflow($diff);
$entitlement->save();
$this->debit($entitlement->cost * $diff);
diff --git a/src/database/seeds/UserSeeder.php b/src/database/seeds/UserSeeder.php
--- a/src/database/seeds/UserSeeder.php
+++ b/src/database/seeds/UserSeeder.php
@@ -83,8 +83,8 @@
$john->assignPackage($package_kolab, $jack);
foreach ($john->entitlements as $entitlement) {
- $entitlement->created_at = Carbon::now()->subMonths(1);
- $entitlement->updated_at = Carbon::now()->subMonths(1);
+ $entitlement->created_at = Carbon::now()->subMonthsWithoutOverflow(1);
+ $entitlement->updated_at = Carbon::now()->subMonthsWithoutOverflow(1);
$entitlement->save();
}
diff --git a/src/tests/Feature/BillingTest.php b/src/tests/Feature/BillingTest.php
--- a/src/tests/Feature/BillingTest.php
+++ b/src/tests/Feature/BillingTest.php
@@ -71,7 +71,7 @@
{
$this->backdateEntitlements(
$this->wallet->entitlements,
- Carbon::now()->subMonths(1)->addDays(1)
+ Carbon::now()->subMonthsWithoutOverflow(1)->addDays(1)
);
$this->assertEquals(0, $this->wallet->expectedCharges());
@@ -82,7 +82,7 @@
*/
public function testFullTrial(): void
{
- $this->backdateEntitlements($this->wallet->entitlements, Carbon::now()->subMonths(1));
+ $this->backdateEntitlements($this->wallet->entitlements, Carbon::now()->subMonthsWithoutOverflow(1));
$this->assertEquals(999, $this->wallet->expectedCharges());
}
@@ -94,7 +94,7 @@
{
$this->backdateEntitlements(
$this->wallet->entitlements,
- Carbon::now()->subMonths(1)->subDays(1)
+ Carbon::now()->subMonthsWithoutOverflow(1)->subDays(1)
);
$this->assertEquals(999, $this->wallet->expectedCharges());
@@ -108,7 +108,7 @@
{
$this->backdateEntitlements(
$this->wallet->entitlements,
- Carbon::now()->subMonths(1)->subDays(1)
+ Carbon::now()->subMonthsWithoutOverflow(1)->subDays(1)
);
$this->assertEquals(999, $this->wallet->expectedCharges());
@@ -127,7 +127,7 @@
$this->backdateEntitlements(
[$entitlement],
- Carbon::now()->subMonths(1)->subDays(1)
+ Carbon::now()->subMonthsWithoutOverflow(1)->subDays(1)
);
$this->assertEquals(1024, $this->wallet->expectedCharges());
@@ -139,7 +139,7 @@
*/
public function testAddtStorageLate(): void
{
- $this->backdateEntitlements($this->wallet->entitlements, Carbon::now()->subMonths(1));
+ $this->backdateEntitlements($this->wallet->entitlements, Carbon::now()->subMonthsWithoutOverflow(1));
$this->assertEquals(999, $this->wallet->expectedCharges());
@@ -163,7 +163,7 @@
public function testFifthWeek(): void
{
$targetDateA = Carbon::now()->subWeeks(5);
- $targetDateB = $targetDateA->copy()->addMonths(1);
+ $targetDateB = $targetDateA->copy()->addMonthsWithoutOverflow(1);
$this->backdateEntitlements($this->wallet->entitlements, $targetDateA);
@@ -181,7 +181,7 @@
public function testSecondMonth(): void
{
- $this->backdateEntitlements($this->wallet->entitlements, Carbon::now()->subMonths(2));
+ $this->backdateEntitlements($this->wallet->entitlements, Carbon::now()->subMonthsWithoutOverflow(2));
$this->assertCount(4, $this->wallet->entitlements);
@@ -199,7 +199,7 @@
]
);
- $this->backdateEntitlements([$entitlement], Carbon::now()->subMonths(1));
+ $this->backdateEntitlements([$entitlement], Carbon::now()->subMonthsWithoutOverflow(1));
$this->assertEquals(2023, $this->wallet->expectedCharges());
}
@@ -237,7 +237,7 @@
$wallet_id = $wallet->id;
- $this->backdateEntitlements($wallet->entitlements, Carbon::now()->subMonths(1));
+ $this->backdateEntitlements($wallet->entitlements, Carbon::now()->subMonthsWithoutOverflow(1));
$this->assertEquals(500, $wallet->expectedCharges());
}
diff --git a/src/tests/Feature/EntitlementTest.php b/src/tests/Feature/EntitlementTest.php
--- a/src/tests/Feature/EntitlementTest.php
+++ b/src/tests/Feature/EntitlementTest.php
@@ -65,7 +65,7 @@
$this->assertCount(2, $sku_mailbox->entitlements()->where('wallet_id', $wallet->id)->get());
$this->assertCount(9, $wallet->entitlements);
- $this->backdateEntitlements($owner->entitlements, Carbon::now()->subMonths(1));
+ $this->backdateEntitlements($owner->entitlements, Carbon::now()->subMonthsWithoutOverflow(1));
$wallet->chargeEntitlements();
diff --git a/src/tests/Feature/SkuTest.php b/src/tests/Feature/SkuTest.php
--- a/src/tests/Feature/SkuTest.php
+++ b/src/tests/Feature/SkuTest.php
@@ -39,7 +39,7 @@
$user = $user->assignPackage($package);
- $this->backdateEntitlements($user->fresh()->entitlements, Carbon::now()->subMonths(1));
+ $this->backdateEntitlements($user->fresh()->entitlements, Carbon::now()->subMonthsWithoutOverflow(1));
$wallet->chargeEntitlements();

File Metadata

Mime Type
text/plain
Expires
Fri, Apr 3, 4:45 AM (6 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18822613
Default Alt Text
D1096.1775191534.diff (6 KB)

Event Timeline