update api and add more features
This commit is contained in:
@@ -17,6 +17,7 @@ class BillingTotalsServiceTest extends TestCase
|
||||
'id' => 1,
|
||||
'event_name' => 'Field Trip',
|
||||
'amount' => 25.00,
|
||||
'expiration_date' => '2025-06-01',
|
||||
]);
|
||||
|
||||
DB::table('event_charges')->insert([
|
||||
@@ -58,4 +59,78 @@ class BillingTotalsServiceTest extends TestCase
|
||||
$this->assertSame(25.0, $eventSubtotal);
|
||||
$this->assertSame(10.0, $additionalSubtotal);
|
||||
}
|
||||
|
||||
public function test_additional_subtotal_by_parent_sums_applied_charges(): void
|
||||
{
|
||||
DB::table('additional_charges')->insert([
|
||||
[
|
||||
'parent_id' => 10,
|
||||
'invoice_id' => 99,
|
||||
'school_year' => '2025-2026',
|
||||
'semester' => 'Fall',
|
||||
'charge_type' => 'add',
|
||||
'title' => 'Uniform',
|
||||
'amount' => 40.00,
|
||||
'status' => 'applied',
|
||||
],
|
||||
[
|
||||
'parent_id' => 10,
|
||||
'invoice_id' => 99,
|
||||
'school_year' => '2025-2026',
|
||||
'semester' => 'Fall',
|
||||
'charge_type' => 'deduct',
|
||||
'title' => 'Credit',
|
||||
'amount' => 10.00,
|
||||
'status' => 'applied',
|
||||
],
|
||||
[
|
||||
'parent_id' => 10,
|
||||
'invoice_id' => 99,
|
||||
'school_year' => '2025-2026',
|
||||
'semester' => 'Fall',
|
||||
'charge_type' => 'add',
|
||||
'title' => 'Pending',
|
||||
'amount' => 99.00,
|
||||
'status' => 'pending',
|
||||
],
|
||||
]);
|
||||
|
||||
$service = new BillingTotalsService();
|
||||
|
||||
$this->assertSame(30.0, $service->additionalSubtotalByParent(10, '2025-2026'));
|
||||
}
|
||||
|
||||
public function test_event_subtotals_by_student_groups_amounts(): void
|
||||
{
|
||||
DB::table('events')->insert([
|
||||
'id' => 1,
|
||||
'event_name' => 'Trip',
|
||||
'amount' => 20.00,
|
||||
'expiration_date' => '2025-06-01',
|
||||
]);
|
||||
|
||||
DB::table('event_charges')->insert([
|
||||
[
|
||||
'event_id' => 1,
|
||||
'parent_id' => 5,
|
||||
'student_id' => 1,
|
||||
'charged' => 20.00,
|
||||
'school_year' => '2025-2026',
|
||||
],
|
||||
[
|
||||
'event_id' => 1,
|
||||
'parent_id' => 5,
|
||||
'student_id' => 2,
|
||||
'charged' => 15.00,
|
||||
'school_year' => '2025-2026',
|
||||
],
|
||||
]);
|
||||
|
||||
$service = new BillingTotalsService();
|
||||
$byStudent = $service->eventSubtotalsByStudent(5, '2025-2026');
|
||||
|
||||
$this->assertSame(20.0, $byStudent[1]);
|
||||
$this->assertSame(15.0, $byStudent[2]);
|
||||
$this->assertSame(35.0, $service->eventSubtotal(5, '2025-2026'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user