add tests batch 20
This commit is contained in:
@@ -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,33 +94,30 @@ 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') : '';
|
||||
}
|
||||
|
||||
@@ -128,22 +125,19 @@ 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));
|
||||
@@ -195,7 +189,6 @@ class PaymentEventService
|
||||
);
|
||||
|
||||
$body = $this->renderEmail('emails/extra_charge_notice', $emailData, 'Account Charge Update');
|
||||
|
||||
return $this->sendEmail((string) ($data['email'] ?? ''), $subject, $body, 'billing');
|
||||
}
|
||||
|
||||
@@ -211,15 +204,13 @@ 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];
|
||||
}
|
||||
|
||||
@@ -227,6 +218,6 @@ class PaymentEventService
|
||||
{
|
||||
Log::debug('Skipping Blade email template', ['view' => $viewName]);
|
||||
|
||||
return '<p>'.e($fallbackTitle).'</p>';
|
||||
return '<p>' . e($fallbackTitle) . '</p>';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user