Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117764551
D5706.1775227430.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
D5706.1775227430.diff
View Options
diff --git a/src/app/Http/Resources/WalletInfoResource.php b/src/app/Http/Resources/WalletInfoResource.php
--- a/src/app/Http/Resources/WalletInfoResource.php
+++ b/src/app/Http/Resources/WalletInfoResource.php
@@ -15,6 +15,8 @@
*/
class WalletInfoResource extends WalletResource
{
+ protected ?string $next_payment_date;
+
/**
* Transform the resource into an array.
*/
@@ -26,11 +28,15 @@
$providerLink = $provider->customerLink($this->resource);
}
+ $notice = $this->getWalletNotice();
+
return [
$this->merge(parent::toArray($request)),
- // Wallet status notice
- 'notice' => $this->getWalletNotice(),
+ // @var string|null Next payment date (Y-m-d) if expected
+ 'nextPaymentDate' => $this->next_payment_date,
+ // @var string|null Wallet status notice
+ 'notice' => $notice,
// @var WalletMandateResource Recurring payment mandate information
'mandate' => $this->when($isAdmin, $mandate ?? null),
// Link to the customer page at the payment provider site
@@ -43,6 +49,8 @@
*/
protected function getWalletNotice(): ?string
{
+ $this->next_payment_date = null;
+
// there is no credit
if ($this->resource->balance < 0) {
return Controller::trans('app.wallet-notice-nocredit');
@@ -68,6 +76,8 @@
}
if ($until = $this->resource->balanceLastsUntil()) {
+ $this->next_payment_date = $until->toDateString();
+
if ($until->isToday()) {
return Controller::trans('app.wallet-notice-today');
}
diff --git a/src/tests/Feature/Controller/WalletsTest.php b/src/tests/Feature/Controller/WalletsTest.php
--- a/src/tests/Feature/Controller/WalletsTest.php
+++ b/src/tests/Feature/Controller/WalletsTest.php
@@ -324,10 +324,12 @@
*/
public function testShow(): void
{
+ Carbon::setTestNow(Carbon::createFromDate(2022, 2, 2));
+
$john = $this->getTestUser('john@kolab.org');
$jack = $this->getTestUser('jack@kolab.org');
$wallet = $john->wallets()->first();
- $wallet->balance = -100;
+ $wallet->balance = 1000;
$wallet->save();
// Accessing a wallet of someone else
@@ -348,7 +350,8 @@
$this->assertSame('CHF', $json['currency']);
$this->assertSame($wallet->balance, $json['balance']);
$this->assertTrue(empty($json['description']));
- $this->assertTrue(!empty($json['notice']));
+ $this->assertStringContainsString('until about 2025-08-11', $json['notice']);
+ $this->assertSame('2025-08-11', $json['nextPaymentDate']);
}
/**
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Apr 3, 2:43 PM (20 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18824345
Default Alt Text
D5706.1775227430.diff (2 KB)
Attached To
Mode
D5706: Add nextPaymentDate property to the WalletInfoResource
Attached
Detach File
Event Timeline