# 09 – Expenses (company expenses, vendor expenses, payments, categories, vendors)

Tested in the QA company (company admin) · Pages: Add Expense, Expense List, Expense Paid List, Add Vendor Expense, Vendor Expense List, Expense Category, Vendor, Currency Rate

## Works fine

- All eight pages open.
- **Expense Category** and **Vendor** can be added from Master ("Expense Category added successfully", "Vendor added successfully"); empty saves show "This field is required" / "The Name field is required".
- **Add Expense** (invoice no., name, category, currency, amount, date, note, receipt PDF) saves ("Expense created successfully!"); the list shows it as *Unpaid*. **Edit** opens with every value filled in and saves ("Expense updated successfully!").
- **Add Vendor Expense** (with the vendor chosen) saves and appears in the Vendor Expense List.
- **Payment** (tick the expense → top *Payment* button): mode, reference, bank, date, currency; "Select at least one expense." if nothing is ticked. After "expense paid successfully." the expense moves to the **Expense Paid List** (both company and vendor expenses). *Expense Summary* and *Expense Statement* open as valid PDFs.

## Issues

| # | Sev | What the user experiences | Steps | Evidence |
|---|-----|---------------------------|-------|----------|
| E1 | **High** | **Paying an expense fails in a new company** – pop-up "An error occurred while fetching expense data." (the page crashes behind it). The payment window needs a saved exchange rate for the expense's currency; the Currency Rate page *shows* INR = 1 but nothing is saved until the user presses *Update* there, and nothing tells them. After saving the rate, payment works. | New company → Expense List → tick expense → Payment | `screens/exp_list_data.png` |
| E2 | Medium | **A new company cannot add an expense until a Category exists** (and a Vendor for vendor expenses) – the dropdown only says "Select Category" with no hint (same gap as CRM C1 / Carriers K1). | New company → Add Expense | – |
| E3 | Medium – *fixed locally, awaiting upload* | **The same expense invoice number can be saved twice** (EXP-QA-1 saved again, no warning). | Add Expense with an existing invoice no. | `screens/exp_after_dups.png` |
| E4 | Medium – *fixed locally, awaiting upload* | **A negative amount is accepted** (−50 saved as an expense). | Add Expense → amount -50 | `screens/exp_after_dups.png` |
| E5 | Low | **Expense payments are always for the full amount** – the payment amount boxes are locked, so a part payment is not possible. Please confirm this is intended. | Payment window | `screens/exp_pay_modal.png` |
| E6 | Low | **No confirmation after saving Currency Rate** (the page just reloads). | Master → Currency → Update | – |
| E7 | Low | Script errors on Add Expense, Add Vendor Expense, Expense Paid List, Category and Vendor pages (`classList` / `addEventListener` of null) and a missing script file on every page. | Open the pages, look at the console | – |

## Not tested (and why)

- Delete expense/vendor expense, filters and date ranges, cheque payments, charges / discount / tax inside the payment window, paying expenses in two currencies, expense receipts view, the Expense Report (Reports module), carrier-portal expenses.
- "My Data / All Data" for staff (needs a staff login in the QA company).

## Test data left in the QA company

- Master: Expense Category **QA Fuel**, Vendor **QA Vendor One**, Currency Rate **INR = 83** (per 1 USD), Bank **QA Bank**.
- **EX-26308** (EXP-QA-1, 3,000, Paid – wire) and vendor expense **EX-4353** (VEXP-QA-1, 1,800, Paid).
- **EX-61531** (EXP-QA-1 again, 10, Unpaid) and **EX-62501** (EXP-QA-NEG, −50, Unpaid) – created to test E3 / E4.
