fix the forecast tuition
This commit is contained in:
@@ -65,6 +65,7 @@ class FakeForecastService extends TuitionForecastService
|
||||
'include_event_only' => $options['include_event_only'] ?? '0',
|
||||
'include_paid_invoices' => $options['include_paid_invoices'] ?? '0',
|
||||
'unit_price' => $options['unit_price'] ?? '370.00',
|
||||
'youth_unit_price' => $options['youth_unit_price'] ?? '200.00',
|
||||
],
|
||||
'summary' => [
|
||||
'family_count' => 1,
|
||||
@@ -75,6 +76,7 @@ class FakeForecastService extends TuitionForecastService
|
||||
'old_projected_income' => '550.00',
|
||||
'new_projected_income' => '650.00',
|
||||
'unit_price' => '370.00',
|
||||
'youth_unit_price' => '200.00',
|
||||
'difference' => '100.00',
|
||||
],
|
||||
'families' => [[
|
||||
@@ -160,6 +162,7 @@ class TuitionForecastControllerTest extends CIUnitTestCase
|
||||
'include_event_only' => '1',
|
||||
'include_paid_invoices' => '1',
|
||||
'unit_price' => '395.00',
|
||||
'youth_unit_price' => '200.00',
|
||||
]);
|
||||
|
||||
$result = $this->controller->setRequestObject($request)->index();
|
||||
@@ -170,6 +173,7 @@ class TuitionForecastControllerTest extends CIUnitTestCase
|
||||
$this->assertSame('new', $result['data']['filters']['calculator_mode']);
|
||||
$this->assertSame('1', $result['data']['filters']['include_payment_pending']);
|
||||
$this->assertSame('395.00', $result['data']['filters']['unit_price']);
|
||||
$this->assertSame('200.00', $result['data']['filters']['youth_unit_price']);
|
||||
$this->assertSame('always', $this->service->calls[0]['options']['include_withdrawn_mode']);
|
||||
}
|
||||
|
||||
@@ -184,6 +188,7 @@ class TuitionForecastControllerTest extends CIUnitTestCase
|
||||
'include_event_only' => '0',
|
||||
'include_paid_invoices' => '1',
|
||||
'unit_price' => '390.00',
|
||||
'youth_unit_price' => '210.00',
|
||||
]);
|
||||
|
||||
$response = $this->controller->setRequestObject($request)->calculate();
|
||||
@@ -193,6 +198,7 @@ class TuitionForecastControllerTest extends CIUnitTestCase
|
||||
$this->assertSame('Fall', $payload['semester']);
|
||||
$this->assertSame('compare', $payload['calculator_mode']);
|
||||
$this->assertSame('390.00', $payload['options']['unit_price']);
|
||||
$this->assertSame('210.00', $payload['options']['youth_unit_price']);
|
||||
}
|
||||
|
||||
public function testExportCsvBuildsDownloadWithSummaryAndFamilyRows(): void
|
||||
@@ -210,6 +216,7 @@ class TuitionForecastControllerTest extends CIUnitTestCase
|
||||
$this->assertStringContainsString('Summary', $body);
|
||||
$this->assertStringContainsString('All Year', $body);
|
||||
$this->assertStringContainsString('Old Projected Income', $body);
|
||||
$this->assertStringContainsString('Youth Unit Price', $body);
|
||||
$this->assertStringContainsString('Layla Yusuf', $body);
|
||||
$this->assertStringContainsString('Student One', $body);
|
||||
}
|
||||
|
||||
@@ -51,4 +51,29 @@ class NewTuitionCalculatorServiceTest extends CIUnitTestCase
|
||||
$this->assertSame('0.00', $result['details'][3]['amount']);
|
||||
$this->assertSame('0.00', $result['details'][4]['amount']);
|
||||
}
|
||||
|
||||
public function testYouthStudentsUseSeparateUnitPriceWithoutAffectingRegularDiscountOrder(): void
|
||||
{
|
||||
$service = new NewTuitionCalculatorService();
|
||||
$result = $service->calculateFamilyTuition([
|
||||
['student_id' => 3, 'student_name' => 'Youth', 'grade_level' => 'Youth 1'],
|
||||
['student_id' => 1, 'student_name' => 'Regular One', 'grade_level' => '2'],
|
||||
['student_id' => 2, 'student_name' => 'Regular Two', 'grade_level' => '5'],
|
||||
], [
|
||||
'grade_fee' => 9,
|
||||
'new_tuition_full_amount' => '370.00',
|
||||
'new_tuition_youth_amount' => '200.00',
|
||||
'new_tuition_second_student_discount' => '150.00',
|
||||
'new_tuition_third_student_discount' => '150.00',
|
||||
'new_tuition_fourth_plus_discount' => '150.00',
|
||||
]);
|
||||
|
||||
$this->assertSame('790.00', $result['total']);
|
||||
$this->assertSame('new_first_student_full_amount', $result['details'][0]['rule']);
|
||||
$this->assertSame('370.00', $result['details'][0]['amount']);
|
||||
$this->assertSame('new_second_student_discount', $result['details'][1]['rule']);
|
||||
$this->assertSame('220.00', $result['details'][1]['amount']);
|
||||
$this->assertSame('new_youth_unit_price', $result['details'][2]['rule']);
|
||||
$this->assertSame('200.00', $result['details'][2]['amount']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,10 +38,12 @@ class TuitionForecastServiceTest extends CIUnitTestCase
|
||||
'students' => [
|
||||
['student_id' => 1, 'student_name' => 'Mariam', 'grade_level' => '1'],
|
||||
['student_id' => 2, 'student_name' => 'Yahya', 'grade_level' => '2'],
|
||||
['student_id' => 4, 'student_name' => 'Youth Student', 'grade_level' => 'Youth 1'],
|
||||
],
|
||||
'all_students' => [
|
||||
['student_id' => 1, 'student_name' => 'Mariam', 'grade_level' => '1', 'billable' => true, 'excluded_reason' => null],
|
||||
['student_id' => 2, 'student_name' => 'Yahya', 'grade_level' => '2', 'billable' => true, 'excluded_reason' => null],
|
||||
['student_id' => 4, 'student_name' => 'Youth Student', 'grade_level' => 'Youth 1', 'billable' => true, 'excluded_reason' => null],
|
||||
['student_id' => 3, 'student_name' => 'Event Only', 'grade_level' => '3', 'billable' => false, 'excluded_reason' => 'event_only'],
|
||||
],
|
||||
'warnings' => ['1 event-only student(s) excluded from tuition.'],
|
||||
@@ -54,8 +56,9 @@ class TuitionForecastServiceTest extends CIUnitTestCase
|
||||
'grade_fee' => 9,
|
||||
'first_student_fee' => '350.00',
|
||||
'second_student_fee' => '200.00',
|
||||
'youth_fee' => '180.00',
|
||||
'youth_fee' => '200.00',
|
||||
'new_tuition_full_amount' => $this->unitPriceOverride ?? '350.00',
|
||||
'new_tuition_youth_amount' => $this->youthUnitPriceOverride ?? '200.00',
|
||||
'new_tuition_second_student_discount' => '50.00',
|
||||
'new_tuition_third_student_discount' => '50.00',
|
||||
'new_tuition_fourth_plus_discount' => '100.00',
|
||||
@@ -67,16 +70,18 @@ class TuitionForecastServiceTest extends CIUnitTestCase
|
||||
'include_payment_pending' => true,
|
||||
'include_withdrawn_mode' => 'refund_deadline',
|
||||
'unit_price' => '400.00',
|
||||
'youth_unit_price' => '200.00',
|
||||
]);
|
||||
|
||||
$this->assertSame(1, $result['summary']['family_count']);
|
||||
$this->assertSame(3, $result['summary']['student_count']);
|
||||
$this->assertSame(2, $result['summary']['billable_student_count']);
|
||||
$this->assertSame('550.00', $result['summary']['old_projected_tuition']);
|
||||
$this->assertSame('750.00', $result['summary']['new_projected_tuition']);
|
||||
$this->assertSame('550.00', $result['summary']['old_projected_income']);
|
||||
$this->assertSame('750.00', $result['summary']['new_projected_income']);
|
||||
$this->assertSame(4, $result['summary']['student_count']);
|
||||
$this->assertSame(3, $result['summary']['billable_student_count']);
|
||||
$this->assertSame('750.00', $result['summary']['old_projected_tuition']);
|
||||
$this->assertSame('950.00', $result['summary']['new_projected_tuition']);
|
||||
$this->assertSame('750.00', $result['summary']['old_projected_income']);
|
||||
$this->assertSame('950.00', $result['summary']['new_projected_income']);
|
||||
$this->assertSame('400.00', $result['summary']['unit_price']);
|
||||
$this->assertSame('event_only', $result['families'][0]['student_details'][2]['excluded_reason']);
|
||||
$this->assertSame('200.00', $result['summary']['youth_unit_price']);
|
||||
$this->assertSame('event_only', $result['families'][0]['student_details'][3]['excluded_reason']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user