fix financial and certificates
This commit is contained in:
@@ -24,6 +24,9 @@ use App\Services\Promotions\PromotionEnrollmentService;
|
||||
use App\Services\Promotions\PromotionQueryService;
|
||||
use App\Services\Promotions\PromotionReminderService;
|
||||
use App\Services\Promotions\PromotionStatusService;
|
||||
use App\Services\Promotions\Placement\SectionPlacementPreviewService;
|
||||
use App\Models\SectionPlacementBatch;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -42,7 +45,8 @@ class AdministratorPromotionController extends BaseApiController
|
||||
private PromotionEnrollmentService $enrollmentService,
|
||||
private PromotionReminderService $reminders,
|
||||
private PromotionAuditService $audit,
|
||||
private LevelProgressionService $progression
|
||||
private LevelProgressionService $progression,
|
||||
private SectionPlacementPreviewService $sectionPlacement
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
@@ -133,6 +137,69 @@ class AdministratorPromotionController extends BaseApiController
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function createPlacementPreview(Request $request): JsonResponse
|
||||
{
|
||||
$payload = $request->validate([
|
||||
'from_school_year' => ['required', 'string', 'max:25'],
|
||||
'to_school_year' => ['required', 'string', 'max:25'],
|
||||
'from_grade_level_id' => ['nullable', 'integer', 'min:1'],
|
||||
'to_grade_level_id' => ['required', 'integer', 'min:1'],
|
||||
]);
|
||||
|
||||
try {
|
||||
$batch = $this->sectionPlacement->createDraft(
|
||||
$payload['from_school_year'],
|
||||
$payload['to_school_year'],
|
||||
$payload['from_grade_level_id'] ?? null,
|
||||
$payload['to_grade_level_id'] ?? null,
|
||||
$this->getCurrentUserId()
|
||||
);
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('Section placement preview generation failed', ['exception' => $e]);
|
||||
return response()->json([
|
||||
'ok' => false,
|
||||
'message' => $e->getMessage(),
|
||||
], Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'ok' => true,
|
||||
'data' => $this->sectionPlacement->previewPayload($batch),
|
||||
]);
|
||||
}
|
||||
|
||||
public function showPlacementBatch(int $batchId): JsonResponse
|
||||
{
|
||||
$batch = SectionPlacementBatch::query()->find($batchId);
|
||||
if (!$batch) {
|
||||
return response()->json(['ok' => false, 'message' => 'Placement batch not found.'], Response::HTTP_NOT_FOUND);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'ok' => true,
|
||||
'data' => $this->sectionPlacement->previewPayload($batch),
|
||||
]);
|
||||
}
|
||||
|
||||
public function finalizePlacementBatch(int $batchId): JsonResponse
|
||||
{
|
||||
try {
|
||||
$batch = $this->sectionPlacement->finalize($batchId, $this->getCurrentUserId());
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('Section placement finalization failed', ['batch_id' => $batchId, 'exception' => $e]);
|
||||
return response()->json([
|
||||
'ok' => false,
|
||||
'message' => $e->getMessage(),
|
||||
], Response::HTTP_CONFLICT);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'ok' => true,
|
||||
'data' => $this->sectionPlacement->previewPayload($batch),
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateStatus(UpdatePromotionStatusRequest $request, int $promotionId): JsonResponse
|
||||
{
|
||||
$record = $this->findOrFail($promotionId);
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\Administrator;
|
||||
|
||||
use App\Http\Controllers\Api\Core\BaseApiController;
|
||||
use App\Http\Requests\Administrator\TrophyReportRequest;
|
||||
use App\Services\Administrator\Trophy\TrophyReportService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class TrophyController extends BaseApiController
|
||||
{
|
||||
public function __construct(private TrophyReportService $service)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index(TrophyReportRequest $request): JsonResponse
|
||||
{
|
||||
$payload = $request->validated();
|
||||
|
||||
return response()->json([
|
||||
'ok' => true,
|
||||
'data' => $this->service->projection(
|
||||
$payload['school_year'] ?? null,
|
||||
isset($payload['percentile']) ? (float) $payload['percentile'] : null
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
public function winners(TrophyReportRequest $request): JsonResponse
|
||||
{
|
||||
$payload = $request->validated();
|
||||
|
||||
return response()->json([
|
||||
'ok' => true,
|
||||
'data' => $this->service->winners(
|
||||
$payload['school_year'] ?? null,
|
||||
isset($payload['percentile']) ? (float) $payload['percentile'] : null
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
public function final(TrophyReportRequest $request): JsonResponse
|
||||
{
|
||||
$payload = $request->validated();
|
||||
|
||||
return response()->json([
|
||||
'ok' => true,
|
||||
'data' => $this->service->final(
|
||||
$payload['school_year'] ?? null,
|
||||
isset($payload['percentile']) ? (float) $payload['percentile'] : null
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user