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
@@ -58,8 +58,7 @@ class ExtraChargesChargeService
DB::commit();
} catch (\Throwable $e) {
DB::rollBack();
Log::error('Extra charge create failed: '.$e->getMessage());
Log::error('Extra charge create failed: ' . $e->getMessage());
return ['ok' => false, 'message' => 'Failed to save charge.'];
}
@@ -94,17 +93,15 @@ class ExtraChargesChargeService
}
$charge->save();
if ($charge->status === 'applied' && ! empty($charge->invoice_id) && abs($delta) > 0.00001) {
if ($charge->status === 'applied' && !empty($charge->invoice_id) && abs($delta) > 0.00001) {
$this->invoiceService->adjustDelta((int) $charge->invoice_id, $delta);
}
DB::commit();
return true;
} catch (\Throwable $e) {
DB::rollBack();
Log::error('Extra charge update failed: '.$e->getMessage());
Log::error('Extra charge update failed: ' . $e->getMessage());
return false;
}
}
@@ -127,12 +124,10 @@ class ExtraChargesChargeService
$charge->save();
DB::commit();
return true;
} catch (\Throwable $e) {
DB::rollBack();
Log::error('Extra charge void failed: '.$e->getMessage());
Log::error('Extra charge void failed: ' . $e->getMessage());
return false;
}
}
@@ -158,25 +153,23 @@ class ExtraChargesChargeService
$charge->save();
DB::commit();
return true;
} catch (\Throwable $e) {
DB::rollBack();
Log::error('Extra charge reverse failed: '.$e->getMessage());
Log::error('Extra charge reverse failed: ' . $e->getMessage());
return false;
}
}
private function triggerExtraChargeEvent(?array $parentUser, array $payload, int $chargeId, ?int $invoiceId, array $invoiceBefore, array $invoiceAfter): void
{
if (! $parentUser) {
if (!$parentUser) {
return;
}
$first = $parentUser['first_name'] ?? $parentUser['firstname'] ?? '';
$last = $parentUser['last_name'] ?? $parentUser['lastname'] ?? '';
$parentName = trim($first.' '.$last);
$parentName = trim($first . ' ' . $last);
$before = $this->normalizeRow($invoiceBefore);
$after = $this->normalizeRow($invoiceAfter);
@@ -194,7 +187,7 @@ class ExtraChargesChargeService
'school_year' => $payload['school_year'],
'semester' => $payload['semester'],
'invoice_id' => $invoiceId,
'invoice_number' => $after['invoice_number'] ?? ($invoiceId ? 'INV-'.$invoiceId : null),
'invoice_number' => $after['invoice_number'] ?? ($invoiceId ? 'INV-' . $invoiceId : null),
'charge_id' => $chargeId,
'charge_title' => $payload['title'],
'charge_desc' => $payload['description'],
@@ -219,19 +212,18 @@ class ExtraChargesChargeService
event('extraCharge', [$eventData, $students]);
}
} catch (\Throwable $e) {
Log::warning('extraCharge event failed: '.$e->getMessage());
Log::warning('extraCharge event failed: ' . $e->getMessage());
}
}
private function normalizeRow($row): ?array
{
if (! $row) {
if (!$row) {
return null;
}
if (is_array($row) && isset($row[0]) && is_array($row[0])) {
return $row[0];
}
return is_array($row) ? $row : null;
}
@@ -240,7 +232,6 @@ class ExtraChargesChargeService
if (function_exists('utc_now')) {
return (string) utc_now();
}
return now('UTC')->toDateTimeString();
}
}
@@ -16,7 +16,7 @@ class ExtraChargesInvoiceService
return array_map(function ($inv) {
$id = (int) ($inv['id'] ?? 0);
$num = (string) ($inv['invoice_number'] ?? ('INV-'.$id));
$num = (string) ($inv['invoice_number'] ?? ('INV-' . $id));
$status = strtolower((string) ($inv['status'] ?? ''));
$balance = (float) ($inv['balance'] ?? 0);
$issue = $inv['issue_date'] ?? null;
@@ -28,8 +28,8 @@ class ExtraChargesInvoiceService
'balance' => $balance,
'issue_date' => $issue,
'text' => $num
.($status ? ' — '.ucfirst($status) : '')
.' (Bal: $'.number_format($balance, 2).')',
. ($status ? ' — ' . ucfirst($status) : '')
. ' (Bal: $' . number_format($balance, 2) . ')',
];
}, $rows);
}
@@ -21,7 +21,7 @@ class ExtraChargesMetaService
foreach ($rows as $row) {
$val = (string) ($row['school_year'] ?? '');
if ($val !== '' && ! in_array($val, $schoolYears, true)) {
if ($val !== '' && !in_array($val, $schoolYears, true)) {
$schoolYears[] = $val;
}
}
@@ -39,7 +39,7 @@ class ExtraChargesMetaService
foreach ($rows as $row) {
$val = (string) ($row['school_year'] ?? '');
if ($val !== '' && ! in_array($val, $schoolYears, true)) {
if ($val !== '' && !in_array($val, $schoolYears, true)) {
$schoolYears[] = $val;
}
}
@@ -53,7 +53,7 @@ class ExtraChargesMetaService
$start = (int) $start;
if ($start > 0) {
for ($i = 1; $i <= 3; $i++) {
$schoolYears[] = ($start - $i).'-'.(($start - $i) + 1);
$schoolYears[] = ($start - $i) . '-' . (($start - $i) + 1);
}
}
}
@@ -32,14 +32,13 @@ class ExtraChargesParentService
->all();
return array_map(function ($row) {
$name = trim(($row['lastname'] ?? '').', '.($row['firstname'] ?? ''));
$name = trim(($row['lastname'] ?? '') . ', ' . ($row['firstname'] ?? ''));
$email = $row['email'] ?? '';
$label = $name !== ',' ? $name : ('User #'.$row['id']);
$label = $name !== ',' ? $name : ('User #' . $row['id']);
if ($email) {
$label .= ' — '.$email;
$label .= ' — ' . $email;
}
$label .= ' (ID: '.$row['id'].')';
$label .= ' (ID: ' . $row['id'] . ')';
return [
'id' => (int) $row['id'],
'text' => $label,