fix gitlab tests
This commit is contained in:
@@ -11,7 +11,8 @@ class ReimbursementQueryService
|
||||
public function __construct(
|
||||
private ReimbursementRecipientService $recipients,
|
||||
private ReimbursementFileService $files
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
public function underProcessing(): array
|
||||
{
|
||||
@@ -44,7 +45,7 @@ class ReimbursementQueryService
|
||||
}
|
||||
|
||||
$receiptUrl = $this->files->expenseReceiptUrl($row->expense_receipt ?? null);
|
||||
$fullName = trim(($row->purchaser_firstname ?? '').' '.($row->purchaser_lastname ?? '')) ?: 'Unknown';
|
||||
$fullName = trim(($row->purchaser_firstname ?? '') . ' ' . ($row->purchaser_lastname ?? '')) ?: 'Unknown';
|
||||
|
||||
$item = [
|
||||
'id' => $expenseId,
|
||||
@@ -95,16 +96,16 @@ class ReimbursementQueryService
|
||||
}
|
||||
|
||||
$receiptUrl = $this->files->expenseReceiptUrl($row->expense_receipt ?? null);
|
||||
$purchaser = trim(($row->purchaser_firstname ?? '').' '.($row->purchaser_lastname ?? '')) ?: 'Unknown';
|
||||
$purchaser = trim(($row->purchaser_firstname ?? '') . ' ' . ($row->purchaser_lastname ?? '')) ?: 'Unknown';
|
||||
$yearlyNumber = (int) ($row->batch_year_number ?? 0);
|
||||
$batchLabel = trim((string) ($row->batch_title ?? ''));
|
||||
if ($batchLabel === '') {
|
||||
$fallbackNumber = $yearlyNumber > 0 ? $yearlyNumber : $batchId;
|
||||
$batchLabel = 'Batch #'.$fallbackNumber;
|
||||
$batchLabel = 'Batch #' . $fallbackNumber;
|
||||
}
|
||||
$adminId = $row->admin_id ? (int) $row->admin_id : 0;
|
||||
$adminName = $adminId > 0
|
||||
? (trim(($row->admin_firstname ?? '').' '.($row->admin_lastname ?? '')) ?: 'Admin')
|
||||
? (trim(($row->admin_firstname ?? '') . ' ' . ($row->admin_lastname ?? '')) ?: 'Admin')
|
||||
: 'Unassigned';
|
||||
$batchStatus = strtolower(trim((string) ($row->batch_status ?? ''))) ?: 'open';
|
||||
|
||||
@@ -126,7 +127,7 @@ class ReimbursementQueryService
|
||||
|
||||
$itemsMap[$expenseId] = $item;
|
||||
|
||||
if (! isset($batchStructures[$batchId])) {
|
||||
if (!isset($batchStructures[$batchId])) {
|
||||
$batchStructures[$batchId] = [
|
||||
'batchId' => $batchId,
|
||||
'label' => $batchLabel,
|
||||
@@ -142,7 +143,7 @@ class ReimbursementQueryService
|
||||
}
|
||||
|
||||
$slotKey = $adminId ?: 0;
|
||||
if (! isset($batchStructures[$batchId]['slots'][$slotKey])) {
|
||||
if (!isset($batchStructures[$batchId]['slots'][$slotKey])) {
|
||||
$batchStructures[$batchId]['slots'][$slotKey] = [
|
||||
'admin_id' => $adminId ?: 0,
|
||||
'admin_name' => $adminId > 0 ? $adminName : 'Unassigned',
|
||||
@@ -154,7 +155,7 @@ class ReimbursementQueryService
|
||||
}
|
||||
|
||||
$adminFileMap = [];
|
||||
if (! empty($batchStructures)) {
|
||||
if (!empty($batchStructures)) {
|
||||
$batchIds = array_keys($batchStructures);
|
||||
$files = ReimbursementBatchAdminFile::query()
|
||||
->select('batch_id', 'admin_id', 'filename', 'original_filename')
|
||||
@@ -187,7 +188,6 @@ class ReimbursementQueryService
|
||||
$existingBatches = array_map(static function (array $batch) {
|
||||
$normalizedSlots = array_map(static function (array $slot) {
|
||||
$slot['items'] = array_values(array_map('intval', $slot['items']));
|
||||
|
||||
return $slot;
|
||||
}, array_values($batch['slots']));
|
||||
|
||||
@@ -238,13 +238,13 @@ class ReimbursementQueryService
|
||||
->where('b.status', 'closed')
|
||||
->whereNull('bi.unassigned_at');
|
||||
|
||||
if (! empty($filters['school_year'])) {
|
||||
if (!empty($filters['school_year'])) {
|
||||
$batchQuery->where(function ($q) use ($filters) {
|
||||
$q->where('b.school_year', $filters['school_year'])
|
||||
->orWhere('e.school_year', $filters['school_year']);
|
||||
});
|
||||
}
|
||||
if (! empty($filters['user_id'])) {
|
||||
if (!empty($filters['user_id'])) {
|
||||
$batchQuery->where('e.purchased_by', $filters['user_id']);
|
||||
}
|
||||
|
||||
@@ -255,10 +255,10 @@ class ReimbursementQueryService
|
||||
continue;
|
||||
}
|
||||
$labelNumber = (int) ($row->yearly_batch_number ?? $bid);
|
||||
if (! isset($batchSummaries[$bid])) {
|
||||
if (!isset($batchSummaries[$bid])) {
|
||||
$batchSummaries[$bid] = [
|
||||
'batch_id' => $bid,
|
||||
'title' => trim((string) ($row->batch_title ?? '')) ?: ('Batch #'.$labelNumber),
|
||||
'title' => trim((string) ($row->batch_title ?? '')) ?: ('Batch #' . $labelNumber),
|
||||
'sequence' => $labelNumber,
|
||||
'closed_at' => $row->closed_at ?? null,
|
||||
'amount' => 0.0,
|
||||
@@ -269,7 +269,7 @@ class ReimbursementQueryService
|
||||
$batchSummaries[$bid]['amount'] += (float) $amount;
|
||||
$batchSummaries[$bid]['items'] += 1;
|
||||
|
||||
if (! isset($batchDetails[$bid])) {
|
||||
if (!isset($batchDetails[$bid])) {
|
||||
$batchDetails[$bid] = [
|
||||
'title' => $batchSummaries[$bid]['title'],
|
||||
'sequence' => $labelNumber,
|
||||
@@ -278,7 +278,7 @@ class ReimbursementQueryService
|
||||
'checks' => [],
|
||||
];
|
||||
}
|
||||
if (! isset($batchAttachments[$bid])) {
|
||||
if (!isset($batchAttachments[$bid])) {
|
||||
$batchAttachments[$bid] = [
|
||||
'receipts' => [],
|
||||
'checks' => [],
|
||||
@@ -289,7 +289,7 @@ class ReimbursementQueryService
|
||||
'amount' => (float) $amount,
|
||||
'description' => $row->description ?? '',
|
||||
'vendor' => $row->retailor ?? '',
|
||||
'purchased_by' => trim(($row->purchaser_firstname ?? '').' '.($row->purchaser_lastname ?? '')),
|
||||
'purchased_by' => trim(($row->purchaser_firstname ?? '') . ' ' . ($row->purchaser_lastname ?? '')),
|
||||
'receipt_url' => $this->files->expenseReceiptUrl($row->expense_receipt ?? null),
|
||||
];
|
||||
|
||||
@@ -309,7 +309,7 @@ class ReimbursementQueryService
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($batchSummaries)) {
|
||||
if (!empty($batchSummaries)) {
|
||||
$batchIds = array_keys($batchSummaries);
|
||||
$files = ReimbursementBatchAdminFile::query()
|
||||
->select('id as file_id', 'batch_id', 'admin_id', 'filename', 'original_filename', 'uploaded_at')
|
||||
@@ -319,22 +319,22 @@ class ReimbursementQueryService
|
||||
$adminNames = $this->recipients->adminRoster();
|
||||
$adminNameMap = [];
|
||||
foreach ($adminNames as $admin) {
|
||||
$adminNameMap[(int) $admin['id']] = trim(($admin['firstname'] ?? '').' '.($admin['lastname'] ?? ''));
|
||||
$adminNameMap[(int) $admin['id']] = trim(($admin['firstname'] ?? '') . ' ' . ($admin['lastname'] ?? ''));
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
$bid = (int) ($file->batch_id ?? 0);
|
||||
if ($bid <= 0 || ! isset($batchDetails[$bid])) {
|
||||
if ($bid <= 0 || !isset($batchDetails[$bid])) {
|
||||
continue;
|
||||
}
|
||||
$aid = (int) ($file->admin_id ?? 0);
|
||||
$batchDetails[$bid]['checks'][] = [
|
||||
'admin' => $adminNameMap[$aid] ?? ($aid > 0 ? 'Admin #'.$aid : 'Unassigned'),
|
||||
'admin' => $adminNameMap[$aid] ?? ($aid > 0 ? 'Admin #' . $aid : 'Unassigned'),
|
||||
'filename' => $file->filename,
|
||||
'original' => $file->original_filename ?? $file->filename,
|
||||
'url' => $this->files->adminFileUrl($file->filename ?? '', 'inline'),
|
||||
];
|
||||
if (! isset($batchAttachments[$bid])) {
|
||||
if (!isset($batchAttachments[$bid])) {
|
||||
$batchAttachments[$bid] = [
|
||||
'receipts' => [],
|
||||
'checks' => [],
|
||||
@@ -344,19 +344,18 @@ class ReimbursementQueryService
|
||||
'file_id' => (int) ($file->file_id ?? 0),
|
||||
'filename' => $file->filename,
|
||||
'original_filename' => $file->original_filename ?? $file->filename,
|
||||
'admin' => $adminNameMap[$aid] ?? ($aid > 0 ? 'Admin #'.$aid : 'Unassigned'),
|
||||
'admin' => $adminNameMap[$aid] ?? ($aid > 0 ? 'Admin #' . $aid : 'Unassigned'),
|
||||
'url' => $this->files->adminFileUrl($file->filename ?? '', 'inline'),
|
||||
'uploaded_at' => $file->uploaded_at ?? null,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($batchSummaries)) {
|
||||
if (!empty($batchSummaries)) {
|
||||
$batchSummaries = array_values($batchSummaries);
|
||||
usort($batchSummaries, static function ($a, $b) {
|
||||
$aSeq = (int) ($a['sequence'] ?? 0);
|
||||
$bSeq = (int) ($b['sequence'] ?? 0);
|
||||
|
||||
return $bSeq <=> $aSeq;
|
||||
});
|
||||
}
|
||||
@@ -372,16 +371,16 @@ class ReimbursementQueryService
|
||||
->leftJoin('users as u', 'u.id', '=', 'e.purchased_by')
|
||||
->where('e.category', 'Donation');
|
||||
|
||||
if (! empty($filters['school_year'])) {
|
||||
if (!empty($filters['school_year'])) {
|
||||
$donationQuery->where('e.school_year', $filters['school_year']);
|
||||
}
|
||||
if (! empty($filters['semester'])) {
|
||||
if (!empty($filters['semester'])) {
|
||||
$donationQuery->where('e.semester', $filters['semester']);
|
||||
}
|
||||
if (! empty($filters['user_id'])) {
|
||||
if (!empty($filters['user_id'])) {
|
||||
$donationQuery->where('e.purchased_by', $filters['user_id']);
|
||||
}
|
||||
if (! empty($filters['status'])) {
|
||||
if (!empty($filters['status'])) {
|
||||
$donationQuery->where(function ($q) use ($filters) {
|
||||
$q->where('e.status', $filters['status'])
|
||||
->orWhere('e.status', strtolower((string) $filters['status']))
|
||||
@@ -395,7 +394,7 @@ class ReimbursementQueryService
|
||||
foreach ($donationRows as $row) {
|
||||
$amount = (float) ($row->expense_amount ?? 0);
|
||||
$donationTotal += $amount;
|
||||
$purchaser = trim(($row->purchaser_firstname ?? '').' '.($row->purchaser_lastname ?? ''));
|
||||
$purchaser = trim(($row->purchaser_firstname ?? '') . ' ' . ($row->purchaser_lastname ?? ''));
|
||||
if ($purchaser === '') {
|
||||
$purchaser = 'Unknown';
|
||||
}
|
||||
@@ -429,8 +428,8 @@ class ReimbursementQueryService
|
||||
}
|
||||
|
||||
$recipientId = $e['reimb_recipient_id'] ?? ($e['reimbursed_to'] ?? null);
|
||||
$hasName = trim(($e['reimb_firstname'] ?? '').' '.($e['reimb_lastname'] ?? '')) !== '';
|
||||
if (! $hasName) {
|
||||
$hasName = trim(($e['reimb_firstname'] ?? '') . ' ' . ($e['reimb_lastname'] ?? '')) !== '';
|
||||
if (!$hasName) {
|
||||
$label = $this->recipients->specialRecipientLabel($recipientId);
|
||||
if ($label !== null) {
|
||||
$e['reimb_firstname'] = $label;
|
||||
|
||||
Reference in New Issue
Block a user