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
@@ -8,7 +8,9 @@ use RuntimeException;
class ReimbursementExportService
{
public function __construct(private ReimbursementRecipientService $recipients) {}
public function __construct(private ReimbursementRecipientService $recipients)
{
}
public function buildUnderProcessingCsv(): array
{
@@ -25,12 +27,12 @@ class ReimbursementExportService
foreach ($records as $row) {
$personId = (int) ($row->purchased_by ?? 0);
$name = trim(($row->purchaser_firstname ?? '').' '.($row->purchaser_lastname ?? ''));
$name = trim(($row->purchaser_firstname ?? '') . ' ' . ($row->purchaser_lastname ?? ''));
if ($name === '') {
$name = $row->purchaser_firstname ?? $row->purchaser_lastname ?? 'Unknown';
}
$key = $personId > 0 ? 'id_'.$personId : 'name_'.strtolower($name);
if (! isset($grouped[$key])) {
$key = $personId > 0 ? 'id_' . $personId : 'name_' . strtolower($name);
if (!isset($grouped[$key])) {
$grouped[$key] = [
'name' => $name ?: 'Unknown',
'total' => 0.0,
@@ -43,12 +45,12 @@ class ReimbursementExportService
$grouped[$key]['total'] += $amount;
$vendor = trim((string) ($row->retailor ?? ''));
if ($vendor !== '' && ! in_array($vendor, $grouped[$key]['vendors'], true)) {
if ($vendor !== '' && !in_array($vendor, $grouped[$key]['vendors'], true)) {
$grouped[$key]['vendors'][] = $vendor;
}
$desc = trim((string) ($row->description ?? ''));
if ($desc !== '' && ! in_array($desc, $grouped[$key]['descriptions'], true)) {
if ($desc !== '' && !in_array($desc, $grouped[$key]['descriptions'], true)) {
$grouped[$key]['descriptions'][] = $desc;
}
}
@@ -76,16 +78,16 @@ class ReimbursementExportService
->select('reimbursements.*', 'u.firstname as reimb_firstname', 'u.lastname as reimb_lastname')
->leftJoin('users as u', 'u.id', '=', 'reimbursements.reimbursed_to');
if (! empty($filters['semester'])) {
if (!empty($filters['semester'])) {
$builder->where('reimbursements.semester', $filters['semester']);
}
if (! empty($filters['status'])) {
if (!empty($filters['status'])) {
$builder->where('reimbursements.status', $filters['status']);
}
if (! empty($filters['user_id'])) {
if (!empty($filters['user_id'])) {
$builder->where('reimbursements.reimbursed_to', $filters['user_id']);
}
if (! empty($filters['school_year'])) {
if (!empty($filters['school_year'])) {
$builder->where('reimbursements.school_year', $filters['school_year']);
}
@@ -94,8 +96,8 @@ class ReimbursementExportService
$rows[] = ['Amount', 'Reimbursed To', 'Status', 'Method', 'Check #', 'School Year', 'Semester', 'Date'];
foreach ($records as $row) {
$hasName = trim(($row->reimb_firstname ?? '').' '.($row->reimb_lastname ?? '')) !== '';
if (! $hasName) {
$hasName = trim(($row->reimb_firstname ?? '') . ' ' . ($row->reimb_lastname ?? '')) !== '';
if (!$hasName) {
$label = $this->recipients->specialRecipientLabel($row->reimbursed_to ?? null);
if ($label !== null) {
$row->reimb_firstname = $label;
@@ -105,7 +107,7 @@ class ReimbursementExportService
$rows[] = [
$row->amount,
trim(($row->reimb_firstname ?? '').' '.($row->reimb_lastname ?? '')),
trim(($row->reimb_firstname ?? '') . ' ' . ($row->reimb_lastname ?? '')),
$row->status,
$row->reimbursement_method ?? '-',
$row->check_number ?? '-',
@@ -124,11 +126,11 @@ class ReimbursementExportService
public function buildBatchCsv(int $batchId): array
{
$batch = ReimbursementBatch::query()->find($batchId);
if (! $batch) {
if (!$batch) {
throw new RuntimeException('Batch not found.');
}
$batchLabel = trim((string) ($batch->title ?? '')) ?: ('Batch #'.$batchId);
$batchLabel = trim((string) ($batch->title ?? '')) ?: ('Batch #' . $batchId);
$receiptRows = $this->fetchBatchReceiptRows($batchId);
$rows = [];
@@ -149,14 +151,14 @@ class ReimbursementExportService
->leftJoin('users as u', 'u.id', '=', 'e.purchased_by')
->where('bi.batch_id', $batchId);
if (! empty($receiptIds)) {
if (!empty($receiptIds)) {
$builder->whereIn('e.id', $receiptIds);
}
$rows = $builder->get()->toArray();
return array_values(array_filter($rows, static function ($row) {
return ! empty($row->receipt_filename);
return !empty($row->receipt_filename);
}));
}
@@ -173,7 +175,7 @@ class ReimbursementExportService
{
$receiptTotalsByRecipient = [];
foreach ($receiptRows as $row) {
$recipientName = trim(($row->purchaser_firstname ?? '').' '.($row->purchaser_lastname ?? ''));
$recipientName = trim(($row->purchaser_firstname ?? '') . ' ' . ($row->purchaser_lastname ?? ''));
if ($recipientName === '') {
$recipientName = 'Unknown';
}
@@ -198,7 +200,7 @@ class ReimbursementExportService
];
}
if (! empty($receiptTotalsByRecipient)) {
if (!empty($receiptTotalsByRecipient)) {
$rows[] = [];
$rows[] = ['Totals by Recipient', '', '', '', '', '', '', ''];
foreach ($receiptTotalsByRecipient as $recipient => $total) {
@@ -219,14 +221,13 @@ class ReimbursementExportService
private function formatCsvDate(?string $value): string
{
if (! $value) {
if (!$value) {
return '';
}
$timestamp = strtotime($value);
if ($timestamp === false) {
return '';
}
return date('m-d-Y', $timestamp);
}
}