Files
alrahma_sunday_school_api/tests/Unit/Services/Billing/BillingTotalsServiceTest.php
T
2026-03-10 23:12:49 -04:00

62 lines
1.7 KiB
PHP

<?php
namespace Tests\Unit\Services\Billing;
use App\Services\Billing\BillingTotalsService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class BillingTotalsServiceTest extends TestCase
{
use RefreshDatabase;
public function test_event_and_additional_subtotals(): void
{
DB::table('events')->insert([
'id' => 1,
'event_name' => 'Field Trip',
'amount' => 25.00,
]);
DB::table('event_charges')->insert([
'id' => 1,
'event_id' => 1,
'parent_id' => 10,
'charged' => 25.00,
'school_year' => '2025-2026',
]);
DB::table('additional_charges')->insert([
[
'id' => 1,
'invoice_id' => 99,
'parent_id' => 10,
'school_year' => '2025-2026',
'semester' => 'Fall',
'charge_type' => 'add',
'amount' => 15.00,
'status' => 'applied',
],
[
'id' => 2,
'invoice_id' => 99,
'parent_id' => 10,
'school_year' => '2025-2026',
'semester' => 'Fall',
'charge_type' => 'deduct',
'amount' => 5.00,
'status' => 'applied',
],
]);
$service = new BillingTotalsService();
$eventSubtotal = $service->eventSubtotal(10, '2025-2026');
$additionalSubtotal = $service->additionalSubtotal(99, '2025-2026');
$this->assertSame(25.0, $eventSubtotal);
$this->assertSame(10.0, $additionalSubtotal);
}
}