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:
hamed
2026-07-29 13:28:59 +03:30
parent 11b4dcdd34
commit 4f4bce9fe2
31 changed files with 1497 additions and 137 deletions
@@ -89,17 +89,23 @@ describe('patientShareOf — آینه‌ی BillingCalculator', () => {
});
it('فرانشیز بیمهٔ پایه سهم بیمار را زیاد نمی‌کند', () => {
const share = patientShareOf(600_000, { covered: true, percent: 100, franchise: 50_000, ceiling: null }, null);
const share = patientShareOf(600_000, { covered: true, percent: 100, franchise: 50, ceiling: null }, null);
expect(share).toBe(0);
});
it('فرانشیز بیمهٔ تکمیلی به سهم بیمار اضافه می‌شود', () => {
it('فرانشیز درصدیِ تکمیلی از سهم بیمه کم می‌شود', () => {
// پایه ۷۰٪ → ۴۲۰٬۰۰۰؛ باقیمانده ۱۸۰٬۰۰۰؛ تکمیلی ۱۰۰٪ منهای فرانشیز ۱۰٪ → ۱۶۲٬۰۰۰.
const share = patientShareOf(
600_000,
{ covered: true, percent: 70, franchise: 90_000, ceiling: null },
{ covered: true, percent: 100, franchise: 50_000, ceiling: null },
{ covered: true, percent: 70, franchise: 50, ceiling: null },
{ covered: true, percent: 100, franchise: 10, ceiling: null },
);
expect(share).toBe(50_000);
expect(share).toBe(18_000);
});
it('فرانشیز بزرگ‌تر از تعهد، سهم بیمه را صفر می‌کند نه منفی', () => {
const share = patientShareOf(600_000, null, { covered: true, percent: 20, franchise: 80, ceiling: null });
expect(share).toBe(600_000);
});
it('سقف تعهد سهم بیمه را محدود می‌کند', () => {
@@ -117,7 +123,7 @@ describe('patientShareOf — آینه‌ی BillingCalculator', () => {
const BASIC_CONTRACT = {
uuid: 'c1', insurance_id: 3, insurance_name: 'بیمه ایران', insurance_kind: 'basic',
is_active: true, coverage_percent: 70, franchise_rials: 0, annual_ceiling_rials: null,
is_active: true, coverage_percent: 70, franchise_percent: 0, annual_ceiling_rials: null,
category_coverages: { outpatient: 70, inpatient: 30 },
};