feat: update session payment logic to ensure accurate payable amounts and reflect consumables in cost breakdown

- Adjusted the calculation of payable amounts in PaymentStep to align with server logic, ensuring overpayments are handled correctly.
- Enhanced DetailsStep to include consumables in the itemized cost breakdown, ensuring consistency with patient share calculations.
- Updated tests for SessionPaymentPage to validate new behavior regarding overpayments and consumable listings.
- Modified PatientController to register SessionPayment correctly when settling sessions via wallet, preventing double charges.
- Refactored WalletService to remove outdated methods and ensure wallet transactions reflect the correct amounts after discounts.
- Improved accessibility in SearchableSelect component by adding aria labels and ensuring proper role attributes for screen readers.
- Updated styles to ensure minimum touch targets meet WCAG guidelines for mobile usability.
This commit is contained in:
hamed
2026-07-19 13:29:46 +03:30
parent 0d9784b03a
commit 773f9d4d16
22 changed files with 251 additions and 70 deletions
@@ -34,7 +34,8 @@ beforeEach(() => {
{ insurance_id: 5, insurance_name: 'بیمه دانا', type: 'supplementary' },
],
} });
if (url === '/api/v1/patient/r1/sessions') return Promise.resolve({ success: true, data: [
// صفحه ?filter=active را هم اضافه می‌کند، پس تطبیق باید پیشوندی باشد
if (url.startsWith('/api/v1/patient/r1/sessions')) return Promise.resolve({ success: true, data: [
{ uuid: 's1', services: [{ service_name: 'اسکیلینگ' }], doctor_name: 'دکتر فتحی', final_price_rials: 2500000, is_paid: false, patient_debt_rials: 1500000, notes: 'یادداشت', created_at: 1700000000, visit_price_rials: 0 },
{ uuid: 's2', services: [{ service_name: 'روکش' }], doctor_name: 'دکتر فتحی', final_price_rials: 2350000, is_paid: true, patient_debt_rials: 0, invoice_uuid: 'iv1', created_at: 1700000000, visit_price_rials: 0 },
], meta: { totalRecords: 2 } });
@@ -103,7 +104,7 @@ describe('PatientDetailPage (پرونده تب‌دار)', () => {
it('issues the invoice first (create + finalize) when the paid session has none', async () => {
const base = get.getMockImplementation()!;
get.mockImplementation((url: string) => {
if (url === '/api/v1/patient/r1/sessions') return Promise.resolve({ success: true, data: [
if (url.startsWith('/api/v1/patient/r1/sessions')) return Promise.resolve({ success: true, data: [
{ uuid: 's3', services: [{ service_name: 'لیزر' }], doctor_name: 'دکتر فتحی', final_price_rials: 1000000, is_paid: true, patient_debt_rials: 0, created_at: 1700000000, visit_price_rials: 0 },
], meta: { totalRecords: 1 } });
if (url === '/api/v1/billing/invoices/iv9') return Promise.resolve({ success: true, data: { data: {