add refund and event logic

This commit is contained in:
root
2026-03-10 23:12:49 -04:00
parent ba1206e314
commit f6be51576c
67 changed files with 4808 additions and 1000 deletions
@@ -0,0 +1,71 @@
<?php
namespace Tests\Unit\Services\Fees;
use App\Services\Fees\FeeRefundDetailService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class FeeRefundDetailServiceTest extends TestCase
{
use RefreshDatabase;
public function test_calculate_refund_details_returns_amount(): void
{
DB::table('configuration')->insert([
['config_key' => 'school_year', 'config_value' => '2025-2026'],
['config_key' => 'refund_deadline', 'config_value' => '2025-02-01'],
['config_key' => 'book_price', 'config_value' => '20'],
['config_key' => 'first_student_fee', 'config_value' => '350'],
['config_key' => 'second_student_fee', 'config_value' => '200'],
]);
DB::table('students')->insert([
'id' => 1,
'parent_id' => 10,
'firstname' => 'Sam',
'lastname' => 'Parent',
'school_year' => '2025-2026',
]);
DB::table('invoices')->insert([
'id' => 1,
'parent_id' => 10,
'invoice_number' => 'INV-1',
'total_amount' => 350.00,
'balance' => 0.00,
'paid_amount' => 100.00,
'status' => 'Paid',
'school_year' => '2025-2026',
'semester' => 'Fall',
'issue_date' => '2025-01-05',
]);
DB::table('payments')->insert([
'id' => 1,
'parent_id' => 10,
'invoice_id' => 1,
'paid_amount' => 100.00,
'total_amount' => 100.00,
'balance' => 0.00,
'payment_date' => '2025-01-10',
'school_year' => '2025-2026',
'semester' => 'Fall',
'status' => 'Paid',
]);
$service = new FeeRefundDetailService();
$result = $service->calculateRefundDetails([
[
'student_id' => 1,
'enrollment_status' => 'withdrawn',
'withdrawal_date' => '2025-01-15',
],
], 10);
$this->assertTrue($result['ok']);
$this->assertSame(80.0, $result['refund_amount']);
$this->assertTrue($result['eligible']);
}
}
@@ -0,0 +1,52 @@
<?php
namespace Tests\Unit\Services\Fees;
use App\Services\Fees\FeeConfigService;
use App\Services\Fees\FeeGradeService;
use App\Services\Fees\FeeStudentFeeService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class FeeStudentFeeServiceTest extends TestCase
{
use RefreshDatabase;
public function test_total_tuition_fee_applies_tiers_and_youth_fee(): void
{
DB::table('configuration')->insert([
['config_key' => 'first_student_fee', 'config_value' => '350'],
['config_key' => 'second_student_fee', 'config_value' => '200'],
['config_key' => 'youth_fee', 'config_value' => '180'],
]);
DB::table('classSection')->insert([
[
'id' => 1,
'class_id' => 1,
'class_section_id' => 101,
'class_section_name' => '3',
'semester' => 'Fall',
'school_year' => '2025-2026',
],
[
'id' => 2,
'class_id' => 2,
'class_section_id' => 102,
'class_section_name' => '10',
'semester' => 'Fall',
'school_year' => '2025-2026',
],
]);
$service = new FeeStudentFeeService(new FeeGradeService(), new FeeConfigService());
$total = $service->totalTuitionFee([
['class_section_id' => 101],
['class_section_id' => 102],
]);
$this->assertSame(530.0, $total);
}
}