fix parent pages and teachers and admin
API CI/CD / Validate (composer + pint) (push) Successful in 3m8s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Test (PHPUnit) (push) Failing after 6m5s
API CI/CD / Security audit (push) Failing after 52s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
API CI/CD / Validate (composer + pint) (push) Successful in 3m8s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Test (PHPUnit) (push) Failing after 6m5s
API CI/CD / Security audit (push) Failing after 52s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
This commit is contained in:
@@ -25,6 +25,23 @@ class ClassProgressQueryServiceTest extends TestCase
|
||||
'teacher_id' => $user->id,
|
||||
'class_section_id' => 202,
|
||||
]);
|
||||
DB::table('classSection')->insert([
|
||||
'id' => 1,
|
||||
'class_id' => 1,
|
||||
'class_section_id' => 101,
|
||||
'class_section_name' => '1-A',
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
]);
|
||||
DB::table('teacher_class')->insert([
|
||||
'class_section_id' => 1,
|
||||
'teacher_id' => $user->id,
|
||||
'position' => 'main',
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$service = new ClassProgressQueryService(new ClassProgressRuleService);
|
||||
$results = $service->listReports($user, ['class_section_id' => 101]);
|
||||
@@ -32,6 +49,78 @@ class ClassProgressQueryServiceTest extends TestCase
|
||||
$this->assertSame(1, $results->total());
|
||||
}
|
||||
|
||||
public function test_list_reports_filters_by_equivalent_legacy_section_ids(): void
|
||||
{
|
||||
$user = $this->createUser();
|
||||
DB::table('classSection')->insert([
|
||||
'id' => 1,
|
||||
'class_id' => 1,
|
||||
'class_section_id' => 101,
|
||||
'class_section_name' => '1-A',
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
]);
|
||||
DB::table('teacher_class')->insert([
|
||||
'class_section_id' => 101,
|
||||
'teacher_id' => $user->id,
|
||||
'position' => 'main',
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
$report = ClassProgressReport::factory()->create([
|
||||
'teacher_id' => 999,
|
||||
'class_section_id' => 1,
|
||||
'school_year' => '2025-2026',
|
||||
]);
|
||||
|
||||
$service = new ClassProgressQueryService(new ClassProgressRuleService);
|
||||
$results = $service->listReports($user, ['class_section_id' => 101]);
|
||||
|
||||
$this->assertSame(1, $results->total());
|
||||
$this->assertSame($report->id, $results->items()[0]->id);
|
||||
}
|
||||
|
||||
public function test_teacher_assignments_prefer_section_code_over_colliding_primary_key(): void
|
||||
{
|
||||
$user = $this->createUser();
|
||||
DB::table('classSection')->insert([
|
||||
[
|
||||
'id' => 1,
|
||||
'class_id' => 1,
|
||||
'class_section_id' => 10,
|
||||
'class_section_name' => '1',
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
],
|
||||
[
|
||||
'id' => 10,
|
||||
'class_id' => 3,
|
||||
'class_section_id' => 31,
|
||||
'class_section_name' => '3-A',
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
],
|
||||
]);
|
||||
DB::table('teacher_class')->insert([
|
||||
'class_section_id' => 10,
|
||||
'teacher_id' => $user->id,
|
||||
'position' => 'main',
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$service = new ClassProgressQueryService(new ClassProgressRuleService);
|
||||
$assignments = $service->teacherAssignments($user, '2025-2026', 'Fall');
|
||||
|
||||
$this->assertCount(1, $assignments);
|
||||
$this->assertSame(10, $assignments[0]['class_section_id']);
|
||||
$this->assertSame('1', $assignments[0]['class_section_name']);
|
||||
}
|
||||
|
||||
private function createUser(): User
|
||||
{
|
||||
DB::table('users')->insert([
|
||||
|
||||
@@ -60,4 +60,39 @@ class InvoicePaymentServiceTest extends TestCase
|
||||
$this->assertSame(5.0, $data['invoices'][0]['refund_amount']);
|
||||
$this->assertSame(60.0, $data['invoices'][0]['last_paid_amount']);
|
||||
}
|
||||
|
||||
public function test_parent_invoice_summary_applies_full_discount_to_balance(): void
|
||||
{
|
||||
DB::table('invoices')->insert([
|
||||
[
|
||||
'id' => 1,
|
||||
'parent_id' => 10,
|
||||
'invoice_number' => 'INV-DISCOUNT',
|
||||
'total_amount' => 370,
|
||||
'balance' => 370,
|
||||
'paid_amount' => 0,
|
||||
'has_discount' => 1,
|
||||
'issue_date' => '2025-01-10',
|
||||
'status' => 'Paid',
|
||||
'school_year' => '2025-2026',
|
||||
],
|
||||
]);
|
||||
|
||||
DB::table('discount_usages')->insert([
|
||||
'id' => 1,
|
||||
'voucher_id' => 1,
|
||||
'parent_id' => 10,
|
||||
'invoice_id' => 1,
|
||||
'discount_amount' => 370,
|
||||
'description' => 'Full scholarship',
|
||||
'school_year' => '2025-2026',
|
||||
]);
|
||||
|
||||
$service = new InvoicePaymentService(new InvoiceConfigService);
|
||||
$data = $service->getParentInvoiceSummary(10, '2025-2026');
|
||||
|
||||
$this->assertSame(370.0, $data['invoices'][0]['discount']);
|
||||
$this->assertSame(0.0, $data['invoices'][0]['balance']);
|
||||
$this->assertSame('Paid', $data['invoices'][0]['status']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,67 @@ class ParentEnrollmentServiceTest extends TestCase
|
||||
$this->assertSame('enrolled', $result['students'][0]['enrollment_status']);
|
||||
}
|
||||
|
||||
public function test_withdrawal_request_creates_pending_zero_amount_refund(): void
|
||||
{
|
||||
$this->seedConfig();
|
||||
$parentId = $this->seedParent();
|
||||
|
||||
$studentId = DB::table('students')->insertGetId([
|
||||
'school_id' => 'S-201',
|
||||
'firstname' => 'Omar',
|
||||
'lastname' => 'Parent',
|
||||
'dob' => '2014-09-01',
|
||||
'age' => 11,
|
||||
'gender' => 'Male',
|
||||
'photo_consent' => 1,
|
||||
'parent_id' => $parentId,
|
||||
'year_of_registration' => '2025',
|
||||
'school_year' => '2025-2026',
|
||||
'semester' => 'Fall',
|
||||
]);
|
||||
|
||||
DB::table('enrollments')->insert([
|
||||
'student_id' => $studentId,
|
||||
'parent_id' => $parentId,
|
||||
'school_year' => '2025-2026',
|
||||
'semester' => 'Fall',
|
||||
'enrollment_date' => '2025-09-01',
|
||||
'enrollment_status' => 'enrolled',
|
||||
'admission_status' => 'accepted',
|
||||
'is_withdrawn' => 0,
|
||||
]);
|
||||
|
||||
$invoiceId = DB::table('invoices')->insertGetId([
|
||||
'parent_id' => $parentId,
|
||||
'invoice_number' => 'INV-201',
|
||||
'total_amount' => 100,
|
||||
'paid_amount' => 100,
|
||||
'balance' => 0,
|
||||
'issue_date' => now(),
|
||||
'due_date' => now()->addWeek(),
|
||||
'status' => 'paid',
|
||||
'description' => 'Tuition',
|
||||
'school_year' => '2025-2026',
|
||||
'semester' => 'Fall',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$service = new ParentEnrollmentService(new ParentConfigService);
|
||||
$result = $service->updateEnrollment($parentId, [], [$studentId]);
|
||||
|
||||
$this->assertSame([$studentId], $result['withdrawn']);
|
||||
$this->assertDatabaseHas('refunds', [
|
||||
'parent_id' => $parentId,
|
||||
'invoice_id' => $invoiceId,
|
||||
'school_year' => '2025-2026',
|
||||
'semester' => 'Fall',
|
||||
'status' => 'Pending',
|
||||
'refund_amount' => 0,
|
||||
'refund_paid_amount' => 0,
|
||||
]);
|
||||
}
|
||||
|
||||
private function seedParent(): int
|
||||
{
|
||||
return DB::table('users')->insertGetId([
|
||||
|
||||
@@ -41,6 +41,188 @@ class ParentInvoiceServiceTest extends TestCase
|
||||
$this->assertSame('INV-1', $rows[0]['invoice_number']);
|
||||
}
|
||||
|
||||
public function test_list_invoices_derives_payment_totals_from_payments_table(): void
|
||||
{
|
||||
$parentId = $this->seedParent();
|
||||
|
||||
$invoiceId = DB::table('invoices')->insertGetId([
|
||||
'parent_id' => $parentId,
|
||||
'invoice_number' => 'INV-PAY',
|
||||
'total_amount' => 100,
|
||||
'paid_amount' => 0,
|
||||
'balance' => 100,
|
||||
'issue_date' => '2025-09-01',
|
||||
'due_date' => '2025-10-01',
|
||||
'status' => 'Unpaid',
|
||||
'school_year' => '2025-2026',
|
||||
'semester' => 'Fall',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
DB::table('payments')->insert([
|
||||
[
|
||||
'parent_id' => $parentId,
|
||||
'invoice_id' => $invoiceId,
|
||||
'total_amount' => 100,
|
||||
'paid_amount' => 40,
|
||||
'balance' => 60,
|
||||
'number_of_installments' => 1,
|
||||
'payment_method' => 'Check',
|
||||
'payment_date' => '2025-09-15',
|
||||
'transaction_id' => 'CHK-1',
|
||||
'status' => 'Paid',
|
||||
'school_year' => '2025-2026',
|
||||
'semester' => 'Fall',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
[
|
||||
'parent_id' => $parentId,
|
||||
'invoice_id' => $invoiceId,
|
||||
'total_amount' => 100,
|
||||
'paid_amount' => 25,
|
||||
'balance' => 35,
|
||||
'number_of_installments' => 1,
|
||||
'payment_method' => 'Online',
|
||||
'payment_date' => '2025-09-16',
|
||||
'transaction_id' => 'PENDING-1',
|
||||
'status' => 'Pending',
|
||||
'school_year' => '2025-2026',
|
||||
'semester' => 'Fall',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
]);
|
||||
|
||||
$service = new ParentInvoiceService;
|
||||
$rows = $service->listInvoices($parentId, '2025-2026');
|
||||
|
||||
$this->assertCount(1, $rows);
|
||||
$this->assertSame(40.0, $rows[0]['paid_amount']);
|
||||
$this->assertSame(60.0, $rows[0]['balance']);
|
||||
$this->assertSame('Partially Paid', $rows[0]['status']);
|
||||
$this->assertCount(1, $rows[0]['payments']);
|
||||
$this->assertSame('CHK-1', $rows[0]['payments'][0]['transaction_id']);
|
||||
}
|
||||
|
||||
public function test_list_invoices_applies_discounts_to_balance(): void
|
||||
{
|
||||
$parentId = $this->seedParent();
|
||||
|
||||
$invoiceId = DB::table('invoices')->insertGetId([
|
||||
'parent_id' => $parentId,
|
||||
'invoice_number' => 'INV-DISCOUNT',
|
||||
'total_amount' => 380,
|
||||
'paid_amount' => 10,
|
||||
'balance' => 370,
|
||||
'has_discount' => 1,
|
||||
'issue_date' => '2025-09-06',
|
||||
'due_date' => '2025-09-21',
|
||||
'status' => 'Paid',
|
||||
'school_year' => '2025-2026',
|
||||
'semester' => 'Fall',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
DB::table('payments')->insert([
|
||||
'parent_id' => $parentId,
|
||||
'invoice_id' => $invoiceId,
|
||||
'total_amount' => 380,
|
||||
'paid_amount' => 10,
|
||||
'balance' => 370,
|
||||
'number_of_installments' => 1,
|
||||
'payment_method' => 'Cash',
|
||||
'payment_date' => '2025-09-10',
|
||||
'status' => 'Paid',
|
||||
'school_year' => '2025-2026',
|
||||
'semester' => 'Fall',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
DB::table('discount_usages')->insert([
|
||||
'voucher_id' => 1,
|
||||
'parent_id' => $parentId,
|
||||
'invoice_id' => $invoiceId,
|
||||
'discount_amount' => 370,
|
||||
'description' => 'Tuition discount',
|
||||
'school_year' => '2025-2026',
|
||||
'semester' => 'Fall',
|
||||
]);
|
||||
|
||||
$service = new ParentInvoiceService;
|
||||
$rows = $service->listInvoices($parentId, '2025-2026');
|
||||
|
||||
$this->assertSame(10.0, $rows[0]['paid_amount']);
|
||||
$this->assertSame(370.0, $rows[0]['discount']);
|
||||
$this->assertSame(0.0, $rows[0]['balance']);
|
||||
$this->assertSame('Paid', $rows[0]['status']);
|
||||
}
|
||||
|
||||
public function test_statement_derives_current_balance_from_computed_invoice_lines(): void
|
||||
{
|
||||
$parentId = $this->seedParent();
|
||||
|
||||
$invoiceId = DB::table('invoices')->insertGetId([
|
||||
'parent_id' => $parentId,
|
||||
'invoice_number' => 'INV-STMT-DISCOUNT',
|
||||
'total_amount' => 380,
|
||||
'paid_amount' => 10,
|
||||
'balance' => 370,
|
||||
'has_discount' => 1,
|
||||
'issue_date' => '2025-09-06',
|
||||
'due_date' => '2025-09-21',
|
||||
'status' => 'Paid',
|
||||
'school_year' => '2025-2026',
|
||||
'semester' => 'Fall',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
DB::table('parent_accounts')->insert([
|
||||
'parent_id' => $parentId,
|
||||
'school_year' => '2025-2026',
|
||||
'opening_balance' => 0,
|
||||
'current_balance' => 370,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
DB::table('payments')->insert([
|
||||
'parent_id' => $parentId,
|
||||
'invoice_id' => $invoiceId,
|
||||
'total_amount' => 380,
|
||||
'paid_amount' => 10,
|
||||
'balance' => 370,
|
||||
'number_of_installments' => 1,
|
||||
'payment_method' => 'Cash',
|
||||
'payment_date' => '2025-09-10',
|
||||
'status' => 'Paid',
|
||||
'school_year' => '2025-2026',
|
||||
'semester' => 'Fall',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
DB::table('discount_usages')->insert([
|
||||
'voucher_id' => 1,
|
||||
'parent_id' => $parentId,
|
||||
'invoice_id' => $invoiceId,
|
||||
'discount_amount' => 370,
|
||||
'description' => 'Tuition discount',
|
||||
'school_year' => '2025-2026',
|
||||
'semester' => 'Fall',
|
||||
]);
|
||||
|
||||
$service = new ParentInvoiceService;
|
||||
$statement = $service->statement($parentId, '2025-2026');
|
||||
|
||||
$this->assertSame(0.0, $statement['lines'][0]['amount']);
|
||||
$this->assertSame(0.0, $statement['current_balance']);
|
||||
}
|
||||
|
||||
private function seedParent(string $email = 'parent@example.com'): int
|
||||
{
|
||||
return DB::table('users')->insertGetId([
|
||||
|
||||
@@ -58,4 +58,82 @@ class PaymentManualServiceTest extends TestCase
|
||||
$this->assertCount(1, $results);
|
||||
$this->assertSame('parent@example.com', $results[0]['value']);
|
||||
}
|
||||
|
||||
public function test_suggest_returns_matches_in_display_name_order(): void
|
||||
{
|
||||
DB::table('users')->insert([
|
||||
[
|
||||
'id' => 10,
|
||||
'school_id' => 1,
|
||||
'firstname' => 'Zara',
|
||||
'lastname' => 'Akter',
|
||||
'cellphone' => '555-555-5555',
|
||||
'email' => 'zara.akter@example.com',
|
||||
'address_street' => '123 Main',
|
||||
'city' => 'City',
|
||||
'state' => 'ST',
|
||||
'zip' => '12345',
|
||||
'accept_school_policy' => 1,
|
||||
'is_verified' => 1,
|
||||
'status' => 'Active',
|
||||
'is_suspended' => 0,
|
||||
'failed_attempts' => 0,
|
||||
'password' => bcrypt('secret'),
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
],
|
||||
[
|
||||
'id' => 11,
|
||||
'school_id' => 1,
|
||||
'firstname' => 'Aisha',
|
||||
'lastname' => 'Akter',
|
||||
'cellphone' => '555-555-5556',
|
||||
'email' => 'aisha.akter@example.com',
|
||||
'address_street' => '123 Main',
|
||||
'city' => 'City',
|
||||
'state' => 'ST',
|
||||
'zip' => '12345',
|
||||
'accept_school_policy' => 1,
|
||||
'is_verified' => 1,
|
||||
'status' => 'Active',
|
||||
'is_suspended' => 0,
|
||||
'failed_attempts' => 0,
|
||||
'password' => bcrypt('secret'),
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
],
|
||||
[
|
||||
'id' => 12,
|
||||
'school_id' => 1,
|
||||
'firstname' => 'Mousumi',
|
||||
'lastname' => 'Akter',
|
||||
'cellphone' => '555-555-5557',
|
||||
'email' => 'mousumi.akter@example.com',
|
||||
'address_street' => '123 Main',
|
||||
'city' => 'City',
|
||||
'state' => 'ST',
|
||||
'zip' => '12345',
|
||||
'accept_school_policy' => 1,
|
||||
'is_verified' => 1,
|
||||
'status' => 'Active',
|
||||
'is_suspended' => 0,
|
||||
'failed_attempts' => 0,
|
||||
'password' => bcrypt('secret'),
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
],
|
||||
]);
|
||||
|
||||
$invoiceService = Mockery::mock(DiscountInvoiceService::class);
|
||||
$enrollmentService = Mockery::mock(PaymentEnrollmentEventService::class);
|
||||
|
||||
$service = new PaymentManualService($invoiceService, $enrollmentService);
|
||||
$results = $service->suggest('akter');
|
||||
|
||||
$this->assertSame([
|
||||
'Aisha Akter',
|
||||
'Mousumi Akter',
|
||||
'Zara Akter',
|
||||
], array_column($results, 'label'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user