fix gitlab tests

This commit is contained in:
root
2026-06-09 02:32:58 -04:00
parent 20a0b6c4e5
commit 6def9993da
1489 changed files with 10449 additions and 11356 deletions
@@ -15,19 +15,20 @@ class PaymentNotificationService
public function __construct(
private EmailService $emailService,
private PaymentNotificationDispatchService $dispatchService
) {}
) {
}
public function listLogs(?string $from, ?string $to, ?string $type): array
{
$query = PaymentNotificationLog::query()->with('parent')->orderByDesc('sent_at');
if (! empty($from)) {
if (!empty($from)) {
$query->where('sent_at', '>=', $from);
}
if (! empty($to)) {
if (!empty($to)) {
$query->where('sent_at', '<=', $to);
}
if (! empty($type)) {
if (!empty($type)) {
$query->where('type', $type);
}
@@ -84,17 +85,15 @@ class PaymentNotificationService
$type = $this->resolveType($parentId, $schoolYear, $typeInput);
if (! $force && PaymentNotificationLog::existsForPeriod($parentId, $year, $month, $type)) {
if (!$force && PaymentNotificationLog::existsForPeriod($parentId, $year, $month, $type)) {
$results['skipped']++;
$results['details'][] = ['parent_id' => $parentId, 'result' => 'already_sent'];
return $results;
}
if ($balance <= 0 && ! $force) {
if ($balance <= 0 && !$force) {
$results['skipped']++;
$results['details'][] = ['parent_id' => $parentId, 'result' => 'no_balance'];
return $results;
}
@@ -229,13 +228,13 @@ class PaymentNotificationService
private function composeMessage(int $parentId, float $balance, string $schoolYear, \DateTime $now): array
{
$user = User::query()->find($parentId);
$parentName = $user ? trim(($user->firstname ?? '').' '.($user->lastname ?? '')) : '';
$parentName = $user ? trim(($user->firstname ?? '') . ' ' . ($user->lastname ?? '')) : '';
$greeting = $parentName !== '' ? "Dear {$parentName}," : 'Dear Parent,';
$monthYear = $now->format('F Y');
$subject = sprintf('Monthly Tuition Reminder — %s', $schoolYear);
$balanceFmt = '$'.number_format($balance, 2);
$intro = 'This is your monthly installment reminder for '.$schoolYear.'.';
$balanceFmt = '$' . number_format($balance, 2);
$intro = 'This is your monthly installment reminder for ' . $schoolYear . '.';
$installmentInfo = $this->computeInstallmentSuggestion($balance);
@@ -299,14 +298,14 @@ class PaymentNotificationService
'remaining_installments' => $remainingInstallments,
'max_installments' => $maxInstallments,
'installment_due' => round($installmentDue, 2),
'installment_due_fmt' => '$'.number_format($installmentDue, 2),
'installment_due_fmt' => '$' . number_format($installmentDue, 2),
];
}
private function getSecondaryGuardianEmail(int $primaryUserId): ?string
{
$row = DB::table('family_guardians')->where('user_id', $primaryUserId)->first();
if (! $row || empty($row->family_id)) {
if (!$row || empty($row->family_id)) {
return null;
}
@@ -331,10 +330,9 @@ class PaymentNotificationService
private function getUserEmail(int $userId): ?string
{
$email = (string) (DB::table('users')->where('id', $userId)->value('email') ?? '');
if ($email === '' || ! filter_var($email, FILTER_VALIDATE_EMAIL)) {
if ($email === '' || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
return null;
}
return $email;
}
@@ -355,7 +353,7 @@ class PaymentNotificationService
);
}
} catch (\Throwable $e) {
Log::warning('Unable to notify heads of finance: '.$e->getMessage());
Log::warning('Unable to notify heads of finance: ' . $e->getMessage());
}
}
@@ -364,10 +362,9 @@ class PaymentNotificationService
$base['sent'] += $update['sent'] ?? 0;
$base['skipped'] += $update['skipped'] ?? 0;
$base['failed'] += $update['failed'] ?? 0;
if (! empty($update['details'])) {
if (!empty($update['details'])) {
$base['details'] = array_merge($base['details'], $update['details']);
}
return $base;
}
@@ -388,7 +385,6 @@ class PaymentNotificationService
if (function_exists('user_timezone')) {
return (string) user_timezone();
}
return (string) (config('app.timezone') ?: 'UTC');
}
}