-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added issue checks for temporary codes for access cards
- Loading branch information
Showing
5 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace App\Issues\Checkers\AccessCards; | ||
|
||
|
||
use App\DataCache\AggregateCustomerData; | ||
use App\DataCache\MemberData; | ||
use App\Issues\Checkers\IssueCheck; | ||
use App\Issues\Checkers\IssueCheckTrait; | ||
use App\Issues\Types\AccessCards\CustomerHasBothCardAndTemporaryCode; | ||
use App\Issues\Types\AccessCards\NoTemporaryCodeOnCustomerWithoutIdCheck; | ||
use App\Models\UserMembership; | ||
use Illuminate\Support\Collection; | ||
|
||
class TemporaryCodeIssues implements IssueCheck | ||
{ | ||
use IssueCheckTrait; | ||
|
||
public function __construct( | ||
private readonly AggregateCustomerData $aggregateCustomerData, | ||
) | ||
{ | ||
} | ||
|
||
protected function generateIssues(): void | ||
{ | ||
/** @var Collection<MemberData> $members */ | ||
$members = $this->aggregateCustomerData->get(); | ||
|
||
foreach ($members as $member) { | ||
/** @var MemberData $member */ | ||
if ($member->cards->count() > 0 && ! is_null($member->accessCardTemporaryCode)) { | ||
$this->issues->add(new CustomerHasBothCardAndTemporaryCode($member)); | ||
} | ||
|
||
$fullMemberUserMembership = $member->userMemberships | ||
->first(fn($um) => $um['plan_id'] == UserMembership::MEMBERSHIP_FULL_MEMBER); | ||
|
||
if (! $member->idChecked && | ||
is_null($member->accessCardTemporaryCode) && | ||
! is_null($fullMemberUserMembership)) { | ||
// This issue is important because they won't be able to get their card once their id is checked | ||
$this->issues->add(new NoTemporaryCodeOnCustomerWithoutIdCheck($member)); | ||
} | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
app/Issues/Types/AccessCards/CustomerHasBothCardAndTemporaryCode.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Issues\Types\AccessCards; | ||
|
||
use App\DataCache\MemberData; | ||
use App\Issues\Types\IssueBase; | ||
|
||
class CustomerHasBothCardAndTemporaryCode extends IssueBase | ||
{ | ||
public function __construct( | ||
private readonly MemberData $member | ||
) | ||
{ | ||
} | ||
|
||
public static function getIssueNumber(): int | ||
{ | ||
return 7; // auto-generated based on namespace and existing issues | ||
} | ||
|
||
public static function getIssueTitle(): string | ||
{ | ||
return "Access Cards: Customer has both card and temporary code"; | ||
} | ||
|
||
public function getIssueText(): string | ||
{ | ||
return "{$this->member->full_name} has both an access card and a temporary code"; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
app/Issues/Types/AccessCards/NoTemporaryCodeOnCustomerWithoutIdCheck.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Issues\Types\AccessCards; | ||
|
||
use App\DataCache\MemberData; | ||
use App\Issues\Types\IssueBase; | ||
|
||
class NoTemporaryCodeOnCustomerWithoutIdCheck extends IssueBase | ||
{ | ||
public function __construct( | ||
private readonly MemberData $member | ||
) | ||
{ | ||
} | ||
|
||
public static function getIssueNumber(): int | ||
{ | ||
return 8; // auto-generated based on namespace and existing issues | ||
} | ||
|
||
public static function getIssueTitle(): string | ||
{ | ||
return "Access Cards: No temporary code on customer without id check"; | ||
} | ||
|
||
public function getIssueText(): string | ||
{ | ||
return "{$this->member->full_name} has no temporary code to get their access card and has not had their id checked."; | ||
} | ||
} |