Bakery POS - Phase 9 Deployment Instructions
=============================================

Phase 9 adds:
- Multi-outlet POS sales
- POS terminal management
- Cashier shift open/close and cash reconciliation
- Barcode/product search and quick product buttons
- Held carts
- Cash / Card / QR / Bank / Credit / Split payments
- FEFO finished-stock deduction with server-side stock locks
- Outlet-specific/default retail price resolution
- Separate revocable owner/manager discount-authorization QR
- 80mm bilingual receipt with bill-number barcode
- Audited receipt reprints
- Bill lookup, returns and controlled voids
- Credit customers, credit limits and credit collections

IMPORTANT DEPLOYMENT ORDER
--------------------------
1. Back up the current /public_html/bakery/ application folder.
2. Back up the engrgolk_bakery database in phpMyAdmin.
3. Select engrgolk_bakery in phpMyAdmin.
4. Import ONLY:

   /sql/011_phase9_pos.sql

   Import it once.

5. If you are already inside /public_html/bakery/, upload and extract:

   bakery_full_phase9_DIRECT_EXTRACT.zip

   Choose overwrite/replace existing files.

6. Confirm the application root still contains:
   /public_html/bakery/login.php
   /public_html/bakery/config/database.php
   /public_html/bakery/outlet/pos.php
   /public_html/bakery/outlet/shifts.php

7. Login normally.

DO NOT IMPORT ON THE EXISTING LIVE DATABASE
-------------------------------------------
- sql/001_master_schema.sql
- sql/002_seed_core.sql

Those files are synchronized for a future clean installation only.

DATABASE CREDENTIALS
--------------------
The complete Phase 9 package preserves the exact config/database.php file supplied in the user's Phase 8.1 ZIP.
Verify it after extraction, but do not publish/share its credentials.

FIRST POS TEST
--------------
A. Administration -> Discount Authorization QR
   - Create a test authorization QR as Super Admin/Admin.

B. Outlet -> POS Terminals
   - Confirm Main Outlet and existing outlets have an active terminal.
   - New outlets created after Phase 9 automatically receive a default POS terminal.

C. Outlet -> Cashier Shifts
   - Open a test shift with opening cash.

D. Outlet -> POS Sale
   - Scan/select one product.
   - Complete a CASH sale.
   - Confirm receipt prints and bill barcode appears.
   - Confirm finished stock decreased and SALE appears in stock history.

E. Test a split payment
   - Example: CASH + CARD.

F. Test cashier discount authorization
   - Login as a Cashier without sale.discount.
   - Add a discount.
   - Scan the separate owner/manager QR.
   - Complete the sale.

G. Test return
   - Outlet -> Returns.
   - Scan/enter the bill number.
   - Return a sellable quantity.
   - Confirm stock is restored to the original batch.

H. Test credit
   - Outlet -> Credit Customers -> create customer + credit limit.
   - Complete a Credit or Split Credit sale.
   - Outlet -> Credit Collections -> record a partial payment.

CACHE
-----
Phase 9 uses a new asset version and service-worker cache name.
A normal reopen/reload should fetch the new interface.
If a tab was already open during deployment, close all Bakery POS tabs and reopen once.

ONLINE-FIRST POS
----------------
Phase 9 checkout remains online-first so server-side stock locks, FEFO allocation, prices and credit limits remain authoritative.
The existing PWA/offline infrastructure is preserved for future controlled offline transaction synchronization.

CODE FORMAT
-----------
All Phase 9 new/modified PHP, JavaScript, CSS and SQL files are formatted vertically with normal indentation and readable line breaks.
