# Full test flow – one shipment from start to end (all roles)

Start: the company admin, a staff user, a customer and a carrier are already registered and can log in.
Use ONE test order from start to finish. For every problem send: page, what you did, what you expected, what happened, screenshot.
**[upload]** = only works after the latest local fixes are uploaded.

---
## 1. Company Admin — Setup
*Creates master data, currency rates, staff roles and users; checks the new customer and carrier registrations.*
1. Log in as the company admin → **Master Manage**.
2. Add **Equipment** (2), **Mode Of Transport**, **Unit**, **Tax**, **Discount**, **Terms & Conditions**.
3. Add **Customer Type** and **Carrier Type**; check/add **Lead Source, Lead Status, Followup Status, Quote Status, Tracing Status**.
4. Set the **ID series** (Order, Quote, Lead, Customer, Carrier): prefix and start number.
5. **Currency**: set the rate for your currency → Update (needed before paying an expense).
6. Add **Expense Category**, **Vendor**, **Bank Master** (one account number cannot be used twice inside a company).
7. **HRM → Role List → Add Role**: "Sales" with some permissions, and for Users / Carriers / Expenses choose **My Data**; a second role "Manager" with **All Data**. Tick **notification view** in one role **[upload]**.
8. **HRM → Add User**: a staff user with the "Sales" role (password min 8; an email already used must show an error). Check **User List**.
9. **CRM → Customer** and **Carrier → Carrier List**: the registered customer and carrier appear with the right email and phone.
10. **Carrier List → Edit** the carrier: set **Liability and Cargo Insurance End Dates in the FUTURE** (otherwise dispatch says "Insurance is Expired"). Save, reopen – documents are still there.
- Check: records show in lists, edit/delete work, duplicates are refused where they should be.

## 2. Staff, Customer and Carrier — first look and own set-up
1. **Staff:** log in → only the menus of the role appear.
2. **Customer:** log in → **Setting → General Setting**: the **Customer Credit** section is view only; **Customer Type** shows the fixed types plus the company's **[upload]**. Dashboard shows only your data.
3. **Carrier:** log in → **Setting → General Setting** (Approved / Rating / Internal notes should not be editable by the carrier – tell me if they are).
4. **Carrier → Driver Manage → Add Driver**: an empty form must be refused **[upload]**; add a driver with name, phone, vehicle and choose Country / State / City with the search boxes **[upload]**. Check **Driver List**.
5. **Carrier → Truck Manage → Add Truck**; check **Truck List**.

## 3. Admin / Staff — Lead and customer
1. **CRM → Add Lead**: name, company, email, phone, address → Save. Also try **Bulk Upload Leads** with a small file.
2. Open the lead → add a **Follow Up** (status, date, note). Check **Follow Up Leads**, **Missed Followups**, **Quotation Leads**.
3. **CRM → Customer → Add** (or convert the lead): customer type, credit section, primary address; tick **"same as primary address"** for mailing – red errors disappear and state/city fill **[upload]**.
4. **Customer List → Assign** the customer to the staff user (needed for the "My Data" test).

## 4. Customer — Requests a shipment
1. Log in as the customer → **Quotation → Create RFQ** → fill the shipment details → Save. **RFQ List** shows it (Pending).
2. **Order → Create RFQ Order** → fill → Save. **RFQ Order List** shows it (Pending).

## 5. Admin — Creates the quotation
1. **Quotation → RFQ List** → open the request → **Update Quote**: set the price, tick **Admin Approved**, save (a request that is not approved goes back to the RFQ List, an approved one to the Quotation List) **[upload]**.
2. **Quotation → Quotation List**: change the status badge to **Approved**. Try **Quote PDF** and **Send Email**.
3. **Quotation → Approved Quotation List** → Action → **Send to Load Board**.
4. **Load Board → Load Board List → Bid Limit**: it is the **maximum NUMBER of bids**; save, reopen – the saved value shows **[upload]**. Set the days and **Publish**.
5. Also test **Quotation → Create Quotation** (direct, without a customer request): customer, FTL/LTL, equipment, pickup + delivery, shipping details, charges/discount/tax, final price.
6. **Customer:** **Quotation → RFQ List / Approved Quotation List** shows the price → approve it.

