Fix Pint formatting
This commit is contained in:
@@ -15,20 +15,19 @@ 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);
|
||||
}
|
||||
|
||||
@@ -85,15 +84,17 @@ 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;
|
||||
}
|
||||
|
||||
@@ -228,13 +229,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);
|
||||
|
||||
@@ -298,14 +299,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;
|
||||
}
|
||||
|
||||
@@ -330,9 +331,10 @@ 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;
|
||||
}
|
||||
|
||||
@@ -353,7 +355,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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,9 +364,10 @@ 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;
|
||||
}
|
||||
|
||||
@@ -385,6 +388,7 @@ class PaymentNotificationService
|
||||
if (function_exists('user_timezone')) {
|
||||
return (string) user_timezone();
|
||||
}
|
||||
|
||||
return (string) (config('app.timezone') ?: 'UTC');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user