fix apply the plan docs/alrahma_api_fix_plan_school_year_only_v7
API CI/CD / Validate (composer + pint) (push) Successful in 3m10s
API CI/CD / Test (PHPUnit) (push) Failing after 6m49s
API CI/CD / Build frontend assets (push) Successful in 1m3s
API CI/CD / Security audit (push) Failing after 1m0s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
API CI/CD / Validate (composer + pint) (push) Successful in 3m10s
API CI/CD / Test (PHPUnit) (push) Failing after 6m49s
API CI/CD / Build frontend assets (push) Successful in 1m3s
API CI/CD / Security audit (push) Failing after 1m0s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
This commit is contained in:
@@ -20,6 +20,7 @@ class FamilyFinanceServiceTest extends TestCase
|
||||
'total_amount' => 100,
|
||||
'paid_amount' => 20,
|
||||
'balance' => 80,
|
||||
'school_year' => '2025-2026',
|
||||
'issue_date' => now()->toDateString(),
|
||||
'due_date' => now()->addDays(5)->toDateString(),
|
||||
'created_at' => now(),
|
||||
@@ -36,16 +37,90 @@ class FamilyFinanceServiceTest extends TestCase
|
||||
'payment_method' => 'cash',
|
||||
'payment_date' => now()->toDateString(),
|
||||
'status' => 'completed',
|
||||
'school_year' => '2024-2025',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$service = new FamilyFinanceService;
|
||||
$result = $service->loadFinancialsForParents([1]);
|
||||
$result = $service->loadFinancialsForParents([1], '2025-2026');
|
||||
|
||||
$this->assertSame(1, $result['summary']['invoices_count']);
|
||||
$this->assertSame(100.0, $result['summary']['total_amount']);
|
||||
$this->assertSame(80.0, $result['summary']['positive_unpaid_balance']);
|
||||
$this->assertSame(0.0, $result['summary']['credit_balance']);
|
||||
$this->assertNotEmpty($result['invoices']);
|
||||
$this->assertNotEmpty($result['payments']);
|
||||
}
|
||||
|
||||
public function test_load_financials_filters_invoices_and_payments_by_selected_year(): void
|
||||
{
|
||||
DB::table('invoices')->insert([
|
||||
[
|
||||
'id' => 10,
|
||||
'parent_id' => 1,
|
||||
'invoice_number' => 'INV-2025',
|
||||
'status' => 'open',
|
||||
'total_amount' => 100,
|
||||
'paid_amount' => 0,
|
||||
'balance' => 100,
|
||||
'school_year' => '2025-2026',
|
||||
'issue_date' => now()->toDateString(),
|
||||
'due_date' => now()->addDays(5)->toDateString(),
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
[
|
||||
'id' => 11,
|
||||
'parent_id' => 1,
|
||||
'invoice_number' => 'INV-2024',
|
||||
'status' => 'open',
|
||||
'total_amount' => 75,
|
||||
'paid_amount' => 0,
|
||||
'balance' => -25,
|
||||
'school_year' => '2024-2025',
|
||||
'issue_date' => now()->subYear()->toDateString(),
|
||||
'due_date' => now()->subYear()->addDays(5)->toDateString(),
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
]);
|
||||
|
||||
DB::table('payments')->insert([
|
||||
[
|
||||
'parent_id' => 1,
|
||||
'invoice_id' => 10,
|
||||
'total_amount' => 100,
|
||||
'paid_amount' => 50,
|
||||
'balance' => 50,
|
||||
'number_of_installments' => 1,
|
||||
'payment_method' => 'cash',
|
||||
'payment_date' => now()->toDateString(),
|
||||
'status' => 'completed',
|
||||
'school_year' => '2025-2026',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
[
|
||||
'parent_id' => 1,
|
||||
'invoice_id' => 11,
|
||||
'total_amount' => 75,
|
||||
'paid_amount' => 75,
|
||||
'balance' => -25,
|
||||
'number_of_installments' => 1,
|
||||
'payment_method' => 'cash',
|
||||
'payment_date' => now()->subYear()->toDateString(),
|
||||
'status' => 'completed',
|
||||
'school_year' => '2025-2026',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
]);
|
||||
|
||||
$service = new FamilyFinanceService;
|
||||
$result = $service->loadFinancialsForParents([1], '2025-2026');
|
||||
|
||||
$this->assertSame(['INV-2025'], array_column($result['invoices'], 'invoice_number'));
|
||||
$this->assertSame([10], array_column($result['payments'], 'invoice_id'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Models\User;
|
||||
use App\Services\Staff\StaffCommandService;
|
||||
use App\Services\System\GlobalConfigService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\TestCase;
|
||||
|
||||
class StaffCommandServiceTest extends TestCase
|
||||
@@ -15,6 +16,7 @@ class StaffCommandServiceTest extends TestCase
|
||||
|
||||
public function test_create_requires_user(): void
|
||||
{
|
||||
$this->seedRole('teacher');
|
||||
$service = new StaffCommandService(new GlobalConfigService);
|
||||
|
||||
$this->expectException(\RuntimeException::class);
|
||||
@@ -28,6 +30,7 @@ class StaffCommandServiceTest extends TestCase
|
||||
|
||||
public function test_create_with_user_id(): void
|
||||
{
|
||||
$this->seedRole('teacher');
|
||||
$user = User::query()->create([
|
||||
'firstname' => 'Test',
|
||||
'lastname' => 'User',
|
||||
@@ -57,4 +60,18 @@ class StaffCommandServiceTest extends TestCase
|
||||
$this->assertInstanceOf(Staff::class, $staff);
|
||||
$this->assertSame($user->id, $staff->user_id);
|
||||
}
|
||||
|
||||
private function seedRole(string $name): void
|
||||
{
|
||||
DB::table('roles')->updateOrInsert(
|
||||
['name' => $name],
|
||||
[
|
||||
'slug' => $name,
|
||||
'priority' => 1,
|
||||
'is_active' => 1,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user