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
+34 -33
View File
@@ -17,7 +17,8 @@ class PaymentManualService
public function __construct(
private DiscountInvoiceService $invoiceService,
private PaymentEnrollmentEventService $enrollmentEventService
) {}
) {
}
public function search(string $searchTerm, ?string $schoolYear = null): array
{
@@ -47,9 +48,9 @@ class PaymentManualService
$builder->where(function ($q) use ($searchTerm, $searchClean, $searchFormatted) {
$q->where('email', $searchTerm);
if (! empty($searchClean)) {
if (!empty($searchClean)) {
if (strlen($searchClean) === 10) {
$formattedPhone = substr($searchClean, 0, 3).'-'.substr($searchClean, 3, 3).'-'.substr($searchClean, 6, 4);
$formattedPhone = substr($searchClean, 0, 3) . '-' . substr($searchClean, 3, 3) . '-' . substr($searchClean, 6, 4);
$q->orWhere('cellphone', $formattedPhone);
}
@@ -59,13 +60,13 @@ class PaymentManualService
);
}
if (! empty($searchFormatted)) {
if (!empty($searchFormatted)) {
$q->orWhere('cellphone', $searchFormatted);
}
});
$parent = (array) $builder->first();
if (! empty($parent)) {
if (!empty($parent)) {
unset($parent['password']);
$parentData = $parent;
$parentId = (int) ($parent['id'] ?? 0);
@@ -126,23 +127,23 @@ class PaymentManualService
OR email LIKE ?
OR cellphone LIKE ?";
$params = ['%'.$q.'%', '%'.$q.'%', '%'.$q.'%'];
$params = ['%' . $q . '%', '%' . $q . '%', '%' . $q . '%'];
if ($digits !== '') {
$sql .= " OR REPLACE(REPLACE(REPLACE(REPLACE(cellphone, '(', ''), ')', ''), '-', ''), ' ', '') LIKE ?";
$params[] = '%'.$digits.'%';
$params[] = '%' . $digits . '%';
}
$sql .= ') ORDER BY lastname, firstname LIMIT 20';
$sql .= ") ORDER BY lastname, firstname LIMIT 20";
$rows = DB::select($sql, $params);
$items = [];
foreach ($rows as $row) {
$label = trim(($row->firstname ?? '').' '.($row->lastname ?? ''));
$label = trim(($row->firstname ?? '') . ' ' . ($row->lastname ?? ''));
$email = trim((string) ($row->email ?? ''));
$phone = trim((string) ($row->cellphone ?? ''));
$sub = trim($email.' '.$phone);
$sub = trim($email . ' ' . $phone);
$value = $email !== '' ? $email : ($phone !== '' ? $phone : $label);
$items[] = [
@@ -171,7 +172,7 @@ class PaymentManualService
$paymentMethod = strtolower(trim($paymentMethod));
$allowedMethods = ['cash', 'check', 'card'];
if (! in_array($paymentMethod, $allowedMethods, true)) {
if (!in_array($paymentMethod, $allowedMethods, true)) {
throw new \InvalidArgumentException('Invalid payment method.');
}
@@ -184,7 +185,7 @@ class PaymentManualService
}
$invoice = Invoice::query()->find($invoiceId);
if (! $invoice) {
if (!$invoice) {
throw new \RuntimeException('Invoice not found.');
}
@@ -208,7 +209,7 @@ class PaymentManualService
try {
$locked = DB::table('invoices')->where('id', $invoiceId)->lockForUpdate()->first();
if (! $locked) {
if (!$locked) {
DB::rollBack();
throw new \RuntimeException('Invoice not found.');
}
@@ -229,7 +230,7 @@ class PaymentManualService
$paidCount = $this->getSuccessfulPaymentCount($invoiceId);
$installmentSeq = $paidCount + 1;
$transactionId = 'INV-'.$invoiceId.'-'.str_replace('.', '', (string) microtime(true));
$transactionId = 'INV-' . $invoiceId . '-' . str_replace('.', '', (string) microtime(true));
$ok = $this->processPayment(
$invoiceId,
@@ -245,7 +246,7 @@ class PaymentManualService
$userId
);
if (! $ok) {
if (!$ok) {
DB::rollBack();
throw new \RuntimeException('Failed to record payment.');
}
@@ -307,7 +308,7 @@ class PaymentManualService
];
} catch (\Throwable $e) {
DB::rollBack();
Log::error('[manualPayUpdate] '.$e->getMessage());
Log::error('[manualPayUpdate] ' . $e->getMessage());
throw $e;
}
}
@@ -327,12 +328,12 @@ class PaymentManualService
}
$payment = Payment::query()->find($paymentId);
if (! $payment) {
if (!$payment) {
throw new \RuntimeException('Original payment not found.');
}
$invoice = Invoice::query()->find((int) $payment->invoice_id);
if (! $invoice) {
if (!$invoice) {
throw new \RuntimeException('Linked invoice not found.');
}
@@ -366,10 +367,10 @@ class PaymentManualService
{
$filename = basename($filename);
$roots = [
storage_path('app/uploads/checks/'.$filename),
storage_path('app/uploads/cards/'.$filename),
storage_path('app/uploads/misc/'.$filename),
storage_path('app/uploads/'.$filename),
storage_path('app/uploads/checks/' . $filename),
storage_path('app/uploads/cards/' . $filename),
storage_path('app/uploads/misc/' . $filename),
storage_path('app/uploads/' . $filename),
];
$path = null;
@@ -380,14 +381,14 @@ class PaymentManualService
}
}
if (! $path) {
if (!$path) {
abort(404, 'Payment file not found.');
}
if ($mode === 'inline') {
return response()->file($path, [
'Content-Type' => mime_content_type($path) ?: 'application/octet-stream',
'Content-Disposition' => 'inline; filename="'.$filename.'"',
'Content-Disposition' => 'inline; filename="' . $filename . '"',
]);
}
@@ -408,7 +409,7 @@ class PaymentManualService
?int $userId
): bool {
$invoice = Invoice::query()->find($invoiceId);
if (! $invoice) {
if (!$invoice) {
return false;
}
@@ -432,7 +433,7 @@ class PaymentManualService
'updated_by' => $userId,
];
if (! Invoice::query()->whereKey($invoiceId)->update($invoiceUpdateData)) {
if (!Invoice::query()->whereKey($invoiceId)->update($invoiceUpdateData)) {
return false;
}
@@ -465,7 +466,7 @@ class PaymentManualService
private function getCurrentInvoiceBalanceExcludingPayment(int $invoiceId, int $excludePaymentId): float
{
$invoice = Invoice::query()->find($invoiceId);
if (! $invoice) {
if (!$invoice) {
return 0.0;
}
@@ -529,7 +530,7 @@ class PaymentManualService
$discountByInvoice = [];
$refundByInvoice = [];
if (! empty($invoiceIds)) {
if (!empty($invoiceIds)) {
$rows = Payment::query()
->selectRaw('invoice_id, COALESCE(SUM(paid_amount),0) AS total_paid')
->whereIn('invoice_id', $invoiceIds)
@@ -580,7 +581,7 @@ class PaymentManualService
$issueYmd = '';
foreach (['issue_date', 'start_date', 'created_at'] as $k) {
if (! empty($inv[$k])) {
if (!empty($inv[$k])) {
$its = strtotime((string) $inv[$k]);
if ($its !== false) {
$issueYmd = date('Y-m-d', $its);
@@ -612,7 +613,7 @@ class PaymentManualService
$okTypes = ['image/jpeg', 'image/png', 'application/pdf'];
$okExts = ['jpg', 'jpeg', 'png', 'pdf'];
if (! in_array($mime, $okTypes, true) || ! in_array($ext, $okExts, true)) {
if (!in_array($mime, $okTypes, true) || !in_array($ext, $okExts, true)) {
throw new \InvalidArgumentException('Unsupported file type. Use JPG, PNG, or PDF.');
}
@@ -622,9 +623,9 @@ class PaymentManualService
$fileName = $file->hashName();
$subdir = $paymentMethod === 'check' ? 'checks' : ($paymentMethod === 'card' ? 'cards' : 'misc');
$targetDir = storage_path('app/uploads/'.$subdir);
$targetDir = storage_path('app/uploads/' . $subdir);
if (! is_dir($targetDir)) {
if (!is_dir($targetDir)) {
mkdir($targetDir, 0775, true);
}
@@ -640,7 +641,7 @@ class PaymentManualService
event($name, $payload);
}
} catch (\Throwable $e) {
Log::warning($name.' hook failed: '.$e->getMessage());
Log::warning($name . ' hook failed: ' . $e->getMessage());
}
}
}