DONE: fix naming, add transaction for completion of membership application (#12)
Co-authored-by: ISMAIL MASSERAN <topaz@ISMAILs-Macbook.local> Reviewed-on: #12
This commit was merged in pull request #12.
This commit is contained in:
@@ -254,12 +254,8 @@ class MembershipApplicationService
|
||||
});
|
||||
}
|
||||
|
||||
public function complete(
|
||||
MembershipApplication $application,
|
||||
User $processedBy,
|
||||
string $boardMeetingReference,
|
||||
string $boardMeetingDate,
|
||||
): MembershipApplication {
|
||||
public function complete(MembershipApplication $application, User $processedBy, string $boardMeetingReference, string $boardMeetingDate,): MembershipApplication
|
||||
{
|
||||
if ($application->status !== ApplicationStatus::PendingNotification) {
|
||||
throw ValidationException::withMessages([
|
||||
'status' => ['Permohonan ini tidak boleh diselesaikan pada masa ini.'],
|
||||
@@ -272,7 +268,7 @@ class MembershipApplicationService
|
||||
]);
|
||||
}
|
||||
|
||||
return DB::transaction(function () use ($application, $boardMeetingReference, $boardMeetingDate) {
|
||||
return DB::transaction(function () use ($application, $processedBy, $boardMeetingReference, $boardMeetingDate) {
|
||||
$plainPassword = null;
|
||||
|
||||
if ($application->board_result === BoardResult::Pass->value && ! $application->user_id) {
|
||||
@@ -286,6 +282,18 @@ class MembershipApplicationService
|
||||
|
||||
$this->sendResultNotification($application, $resultLetter, $plainPassword);
|
||||
|
||||
$application->reviews()->create([
|
||||
'stage' => ReviewStage::Completion,
|
||||
'decision' => $application->board_result,
|
||||
'remarks' => sprintf(
|
||||
'Rujukan mesyuarat lembaga: %s, Tarikh mesyuarat: %s',
|
||||
$boardMeetingReference,
|
||||
$boardMeetingDate,
|
||||
),
|
||||
'reviewer_id' => $processedBy->id,
|
||||
'reviewed_at' => now(),
|
||||
]);
|
||||
|
||||
$application->update([
|
||||
'status' => ApplicationStatus::Completed,
|
||||
'completed_at' => now()->toDateTimeString(),
|
||||
@@ -302,12 +310,8 @@ class MembershipApplicationService
|
||||
* failed: list<array{id: string, application_number: string|null, message: string}>
|
||||
* }
|
||||
*/
|
||||
public function completeBatch(
|
||||
array $applicationIds,
|
||||
User $processedBy,
|
||||
string $boardMeetingReference,
|
||||
string $boardMeetingDate,
|
||||
): array {
|
||||
public function completeBatch(array $applicationIds, User $processedBy, string $boardMeetingReference, string $boardMeetingDate): array
|
||||
{
|
||||
$succeeded = [];
|
||||
$failed = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user