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
@@ -10,6 +10,7 @@ use Illuminate\Support\Facades\Log;
class DiscountApplyService
{
private DiscountContextService $context;
private DiscountInvoiceService $invoiceService;
public function __construct(DiscountContextService $context, DiscountInvoiceService $invoiceService)
@@ -24,7 +25,7 @@ class DiscountApplyService
$semester = $this->context->getSemester();
$voucher = DiscountVoucher::query()->find($voucherId);
if (!$voucher) {
if (! $voucher) {
return ['ok' => false, 'message' => 'Voucher not found.'];
}
@@ -43,7 +44,7 @@ class DiscountApplyService
return ['ok' => false, 'message' => 'This voucher has reached its maximum allowed uses.'];
}
if (!$allowAdditional) {
if (! $allowAdditional) {
$rows = DB::table('discount_usages as du')
->select('i.parent_id')
->join('invoices as i', 'i.id', '=', 'du.invoice_id')
@@ -55,7 +56,7 @@ class DiscountApplyService
->all();
$blockedParentIds = array_map(static fn ($r) => (int) ($r['parent_id'] ?? 0), $rows);
if (!empty($blockedParentIds)) {
if (! empty($blockedParentIds)) {
$parentIds = array_values(array_diff(array_map('intval', $parentIds), $blockedParentIds));
}
if (empty($parentIds)) {
@@ -81,6 +82,7 @@ class DiscountApplyService
'parent_id' => (int) $parentId,
'voucher_id' => $voucherId,
]);
continue;
}
@@ -99,7 +101,7 @@ class DiscountApplyService
continue;
}
if (!$allowAdditional) {
if (! $allowAdditional) {
$exists = DB::table('discount_usages as du')
->join('invoices as i', 'du.invoice_id', '=', 'i.id')
->where('du.voucher_id', $voucherId)
@@ -197,6 +199,7 @@ class DiscountApplyService
DB::commit();
} catch (\Throwable $e) {
DB::rollBack();
return ['ok' => false, 'message' => 'Voucher application failed. Transaction rolled back.'];
}
@@ -286,7 +289,7 @@ class DiscountApplyService
event('paymentReceived', [$eventData, $studentData]);
}
} catch (\Throwable $e) {
Log::warning('paymentReceived hook failed: ' . $e->getMessage());
Log::warning('paymentReceived hook failed: '.$e->getMessage());
}
}
}
@@ -17,13 +17,12 @@ class DiscountInvoiceService
{
public function __construct(
private ApplicationUrlService $urls,
) {
}
) {}
public function getCurrentInvoiceBalance(int $invoiceId, string $schoolYear): float
{
$invoice = Invoice::query()->find($invoiceId);
if (!$invoice) {
if (! $invoice) {
return 0.0;
}
@@ -66,13 +65,14 @@ class DiscountInvoiceService
$totalRefundPaid = (float) ($rowRefund['total_refund_paid'] ?? 0);
$total = (float) ($invoice->total_amount ?? 0);
return max(0.0, round($total - $totalPaid - $totalDisc - $totalRefundPaid, 2));
}
public function recalculateInvoice(int $invoiceId, string $schoolYear): void
{
$invoice = Invoice::query()->find($invoiceId);
if (!$invoice) {
if (! $invoice) {
return;
}
@@ -118,7 +118,7 @@ class DiscountInvoiceService
}
$tuitionStudents = $registered;
if (!$refundAllowed) {
if (! $refundAllowed) {
$tuitionStudents = array_merge($tuitionStudents, $withdrawn);
}
@@ -129,7 +129,7 @@ class DiscountInvoiceService
foreach ($tuitionStudents as &$s) {
$name = null;
if (!empty($s['class_section_id'])) {
if (! empty($s['class_section_id'])) {
$name = ClassSection::getClassSectionNameBySectionId($s['class_section_id']);
}
$s['grade_name'] = is_string($name) ? strtoupper(trim($name)) : 'N/A';
@@ -236,13 +236,13 @@ class DiscountInvoiceService
public function updateEnrollmentStatusIfPaid(int $invoiceId, string $schoolYear): int
{
$invoice = Invoice::query()->find($invoiceId);
if (!$invoice) {
if (! $invoice) {
return 0;
}
$total = (float) ($invoice->total_amount ?? 0);
$balance = (float) ($invoice->balance ?? 0);
if (!($total > 0 && $balance < $total)) {
if (! ($total > 0 && $balance < $total)) {
return 0;
}
@@ -281,7 +281,7 @@ class DiscountInvoiceService
->orWhereRaw("LOWER(TRIM(REPLACE(enrollment_status, CHAR(160), ' '))) = 'payment pending'");
});
if (!empty($paidEnrollmentIds)) {
if (! empty($paidEnrollmentIds)) {
$query->whereIn('id', array_values(array_unique($paidEnrollmentIds)));
}
@@ -314,7 +314,7 @@ class DiscountInvoiceService
string $semester
): array {
$invoice = Invoice::query()->find($invoiceId);
if (!$invoice) {
if (! $invoice) {
throw new \RuntimeException("Invoice {$invoiceId} not found");
}
@@ -380,6 +380,7 @@ class DiscountInvoiceService
if (preg_match('/^Y(?:OUTH)?\\s*(\\d+)?$/', $g, $m)) {
$n = isset($m[1]) && $m[1] !== '' ? max(1, (int) $m[1]) : 1;
return $gradeFee + $n;
}
@@ -395,6 +396,7 @@ class DiscountInvoiceService
if (function_exists('local_date') && function_exists('utc_now')) {
return (string) local_date(utc_now(), $format);
}
return now()->format($format);
}
}
@@ -33,6 +33,7 @@ class DiscountVoucherService
$voucher = DiscountVoucher::query()->findOrFail($id);
$voucher->fill($payload);
$voucher->save();
return $voucher;
}