fix tests

This commit is contained in:
root
2026-06-11 11:46:12 -04:00
parent c91fa2ce4d
commit 5ead80fdc7
1489 changed files with 11349 additions and 10305 deletions
+22 -13
View File
@@ -13,21 +13,21 @@ class PaymentEventService
private EmailService $emailService,
private UserNotificationDispatchService $notifier,
private ApplicationUrlService $urls,
) {
}
) {}
public function paymentReceived(array $data, array $studentdata = []): array
{
$parentName = trim((string) ($data['firstname'] ?? '') . ' ' . (string) ($data['lastname'] ?? ''));
$parentName = trim((string) ($data['firstname'] ?? '').' '.(string) ($data['lastname'] ?? ''));
$fmtMoney = static fn ($v) => '$' . number_format((float) $v, 2);
$fmtMoney = static fn ($v) => '$'.number_format((float) $v, 2);
$fmtDateTz = static function (?string $s): string {
if (!$s) {
if (! $s) {
return '';
}
$dt = new \DateTime($s, new \DateTimeZone('UTC'));
$tzName = (string) (config('School')->attendance['timezone'] ?? user_timezone());
$dt->setTimezone(new \DateTimeZone($tzName ?: 'UTC'));
return $dt->format('m-d-Y h:i A');
};
@@ -94,30 +94,33 @@ class PaymentEventService
public function extraCharge(array $data, array $studentdata = []): array
{
$fmtMoney = static fn ($v) => '$' . number_format((float) $v, 2);
$fmtMoney = static fn ($v) => '$'.number_format((float) $v, 2);
$fmtFromUtc = static function (?string $s, string $fmt = 'm-d-Y h:i A'): string {
if (!$s) {
if (! $s) {
return '';
}
try {
$dt = new \DateTime($s, new \DateTimeZone('UTC'));
$tzName = (string) (config('School')->attendance['timezone'] ?? user_timezone());
$dt->setTimezone(new \DateTimeZone($tzName ?: 'UTC'));
return $dt->format($fmt);
} catch (\Throwable $e) {
Log::error('extraCharge date error: ' . $e->getMessage());
Log::error('extraCharge date error: '.$e->getMessage());
return '';
}
};
$fmtDueLocal = static function (?string $s): string {
if (!$s) {
if (! $s) {
return '';
}
try {
if (strlen($s) <= 10) {
$tzName = (string) (config('School')->attendance['timezone'] ?? user_timezone());
$dt = \DateTime::createFromFormat('Y-m-d', $s, new \DateTimeZone($tzName ?: 'UTC'));
return $dt ? $dt->format('m-d-Y') : '';
}
@@ -125,19 +128,22 @@ class PaymentEventService
$dt = new \DateTime($s);
$tzName = (string) (config('School')->attendance['timezone'] ?? user_timezone());
$dt->setTimezone(new \DateTimeZone($tzName ?: 'UTC'));
return $dt->format('m-d-Y h:i A');
}
$tzName = (string) (config('School')->attendance['timezone'] ?? user_timezone());
$dt = new \DateTime($s, new \DateTimeZone($tzName ?: 'UTC'));
return $dt->format('m-d-Y h:i A');
} catch (\Throwable $e) {
Log::error('extraCharge due date error: ' . $e->getMessage());
Log::error('extraCharge due date error: '.$e->getMessage());
return '';
}
};
$parentName = trim((string) ($data['firstname'] ?? '') . ' ' . (string) ($data['lastname'] ?? ''));
$parentName = trim((string) ($data['firstname'] ?? '').' '.(string) ($data['lastname'] ?? ''));
$amountSigned = (float) ($data['amount_signed'] ?? 0);
$amountAbs = (float) ($data['amount_abs'] ?? abs($amountSigned));
@@ -189,6 +195,7 @@ class PaymentEventService
);
$body = $this->renderEmail('emails/extra_charge_notice', $emailData, 'Account Charge Update');
return $this->sendEmail((string) ($data['email'] ?? ''), $subject, $body, 'billing');
}
@@ -204,13 +211,15 @@ class PaymentEventService
{
if ($to === '') {
Log::warning('Payment event missing recipient email', ['subject' => $subject]);
return ['ok' => false, 'message' => 'Missing recipient email.'];
}
$ok = $this->emailService->send($to, $subject, $html, $fromKey);
if (!$ok) {
if (! $ok) {
Log::error('Payment event email failed', ['to' => $to, 'subject' => $subject]);
}
return ['ok' => $ok];
}
@@ -218,6 +227,6 @@ class PaymentEventService
{
Log::debug('Skipping Blade email template', ['view' => $viewName]);
return '<p>' . e($fallbackTitle) . '</p>';
return '<p>'.e($fallbackTitle).'</p>';
}
}