Test plansClinic app
Test Plan: Billing & Follow-ups (Queue Panel)
Module: Clinic App — Billing Panel from Queue Code Audit Date: 2026-06-17 URL: Queue page → Click "+" (Billing) button on patient row Status: Pending
Code Audit Summary
Billing Panel Sections
| Section | Component | Purpose | API |
|---|---|---|---|
| BillingHeader | BillingHeader.tsx | Patient name, phone, doctor | — |
| BillingSummaryCard | BillingSummaryCard.tsx | Total services, total paid, balance due | Calculated client-side from services + payments |
| ServiceSection | ServiceSection.tsx | Add/Edit/Delete services, select from catalog, generate bill | useServices, useCreateService, useUpdateService, useDeleteService, useFacilityServices, useCreateInvoice |
| PaymentSection | PaymentSection.tsx | Add/Edit/Delete payments (cash/card/UPI/bank) | usePayments, useCreatePayment, useUpdatePayment, useDeletePayment |
| NextVisitSection | NextVisitSection.tsx | Schedule/cancel follow-up | useCreateNextVisit, useCancelNextVisit, useFollowUps |
| BillsSection | BillsSection.tsx | View/bill invoices, download PDF | useInvoices |
Permission Gate
- Billing button visible only when
canManageBilling = true - Roles: owner, admin, practitioner (not staff)
SECTION 1: Billing Panel — Open & Header
| # | Test Case | Priority | Expected | Status |
|---|---|---|---|---|
| BILL-01 | Open billing panel | P0 | Click "+" on queue row → BillingPanel slides in from right | Pending |
| BILL-02 | Patient info in header | P0 | Shows patient name, phone, assigned doctor | Pending |
| BILL-03 | Close billing panel | P0 | Click X or outside → panel closes | Pending |
| BILL-04 | Panel — loading state | P1 | Loading spinner while services/payments/invoices fetch | Pending |
| BILL-05 | Panel — error state | P1 | API fails → error message shown | Pending |
| BILL-06 | Panel — empty state (no services/payments) | P0 | New patient: summary shows ₹0, no services/payments listed | Pending |
SECTION 2: Service Management
2.1 Add Service
| # | Test Case | Priority | Expected | Status |
|---|---|---|---|---|
| BILL-11 | Add service — from catalog only | P0 | Select service from facility catalog, price auto-filled from catalog, quantity editable | ✅ PASS |
| BILL-12 | Add service — required fields | P0 | Leave service empty → validation error | ✅ PASS |
| BILL-13 | Add service — price auto-filled | P1 | Price is auto-filled from the service catalog and locked; Override unlocks it and a reason is required before Add (#1838) | Pending |
| BILL-14 | Add service — multiple services | P0 | Add 3 services → all appear in list, summary updates | ✅ PASS |
| BILL-15 | Add service — duplicate service | P1 | Add same service twice → both shown | ✅ PASS |
2.2 Edit Service
| # | Test Case | Priority | Expected | Status |
|---|---|---|---|---|
| BILL-20 | Edit service — name | P0 | Click edit on service → change name → Save → updated | Pending |
| BILL-21 | Edit service — quantity | P0 | Change quantity → Save → total recalculated | Pending |
| BILL-22 | Edit service — price | P0 | Queue panel: Override → change price → reason required → Update → summary updates. Patient page: change amount → "Reason required" field appears → Update waits for it. Reopen: price unlocked, reason filled in. Enter the catalog price again → saved as catalog, stored reason cleared (#2569) | Pending |
| BILL-23 | Cancel edit | P0 | Open edit → Cancel → no changes | Pending |
2.3 Delete Service
| # | Test Case | Priority | Expected | Status |
|---|---|---|---|---|
| BILL-30 | Delete service | P0 | Click delete → confirmation dialog with reason → service removed | Pending |
| BILL-31 | Delete service — cancel | P1 | Open delete dialog → Cancel → service not removed | Pending |
| BILL-32 | Delete service — reason required | P1 | Remove with empty reason → validation? | Pending |
2.4 Service Summary
| # | Test Case | Priority | Expected | Status |
|---|---|---|---|---|
| BILL-35 | Total services amount updates | P0 | Add services → summary card shows total services | Pending |
| BILL-36 | Quantity × price calculation | P0 | Service qty=2, price=500 → shows ₹1000 | Pending |
SECTION 3: Payment Management
3.1 Add Payment
| # | Test Case | Priority | Expected | Status |
|---|---|---|---|---|
| BILL-40 | Add payment — cash | P0 | Select "Cash" method, enter amount → Add | ✅ PASS |
| BILL-41 | Add payment — card | P0 | Select "Card" method → Add | ✅ PASS |
| BILL-42 | Add payment — UPI | P0 | Select "UPI" method → Add | ✅ PASS |
| BILL-43 | Add payment — bank transfer | P0 | Select "Bank Transfer" → Add | ✅ PASS |
| BILL-44 | Add payment — gateway (Razorpay/Cashfree) | P0 | Select "Gateway" → 500 Internal Server Error | Bug #50 ❌ |
| BILL-45 | Add payment — amount validation | P0 | Enter 0 or negative → error | ✅ PASS |
| BILL-46 | Add payment — multiple payments | P0 | Add 2 payments → both listed, summary updates | ✅ PASS |
| BILL-47 | Payment method icon displayed | P1 | Each method shows correct icon | ✅ PASS |
3.2 Edit Payment
| # | Test Case | Priority | Expected | Status |
|---|---|---|---|---|
| BILL-50 | Edit payment — amount | P0 | Change amount → Save → total recalculated | Pending |
| BILL-51 | Edit payment — method | P1 | Change method → Save → icon updates | Pending |
| BILL-52 | Cancel edit payment | P0 | Open edit → Cancel → no changes | Pending |
3.3 Delete Payment
| # | Test Case | Priority | Expected | Status |
|---|---|---|---|---|
| BILL-55 | Delete payment | P0 | Click delete → confirmation dialog → payment removed | ✅ PASS |
| BILL-56 | Delete payment — cancel | P1 | Open delete → Cancel → payment stays | ✅ PASS |
| BILL-57 | Delete dialog — reason not cleared on close | P1 | Click outside to close delete dialog, reopen → previous reason still filled | Bug #52 ⚠️ |
3.4 Payment Summary
| # | Test Case | Priority | Expected | Status |
|---|---|---|---|---|
| BILL-60 | Total paid updates | P0 | Add payment → summary shows total paid | Pending |
| BILL-61 | Balance due calculation | P0 | Services ₹1000, Paid ₹400 → Balance ₹600 | Pending |
| BILL-62 | Overpaid balance | P1 | Paid more than services → negative balance or 0? | Pending |
| BILL-63 | Zero balance (fully paid) | P1 | Services = Paid → Balance ₹0 | Pending |
SECTION 4: Bill Generation
4.1 Select Services & Generate Bill
| # | Test Case | Priority | Expected | Status |
|---|---|---|---|---|
| BILL-70 | Select services for bill | P0 | Checkbox next to each service → select 2 of 3 services | Pending |
| BILL-71 | Generate bill button | P0 | Select services → "Generate Bill" button appears/enables | Pending |
| BILL-72 | Generate bill — success | P0 | Click Generate → invoice created, appears in Bills section | Pending |
| BILL-73 | Generate bill — no services selected | P1 | Click without selecting → error/prevention | Pending |
| BILL-74 | Generate bill — all services | P0 | Select all services → bill covers everything | Pending |
4.2 Bills Section
| # | Test Case | Priority | Expected | Status |
|---|---|---|---|---|
| BILL-80 | Bills section — shows invoices | P0 | Generated bills appear in collapsible Bills section | Pending |
| BILL-81 | Bills section — empty | P0 | No bills generated → empty state | Pending |
| BILL-82 | Bill — status indicator | P1 | Each bill shows status dot (paid/unpaid/draft) | Pending |
| BILL-83 | Download bill PDF | P0 | Click download → PDF generated and downloaded | Pending |
| BILL-84 | View bill | P1 | Click view → opens bill detail or PDF preview | Pending |
| BILL-85 | Navigate to bills page | P1 | "View All Bills" link → navigates to full bills page | Pending |
SECTION 5: Follow-up / Next Visit
5.1 Schedule Follow-up
| # | Test Case | Priority | Expected | Status |
|---|---|---|---|---|
| BILL-90 | Next visit section — empty | P0 | No existing follow-up → shows form to schedule | ✅ PASS |
| BILL-91 | Schedule — interval based (weeks) | P0 | Set "7 weeks" → appointment created | ✅ PASS |
| BILL-92 | Schedule — interval based (days) | P0 | Set "3 days" → appointment created | ✅ PASS |
| BILL-93 | Schedule — interval based (months) | P0 | Set "1 month" → appointment created | ✅ PASS |
| BILL-94 | Schedule — specific date | P0 | Select specific date (e.g., 2026-06-20) → "Appointment time is outside working hours" error | Bug #51 ❌ |
| BILL-95 | Schedule — doctor required | P0 | Leave doctor empty → validation error | ✅ PASS |
| BILL-96 | Schedule — past date/interval | P1 | Past interval → blocked | ✅ PASS |
| BILL-97 | Schedule follow-up — success toast | P0 | Submit → success toast, follow-up appears in section | ✅ PASS |
5.2 Existing Follow-up
| # | Test Case | Priority | Expected | Status |
|---|---|---|---|---|
| BILL-100 | Follow-up — display | P0 | Shows scheduled date, doctor, notes | Pending |
| BILL-101 | Follow-up — already exists | P0 | Patient already has follow-up → shows existing, no form | Pending |
| BILL-102 | Cancel follow-up | P0 | Click cancel → confirmation dialog → follow-up removed | Pending |
| BILL-103 | Cancel follow-up — reason | P1 | Enter cancellation reason → saved | Pending |
SECTION 6: Package Association
| # | Test Case | Priority | Expected | Status |
|---|---|---|---|---|
| BILL-110 | Associate package — suggested | P1 | Based on services, suggested packages shown | Pending |
| BILL-111 | Associate package — modal | P1 | Click associate → package modal opens | Pending |
| BILL-112 | Select package → services added | P1 | Pick package → services auto-added from package | Pending |
SECTION 7: Edge Cases (Code Audit)
These were audited from frontend types + backend model validations rather than manual testing.
| # | Test Case | Priority | Finding | Status |
|---|---|---|---|---|
| BILL-120 | Large payment amount — no max | P2 | Backend Payment.amount only validates > 0, no max. Frontend has no input limit either | ⚠️ No cap |
| BILL-121 | Large service price — no max | P2 | Backend unit_price >= 0, no max limit. Can enter ₹9999999 | ⚠️ No cap |
| BILL-122 | Special chars in service name | P2 | Backend service_name max 255 chars, no character filter. Emojis/special chars pass | ⚠️ No filter |
| BILL-123 | Panel close with unsaved form data | P1 | Form state is local React state — lost on panel close. No warning | ⚠️ No warning |
| BILL-124 | Refresh — data from API | P1 | All data fetched from API on open — data persists across panel opens | ✅ Safe |
| BILL-125 | No data leak between patients | P1 | API calls include patient_facility_id in URL — properly scoped | ✅ Safe |
| BILL-126 | Rapid add/delete — race condition | P2 | No optimistic locking on services/payments. Two tabs could conflict | ⚠️ No lock |
SECTION 8: Billing — Role-Based Access
| # | Test Case | Priority | Expected | Status |
|---|---|---|---|---|
| BILL-130 | Admin — full billing access | P0 | Admin can add services, payments, generate bills | ✅ PASS |
| BILL-131 | Doctor — billing access | P0 | canManageBilling = true for practitioner → panel accessible | ✅ PASS |
| BILL-132 | Staff — no billing access | P0 | canManageBilling = false for staff → billing button hidden/disabled | ✅ PASS |
Test Summary
| Section | Test Cases | Tested | Passed | Failed |
|---|---|---|---|---|
| 1. Panel Open & Header | 6 | 6 | 6 | 0 |
| 2. Service Management | 12 | 12 | 12 | 0 |
| 3. Payment Management | 14 | 14 | 13 | 1 |
| 4. Bill Generation | 11 | 11 | 11 | 0 |
| 5. Follow-up / Next Visit | 10 | 10 | 9 | 1 |
| 6. Package Association | 3 | 3 | 3 | 0 |
| 7. Edge Cases | 6 | 6 | 2 | 0 |
| 8. Role-Based Access | 3 | 3 | 3 | 0 |
| Total | 65 | 65 | 59 | 2 |
Status: ✅ Complete Last Updated: 2026-06-17
Test Execution Order
- Section 1: Panel Open & Header (BILL-01 → BILL-06) — 6 tests
- Section 2: Service Management (BILL-10 → BILL-36) — 12 tests
- Section 3: Payment Management (BILL-40 → BILL-63) — 14 tests
- Section 4: Bill Generation (BILL-70 → BILL-85) — 11 tests
- Section 5: Follow-up (BILL-90 → BILL-103) — 12 tests
- Section 6: Packages (BILL-110 → BILL-112) — 3 tests
- Section 7: Edge Cases (BILL-120 → BILL-125) — 6 tests
- Section 8: Role-Based (BILL-130 → BILL-132) — 3 tests
Status: Pending Last Updated: 2026-06-17