## 6. Carrier — Quotes on the load
1. Log in as the carrier → **Load Board → Load Board List**: the published load appears (only this company's).
2. **Add Quote**: try empty (refused), a bid above the allowed amount (the message must NOT show the customer's price **[upload]**), a valid bid, and a second bid on the same load (refused).
3. **Load Board → All Bid** shows your bid.

## 7. Admin — Approves the bid and creates the order
1. **Load Board → Carrier Bids** → open the bid → **Approve**. **Approved Bids** lists it.
2. **Carrier:** you get a "Bid Approved" notification; **Closed Bids** shows it.
3. **Load Board List → Action → Create Order** (the customer must be a real Customer) – or **Order → Create Order**. Check it is prefilled → Save.
4. **Order → Order List** and **Pending Orders** show the order. **Customer → Order → Order List** shows it too.

## 8. Admin — Dispatches to the carrier
1. **Order → Order List → Action → Dispatch**: choose the carrier you approved, equipment, carrier rate (the bid amount), truck unit, trailer unit, PAPS/PARS, driver. Picking the carrier fills **Contact**, picking the driver fills the phone.
2. Save. **Order → Dispatch List** shows it.
3. **Carrier:** **Order → Order List** shows the order; **Assign Driver** shows driver, phone, truck, trailer, PAPS/PARS from the dispatch **[upload]** → change → Assign. **Driver Manage → Driver Order List** shows it.
4. **Carrier:** no customer name / email / phone / customer PO / customer price anywhere (Order List, panels, Order Report, Invoice Report) **[upload]**; Order PDF and customer invoice PDF say "not found"; **Rate Confirmation** and **BOL** open (no customer PO on the BOL).
5. **Customer:** **Order → Dispatched Orders** shows the order and no carrier details.

## 9. Carrier — Delivers the shipment
1. **Order → Tracing → Update Tracing** on the order: try empty (must say required).
2. Choose **Pickup** + Country / State / City + a note → Update. Reopen the popup: the last saved values show **[upload]**.
3. Repeat with **In Route**, then **Delivered** + **Proof Of Delivery** (a real PDF under 5 MB). **Order In Transit** and **Delivered Orders** (with View POD) follow.
4. Tick **Send Email** on one update: the **customer gets one email** (admin in copy); no tick = no email **[upload]**.
5. **Admin:** **Order → Tracing** shows the same updates; **Delivered Orders** shows the POD. If the admin ticks Send Email: the customer gets the email and the carrier a separate copy **[upload]**.
6. **Customer:** **Order → Delivered Orders**, tracing history, POD; the "Order delivered" notification.

## 10. Admin — Customer invoice and payment (Customer pays the company)
1. **Invoice → Customer Invoice (A/R) → Invoice Not Sent**: create / preview the invoice → tick it and **Send Invoice** (moves to Receivable). The email must reach the customer.
2. **Customer:** **Invoice → Unpaid Invoice List** shows the invoice; open the PDF; amounts match.
3. **Admin:** **Receive Payment** – a part payment, then the rest. An amount **bigger than the invoice must be refused** **[upload]**. Status goes Partially Paid → Paid.
4. **Customer:** **Invoice → Paid Invoice Orders** and **Order → Paid Orders** show it.
5. **Admin:** check the **Paid** list, receipt and **Receivable Age**.

## 11. Admin — Carrier invoice and payment (Company pays the carrier)
1. **Invoice → Carrier Invoice (A/P) → Invoice not received** (delivered with POD): **Receive Invoice** (carrier invoice no. and amount).
2. **Carrier:** **Invoice & Payments → Unpaid Invoice List** shows your invoice.
3. **Admin:** **Make Payment** (part, then full; over-payment refused). Check the **Paid** list and **Payable Age**.
4. **Carrier:** **Paid Invoice Orders**, **Order → Paid Orders** and **Report → Invoice Report** agree.

## 12. Admin / Staff — Expenses
1. **Expenses → Add Expense** (category, amount, invoice no.): a negative amount and a duplicate invoice number must be refused **[upload]**.
2. **Add Vendor Expense**, **Expense List**, **Vendor Expense List**.
3. **Paid Expenses** → make the payment (needs the Currency rate from step 1).

## 13. Admin — Reports (and the portal reports)
1. **Reports:** Order, Invoice, Quotation, Carrier Dispatch, Expense, Commission, Profitability, Accounts Receivable / Payable, All Revenue, Profit & Loss, Bids, Tax – totals must match your test order; try the filters and dates.
2. **Customer:** Order Report and Invoice Report. **Carrier:** **Report →** Order, Bids, Invoice, Driver Report. Each shows only its own data; the carrier sees no customer details.

## 14. Isolation check (the most important one)
1. **Staff on My Data:** dashboard, every list, every filter drop-down, grouped payments and Closed Bids show ONLY the customers assigned to the staff user; an order the admin created for his customer appears for him.
2. **A brand-new customer / carrier with no data:** dashboard and every list are empty; nothing from other companies.
3. **Carrier:** Delivered Orders and Load Board show only your companies. **Customer:** no carrier details.
4. Type another company's order / invoice id in the address bar → "not found".

## 15. Notifications, Mass Email and the rest
1. **Admin → Notifications:** all company notifications with filters (For, Status, Type, dates, search) and normal Previous / Next links **[upload]**. **Staff** with the permission sees it; without it "forbidden" **[upload]**.
2. **The bell:** after reading the last notification the list shows "No new notifications" and the dot hides. Admin pages do NOT refresh the bell by themselves (on purpose). **Customer / Carrier:** the bell updates by its own background check; the page never reloads.
3. **Admin → Mass Email** to a group that has only your own address: the campaign becomes "completed" and the email arrives.
4. **Admin → Order List → Cancel** an order, and from **Pending Orders**; **Repeat Order**; **Claim/Dispute Orders**. **Customer:** the cancelled order shows as cancelled.
5. **Settings:** Admin **General Setting** (logo; foreign phone numbers are allowed); **Admin Profile**: an empty username must be refused **[upload]**. **Customer / Carrier:** Profile and **Agreement** pages open.

## 16. After each upload
Run `route:clear` and `view:clear` (and the migration for the notification permission), then repeat only the steps marked **[upload]**.
