Fix Pint formatting

This commit is contained in:
root
2026-06-09 01:25:14 -04:00
parent 6be4875c5e
commit 20a0b6c4e5
1485 changed files with 11318 additions and 10273 deletions
+33 -34
View File
@@ -17,8 +17,7 @@ class PaymentManualService
public function __construct(
private DiscountInvoiceService $invoiceService,
private PaymentEnrollmentEventService $enrollmentEventService
) {
}
) {}
public function search(string $searchTerm, ?string $schoolYear = null): array
{
@@ -48,9 +47,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);
}
@@ -60,13 +59,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);
@@ -127,23 +126,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[] = [
@@ -172,7 +171,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.');
}
@@ -185,7 +184,7 @@ class PaymentManualService
}
$invoice = Invoice::query()->find($invoiceId);
if (!$invoice) {
if (! $invoice) {
throw new \RuntimeException('Invoice not found.');
}
@@ -209,7 +208,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.');
}
@@ -230,7 +229,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,
@@ -246,7 +245,7 @@ class PaymentManualService
$userId
);
if (!$ok) {
if (! $ok) {
DB::rollBack();
throw new \RuntimeException('Failed to record payment.');
}
@@ -308,7 +307,7 @@ class PaymentManualService
];
} catch (\Throwable $e) {
DB::rollBack();
Log::error('[manualPayUpdate] ' . $e->getMessage());
Log::error('[manualPayUpdate] '.$e->getMessage());
throw $e;
}
}
@@ -328,12 +327,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.');
}
@@ -367,10 +366,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;
@@ -381,14 +380,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.'"',
]);
}
@@ -409,7 +408,7 @@ class PaymentManualService
?int $userId
): bool {
$invoice = Invoice::query()->find($invoiceId);
if (!$invoice) {
if (! $invoice) {
return false;
}
@@ -433,7 +432,7 @@ class PaymentManualService
'updated_by' => $userId,
];
if (!Invoice::query()->whereKey($invoiceId)->update($invoiceUpdateData)) {
if (! Invoice::query()->whereKey($invoiceId)->update($invoiceUpdateData)) {
return false;
}
@@ -466,7 +465,7 @@ class PaymentManualService
private function getCurrentInvoiceBalanceExcludingPayment(int $invoiceId, int $excludePaymentId): float
{
$invoice = Invoice::query()->find($invoiceId);
if (!$invoice) {
if (! $invoice) {
return 0.0;
}
@@ -530,7 +529,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)
@@ -581,7 +580,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);
@@ -613,7 +612,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.');
}
@@ -623,9 +622,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);
}
@@ -641,7 +640,7 @@ class PaymentManualService
event($name, $payload);
}
} catch (\Throwable $e) {
Log::warning($name . ' hook failed: ' . $e->getMessage());
Log::warning($name.' hook failed: '.$e->getMessage());
}
}
}