Refactor insurance share calculation logic in PatientService
- Consolidated the calculation of patient and insurance shares into a single method using BillingCalculator. - Introduced new fields in PatientSession to store breakdown of insurance shares and patient share. - Updated the API responses to include the new fields for consistency across payment, invoice, and claims dashboard. - Added migration to backfill existing sessions with appropriate values for the new fields. - Implemented tests to ensure the correctness of the new logic and verify that the breakdown sums to the gross total. - Redesigned the claims dashboard to provide a more user-friendly overview of patient claims and their statuses.
This commit is contained in:
@@ -539,7 +539,6 @@ export interface ServiceItem {
|
||||
staff_members?: { uuid: string; full_name: string }[];
|
||||
active: boolean;
|
||||
insurance_covered?: boolean;
|
||||
insurance_price_rials?: number | null;
|
||||
duration_minutes?: number | null;
|
||||
bookable?: boolean;
|
||||
}
|
||||
@@ -670,7 +669,14 @@ export interface PatientSession {
|
||||
base_insurance_discount_percent: string;
|
||||
supplementary_discount_percent: string;
|
||||
services_total_rials: number;
|
||||
/** تفکیک بیمه — سرور محاسبه میکند؛ کلاینت هرگز خودش نسازد */
|
||||
gross_total_rials?: number;
|
||||
base_insurance_rials?: number;
|
||||
supplementary_insurance_rials?: number;
|
||||
patient_share_rials?: number;
|
||||
final_price_rials: number;
|
||||
remaining_rials?: number;
|
||||
paid_total_rials?: number;
|
||||
payment_method: string;
|
||||
is_paid?: boolean;
|
||||
services?: SessionServiceLine[];
|
||||
|
||||
Reference in New Issue
Block a user