feat(migrations): update franchise to percentage in tenant_insurances and tenant_service_coverage
- Changed franchise_rials to franchise_percent in tenant_insurances and tenant_service_coverage tables. - Reset old rial values to 0/NULL as they are not convertible to percentage. feat(command): add SeedInsuranceScenarioCommand for seeding insurance data - Implemented a command to seed supplementary insurance contracts, patients, and claims for a specified doctor. - Includes functionality for purging existing scenario data and generating new entries with predefined contracts and patient scenarios.
This commit is contained in:
@@ -70,6 +70,45 @@ class TenantInsuranceCategoryCoverageApiTest extends ApiTestCase
|
||||
$this->assertSame('admin_default', $row['category_coverage_source']['outpatient']);
|
||||
}
|
||||
|
||||
public function testAnEnabledServiceKindCannotBeLeftWithoutAPercent(): void
|
||||
{
|
||||
// بدون پیشفرض مرکزی: ارسال درصد فقط برای سرپایی، بستری را صفر رها میکند.
|
||||
[$owner, $insurance] = $this->makeDoctorAndInsurance();
|
||||
|
||||
$body = $this->authJson('POST', '/api/v1/billing/tenant-insurances', $owner, [
|
||||
'insurance_id' => $insurance->getId(),
|
||||
'category_coverages' => [
|
||||
['key' => 'outpatient', 'coverage_percent' => 70],
|
||||
['key' => 'inpatient', 'coverage_percent' => null],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertSame(422, $this->responseCode());
|
||||
$this->assertSame('category_coverages', $body['errors'][0]['field']);
|
||||
$this->assertStringContainsString('خدمات بستری', $body['errors'][0]['message']);
|
||||
}
|
||||
|
||||
public function testADisabledServiceKindNeedsNoPercent(): void
|
||||
{
|
||||
[$owner, $insurance] = $this->makeDoctorAndInsurance();
|
||||
$this->authJson('PUT', '/api/v1/insurance-pricing', $owner, [
|
||||
'service_categories' => [
|
||||
['key' => 'outpatient', 'enabled' => true],
|
||||
['key' => 'inpatient', 'enabled' => false],
|
||||
],
|
||||
]);
|
||||
|
||||
$body = $this->authJson('POST', '/api/v1/billing/tenant-insurances', $owner, [
|
||||
'insurance_id' => $insurance->getId(),
|
||||
'category_coverages' => [
|
||||
['key' => 'outpatient', 'coverage_percent' => 70],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertSame(201, $this->responseCode());
|
||||
$this->assertEquals(70.0, $body['data']['data']['category_coverages']['outpatient']);
|
||||
}
|
||||
|
||||
public function testListReturnsEffectivePercentsAndSources(): void
|
||||
{
|
||||
[$owner, $insurance] = $this->makeDoctorAndInsurance();
|
||||
@@ -113,8 +152,10 @@ class TenantInsuranceCategoryCoverageApiTest extends ApiTestCase
|
||||
public function testPatchCanDropAnOverrideBackToTheAdminDefault(): void
|
||||
{
|
||||
[$owner, $insurance] = $this->makeDoctorAndInsurance();
|
||||
// سرپایی هم پیشفرض دارد، وگرنه ساخت قرارداد بهخاطر «درصد پوشش الزامی است» رد میشود.
|
||||
static::getContainer()->get(InsuranceCoverageDefaultService::class)->save($insurance->getId(), [
|
||||
['key' => 'inpatient', 'coverage_percent' => 30],
|
||||
['key' => 'outpatient', 'coverage_percent' => 50],
|
||||
['key' => 'inpatient', 'coverage_percent' => 30],
|
||||
]);
|
||||
|
||||
$created = $this->authJson('POST', '/api/v1/billing/tenant-insurances', $owner, [
|
||||
|
||||
Reference in New Issue
Block a user