fix tests

This commit is contained in:
root
2026-06-11 11:46:12 -04:00
parent c91fa2ce4d
commit 5ead80fdc7
1489 changed files with 11349 additions and 10305 deletions
@@ -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);
}
}