Fix Laravel Pint formatting
This commit is contained in:
@@ -8,7 +8,6 @@ use App\Models\ParentAccount;
|
||||
use App\Models\ParentBalanceTransfer;
|
||||
use App\Models\SchoolYear;
|
||||
use App\Services\Promotions\LevelProgressionService;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
@@ -19,8 +18,7 @@ class SchoolYearClosureService
|
||||
public function __construct(
|
||||
private SchoolYearResolver $resolver,
|
||||
private LevelProgressionService $progression
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function list(): array
|
||||
{
|
||||
@@ -235,7 +233,7 @@ class SchoolYearClosureService
|
||||
{
|
||||
$year = $this->findOrFail($id);
|
||||
$validation = $this->validateClose($id, $payload);
|
||||
if (!$validation['can_close']) {
|
||||
if (! $validation['can_close']) {
|
||||
throw ValidationException::withMessages(['school_year' => $validation['errors']]);
|
||||
}
|
||||
|
||||
@@ -249,7 +247,7 @@ class SchoolYearClosureService
|
||||
|
||||
$newYearPayload = $payload['new_school_year'];
|
||||
$promotionPreview = $this->buildPromotionPreview($year->name, $newYearPayload['name']);
|
||||
$balances = !empty($payload['transfer_unpaid_balances'])
|
||||
$balances = ! empty($payload['transfer_unpaid_balances'])
|
||||
? $this->buildParentBalanceRows($year->name, $newYearPayload['name'])
|
||||
: ['rows' => [], 'summary' => ['net_balance_to_transfer' => 0]];
|
||||
|
||||
@@ -291,7 +289,7 @@ class SchoolYearClosureService
|
||||
Configuration::setConfigValueByKey('school_year', $newYear->name);
|
||||
|
||||
$promotionCounts = $this->applyPromotions($promotionPreview['rows'], $newYear->name, $newYear->start_date, $actorId);
|
||||
$balanceCounts = !empty($payload['transfer_unpaid_balances'])
|
||||
$balanceCounts = ! empty($payload['transfer_unpaid_balances'])
|
||||
? $this->applyBalanceTransfers($balances['rows'], $year->name, $newYear->name, $actorId)
|
||||
: [
|
||||
'transferred_parents' => 0,
|
||||
@@ -396,8 +394,9 @@ class SchoolYearClosureService
|
||||
$errors[] = 'New school year name is required.';
|
||||
}
|
||||
|
||||
if (!$startDate || !$endDate) {
|
||||
if (! $startDate || ! $endDate) {
|
||||
$errors[] = 'New school year start_date and end_date are required.';
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
@@ -457,7 +456,7 @@ class SchoolYearClosureService
|
||||
];
|
||||
|
||||
foreach ($tables as $mapping) {
|
||||
if (!Schema::hasTable($mapping['table'])) {
|
||||
if (! Schema::hasTable($mapping['table'])) {
|
||||
continue;
|
||||
}
|
||||
if (DB::table($mapping['table'])->where($mapping['column'], $schoolYear)->exists()) {
|
||||
@@ -490,7 +489,7 @@ class SchoolYearClosureService
|
||||
$assignmentByStudent = [];
|
||||
foreach ($assignments as $assignment) {
|
||||
$studentId = (int) $assignment->student_id;
|
||||
if (!isset($assignmentByStudent[$studentId])) {
|
||||
if (! isset($assignmentByStudent[$studentId])) {
|
||||
$assignmentByStudent[$studentId] = $assignment;
|
||||
}
|
||||
}
|
||||
@@ -506,7 +505,7 @@ class SchoolYearClosureService
|
||||
$enrollmentByStudent = [];
|
||||
foreach ($enrollments as $enrollment) {
|
||||
$studentId = (int) $enrollment->student_id;
|
||||
if (!isset($enrollmentByStudent[$studentId])) {
|
||||
if (! isset($enrollmentByStudent[$studentId])) {
|
||||
$enrollmentByStudent[$studentId] = $enrollment;
|
||||
}
|
||||
}
|
||||
@@ -521,7 +520,7 @@ class SchoolYearClosureService
|
||||
$decisionByStudent = [];
|
||||
foreach ($decisions as $decision) {
|
||||
$studentId = (int) $decision->student_id;
|
||||
if (!isset($decisionByStudent[$studentId])) {
|
||||
if (! isset($decisionByStudent[$studentId])) {
|
||||
$decisionByStudent[$studentId] = $decision;
|
||||
}
|
||||
}
|
||||
@@ -539,7 +538,7 @@ class SchoolYearClosureService
|
||||
|
||||
foreach ($studentIds as $studentId) {
|
||||
$student = $students->get($studentId);
|
||||
if (!$student) {
|
||||
if (! $student) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -599,7 +598,7 @@ class SchoolYearClosureService
|
||||
|
||||
$row = [
|
||||
'student_id' => $studentId,
|
||||
'student_name' => trim((string) ($student->firstname ?? '') . ' ' . (string) ($student->lastname ?? '')),
|
||||
'student_name' => trim((string) ($student->firstname ?? '').' '.(string) ($student->lastname ?? '')),
|
||||
'parent_id' => (int) ($student->parent_id ?? 0) ?: null,
|
||||
'current_grade' => $progression['current_level_name'] ?? ($currentClass->class_name ?? null),
|
||||
'current_class' => $section->class_section_name ?? null,
|
||||
@@ -645,7 +644,7 @@ class SchoolYearClosureService
|
||||
? (float) $invoice->balance
|
||||
: (float) ($invoice->total_amount ?? 0) - (float) ($invoice->paid_amount ?? 0);
|
||||
|
||||
if (!isset($byParent[$parentId])) {
|
||||
if (! isset($byParent[$parentId])) {
|
||||
$existing = ParentBalanceTransfer::query()
|
||||
->where('parent_id', $parentId)
|
||||
->where('from_school_year', $fromSchoolYear)
|
||||
@@ -737,7 +736,7 @@ class SchoolYearClosureService
|
||||
->orderBy('class_section_id')
|
||||
->first();
|
||||
|
||||
if (!$section) {
|
||||
if (! $section) {
|
||||
return [null, null];
|
||||
}
|
||||
|
||||
@@ -757,13 +756,13 @@ class SchoolYearClosureService
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$action = $row['promotion_action'];
|
||||
if (!isset($counts[$action])) {
|
||||
if (! isset($counts[$action])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$counts[$action]++;
|
||||
|
||||
if (!in_array($action, ['promote', 'repeat'], true)) {
|
||||
if (! in_array($action, ['promote', 'repeat'], true)) {
|
||||
$this->logAudit(
|
||||
$actorId,
|
||||
'school_year_promotion_decision_applied',
|
||||
@@ -773,6 +772,7 @@ class SchoolYearClosureService
|
||||
null,
|
||||
['action' => $action, 'new_school_year' => $newSchoolYear]
|
||||
);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -781,7 +781,7 @@ class SchoolYearClosureService
|
||||
->where('school_year', $newSchoolYear)
|
||||
->first();
|
||||
|
||||
if (!$existingEnrollment) {
|
||||
if (! $existingEnrollment) {
|
||||
DB::table('enrollments')->insert([
|
||||
'student_id' => $row['student_id'],
|
||||
'class_section_id' => $row['target_class_section_id'],
|
||||
@@ -805,7 +805,7 @@ class SchoolYearClosureService
|
||||
->where('class_section_id', $row['target_class_section_id'])
|
||||
->exists();
|
||||
|
||||
if (!$existingAssignment) {
|
||||
if (! $existingAssignment) {
|
||||
DB::table('student_class')->insert([
|
||||
'student_id' => $row['student_id'],
|
||||
'class_section_id' => $row['target_class_section_id'],
|
||||
@@ -950,7 +950,7 @@ class SchoolYearClosureService
|
||||
|
||||
private function countPendingPayments(string $schoolYear): int
|
||||
{
|
||||
if (!Schema::hasTable('payments')) {
|
||||
if (! Schema::hasTable('payments')) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -978,7 +978,7 @@ class SchoolYearClosureService
|
||||
|
||||
private function countDuplicateParentAccounts(): int
|
||||
{
|
||||
if (!Schema::hasTable('parent_accounts')) {
|
||||
if (! Schema::hasTable('parent_accounts')) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -992,11 +992,11 @@ class SchoolYearClosureService
|
||||
private function resolveParentName(int $parentId): ?string
|
||||
{
|
||||
$row = DB::table('users')->where('id', $parentId)->first();
|
||||
if (!$row) {
|
||||
if (! $row) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return trim((string) ($row->firstname ?? '') . ' ' . (string) ($row->lastname ?? ''));
|
||||
return trim((string) ($row->firstname ?? '').' '.(string) ($row->lastname ?? ''));
|
||||
}
|
||||
|
||||
private function resolveStudentNames(int $parentId, string $schoolYear): array
|
||||
@@ -1015,7 +1015,7 @@ class SchoolYearClosureService
|
||||
return DB::table('students')
|
||||
->whereIn('id', $studentIds)
|
||||
->get()
|
||||
->map(fn ($student) => trim((string) ($student->firstname ?? '') . ' ' . (string) ($student->lastname ?? '')))
|
||||
->map(fn ($student) => trim((string) ($student->firstname ?? '').' '.(string) ($student->lastname ?? '')))
|
||||
->filter()
|
||||
->values()
|
||||
->all();
|
||||
@@ -1023,7 +1023,7 @@ class SchoolYearClosureService
|
||||
|
||||
private function presentSchoolYear(?SchoolYear $year): ?array
|
||||
{
|
||||
if (!$year) {
|
||||
if (! $year) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1048,7 +1048,7 @@ class SchoolYearClosureService
|
||||
?array $newValue,
|
||||
?array $metadata = null
|
||||
): void {
|
||||
if (!Schema::hasTable('audit_logs')) {
|
||||
if (! Schema::hasTable('audit_logs')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user