Test Cases: Invoice Creation
Module: Billing & Invoicing - Invoice Creation
Backend Endpoint: POST /api/billing/invoices, POST /api/billing/admin/invoices
Frontend Page: frontend/pwa-app/src/pages/AdminInvoicesPage.tsx
Prerequisites
- User logged in with ADMIN or FINANCE_MANAGER role.
- At least one active member exists in the system.
- Test data from
00_MASTER_TEST_DATA.mdis seeded.
Test Data
| Field | Value |
|---|---|
| Creator | Ana Reyes (FINANCE_MANAGER) |
| Target Member | Maria Cruz (MEM-2024-0004) |
| Invoice Type | Manual Invoice |
| Line Item 1 | Annual Dues - PHP 15,000.00 |
| Line Item 2 | Late Fee - PHP 500.00 |
| Total | PHP 15,500.00 |
| Due Date | Current Month + 30 days |
Test Cases
TC-BIL-001: Create Manual Invoice Successfully
| Step | Action | Expected Result |
|---|---|---|
| 1 | Login as Ana Reyes (FINANCE_MANAGER). | Dashboard displayed. |
| 2 | Navigate to Admin > Invoices. | Invoice list page displayed. |
| 3 | Click "Create Invoice" button. | Invoice creation form opens. |
| 4 | Select member: Maria Cruz. | Member details auto-populated. |
| 5 | Add line item: "Annual Dues" - PHP 15,000.00. | Line item added to invoice. |
| 6 | Add line item: "Late Fee" - PHP 500.00. | Second line item added. Total shows PHP 15,500.00. |
| 7 | Set due date: Current Month + 30 days. | Due date field populated. |
| 8 | Click "Create Invoice". | API POST /api/billing/invoices called. |
| 9 | Verify API response. | Status 201 Created. Invoice number generated (format: INV-YYYY-XXXX). |
| 10 | Verify invoice list. | New invoice appears in list with status "PENDING". |
TC-BIL-002: Create Invoice with Multiple Line Items
| Step | Action | Expected Result |
|---|---|---|
| 1 | Open invoice creation form. | Form displayed. |
| 2 | Select member: Maria Cruz. | - |
| 3 | Add 5 different line items with varying amounts. | All items displayed with subtotals. |
| 4 | Verify total calculation. | Total equals sum of all line items. |
| 5 | Create invoice. | Invoice created with all 5 line items preserved. |
| 6 | View invoice details. | All line items displayed correctly. |
TC-BIL-003: Create Invoice - Validation Errors
| Step | Action | Expected Result |
|---|---|---|
| 1 | Open invoice creation form. | Form displayed. |
| 2 | Click "Create Invoice" without selecting member. | Validation error: "Member is required". |
| 3 | Select member but add no line items. | Validation error: "At least one line item required". |
| 4 | Add line item with amount 0 or negative. | Validation error: "Amount must be greater than 0". |
| 5 | Add line item with empty description. | Validation error: "Description is required". |
| 6 | Set due date in the past. | Warning displayed (may allow based on business rules). |
TC-BIL-004: Create Invoice - Permission Denied
| Step | Action | Expected Result |
|---|---|---|
| 1 | Login as Maria Cruz (MEMBER role). | Member dashboard displayed. |
| 2 | Attempt to navigate to Admin > Invoices. | Access denied or menu not visible. |
| 3 | Attempt direct API call POST /api/billing/invoices. | Status 403 Forbidden. |
TC-BIL-005: Create Invoice for Pending Member
| Step | Action | Expected Result |
|---|---|---|
| 1 | Login as FINANCE_MANAGER. | - |
| 2 | Open invoice creation form. | - |
| 3 | Search for Miguel Fernandez (PENDING_APPROVAL status). | Member found in search. |
| 4 | Attempt to create invoice. | System should warn or prevent (business rule dependent). |
TC-BIL-006: Create Invoice - Duplicate Prevention
| Step | Action | Expected Result |
|---|---|---|
| 1 | Create invoice for Maria Cruz - "Annual Dues 2024". | Invoice created successfully. |
| 2 | Attempt to create another invoice with same description for same period. | Warning displayed about potential duplicate. |
| 3 | Confirm to proceed if allowed. | Duplicate created (if business rules allow). |
TC-BIL-007: Create Invoice with Notes
| Step | Action | Expected Result |
|---|---|---|
| 1 | Open invoice creation form. | - |
| 2 | Fill required fields. | - |
| 3 | Add internal notes: "Follow up if not paid by due date". | Notes field accepts text. |
| 4 | Add customer-facing notes: "Thank you for your membership". | Notes field accepts text. |
| 5 | Create invoice. | Invoice created with both note types. |
| 6 | View invoice details. | Internal notes visible to admin only. Customer notes visible to member. |
API Test Cases
TC-BIL-API-001: POST /api/billing/invoices - Valid Request
Request:
{
"memberId": "MEM-2024-0004",
"dueDate": "2024-02-28",
"lines": [
{ "description": "Annual Dues 2024", "amount": 15000 },
{ "description": "Late Fee", "amount": 500 }
],
"notes": "Manual invoice for dues collection"
}
Expected Response: 201 Created
{
"id": "uuid",
"invoiceNumber": "RCME-DUES-XXXX",
"memberId": "MEM-2024-0004",
"total": 15500,
"status": "PENDING",
"dueDate": "2024-02-28",
"createdAt": "timestamp",
"createdBy": "treasurer@demo.membervu.com"
}
TC-BIL-API-002: POST /api/billing/invoices - Invalid Member
Request:
{
"memberId": "INVALID-ID",
"dueDate": "2024-02-28",
"lines": [{ "description": "Test", "amount": 100 }]
}
Expected Response: 404 Not Found or 400 Bad Request
{
"error": "MEMBER_NOT_FOUND",
"message": "Member not found"
}
TC-BIL-API-003: POST /api/billing/invoices - Unauthorized
Headers: No auth token or invalid token
Expected Response: 401 Unauthorized