add tests batch 20

This commit is contained in:
root
2026-06-09 01:03:53 -04:00
parent 95efb9652e
commit 6be4875c5e
1502 changed files with 13797 additions and 11313 deletions
@@ -8,7 +8,9 @@ use Illuminate\Support\Facades\Schema;
class FinancialUnpaidParentsService
{
public function __construct(private FinancialSchoolYearService $schoolYears) {}
public function __construct(private FinancialSchoolYearService $schoolYears)
{
}
public function getUnpaidParents(?string $schoolYear): array
{
@@ -74,7 +76,7 @@ class FinancialUnpaidParentsService
$total = (float) ($row['total_amount'] ?? 0);
$balance = max(0.0, round($total - $discSum - $paidSum - $refSum, 2));
if (! isset($byParent[$parentId])) {
if (!isset($byParent[$parentId])) {
$byParent[$parentId] = [
'parent_id' => $parentId,
'firstname' => (string) ($row['firstname'] ?? ''),
@@ -94,7 +96,7 @@ class FinancialUnpaidParentsService
}
$extraRows = DB::table('additional_charges as ac')
->selectRaw('ac.parent_id, u.firstname, u.lastname, u.email, COALESCE(SUM(ac.amount), 0) AS total_extra')
->selectRaw("ac.parent_id, u.firstname, u.lastname, u.email, COALESCE(SUM(ac.amount), 0) AS total_extra")
->leftJoin('users as u', 'u.id', '=', 'ac.parent_id')
->where('ac.school_year', $schoolYear)
->where('ac.status', '!=', 'void')
@@ -117,7 +119,7 @@ class FinancialUnpaidParentsService
if (abs($extra) < 0.00001) {
continue;
}
if (! isset($byParent[$parentId])) {
if (!isset($byParent[$parentId])) {
$byParent[$parentId] = [
'parent_id' => $parentId,
'firstname' => (string) ($row['firstname'] ?? ''),
@@ -148,8 +150,8 @@ class FinancialUnpaidParentsService
}
}
$monthsUntil = static function (?\DateTimeImmutable $end) use ($today): int {
if (! $end) {
$monthsUntil = static function (? \DateTimeImmutable $end) use ($today): int {
if (!$end) {
return 0;
}
$y = (int) $end->format('Y') - (int) $today->format('Y');
@@ -158,7 +160,6 @@ class FinancialUnpaidParentsService
if ((int) $end->format('j') > (int) $today->format('j')) {
$months += 1;
}
return max(0, $months);
};
@@ -194,7 +195,7 @@ class FinancialUnpaidParentsService
$hasPayments = [];
$paidTotals = [];
$paymentCounts = [];
if (! empty($parentIds)) {
if (!empty($parentIds)) {
$pRows = DB::table('payments')
->selectRaw('parent_id, SUM(paid_amount) AS total_paid, COUNT(*) AS payment_count')
->whereIn('parent_id', $parentIds)
@@ -216,8 +217,7 @@ class FinancialUnpaidParentsService
$results = array_map(function (array $row) use ($hasPayments, $paidTotals, $paymentCounts, $nextInstallment) {
$parentId = (int) ($row['parent_id'] ?? 0);
$name = trim((string) ($row['firstname'] ?? '').' '.(string) ($row['lastname'] ?? ''));
$name = trim((string) ($row['firstname'] ?? '') . ' ' . (string) ($row['lastname'] ?? ''));
return [
'parent_id' => $parentId,
'parent_name' => $name,