CUTPRICE CONNECTED — INSTALL AND CHECK

This is a prepared integration package. It has NOT been executed on PHP/MySQL
in the preparation environment. Complete the local checks below before using it
for real payments. Your running installations have not been changed.

WHAT IS INCLUDED
- One combined database: database/01_COMBINED_DATABASE.sql.
- Complete ERP application in cutprice/.
- Transfer and grocery application in cutprice/transfers/.
- One shared connection file: cutprice/connection.php.
- Connected transfer payouts and grocery payment approvals.
- A rollback-only integration test for a disposable test database.

INSTALL ON LARAGON / XAMPP
1. Keep backups of your current application folders and both databases.
2. Create a NEW EMPTY database called cutprice_connected in phpMyAdmin.
   Choose utf8mb4. Import database/01_COMBINED_DATABASE.sql ONCE into it.
   Do not import it on top of an existing database. Do not import the two old
   SQL files afterwards. This is a snapshot, not an upgrade script.
3. Copy only the cutprice folder into:
   Laragon: C:\laragon\www\cutprice
   XAMPP:   C:\xampp\htdocs\cutprice
4. Edit cutprice/connection.php. Defaults are localhost, cutprice_connected,
   root, and an empty password. Both applications read this same file.
5. Use PHP 8.1 or later with PDO MySQL and mysqli (the existing ERP uses PHP
   features that require 8.1). Start Apache and MySQL.
6. ERP login: http://localhost/cutprice/login.php
   Connected hub: http://localhost/cutprice/cutprice_connected.php
   Grocery payments: http://localhost/cutprice/grocery_payments.php
   Transfer staff login: http://localhost/cutprice/transfers/login.php
   Customer portal: http://localhost/cutprice/transfers/customer_dashboard.php

LOGINS
Both original admin accounts and their passwords are preserved. Use the ERP
admin password for ERP pages, and the transfer-system admin password for
transfer staff pages. They both use the username admin but have different
password hashes, so they were not merged or reset. Sessions are separated;
a transfer login does not grant ERP access. Financial verification and payouts
now require the appropriate ERP login. Cashiers need POS permission.

CHECK BEFORE REAL USE
A. Make another EMPTY database named cutprice_connected_test and import the
   combined SQL into it. The test must not run against your working database.
B. From the package directory, use a terminal with PHP on its PATH:
   php validation/test_connection.php cutprice_connected_test
   On XAMPP you can use C:\xampp\php\php.exe instead of php.
   The test checks repeat payout prevention, bank-reference reuse, partial/full
   grocery payments, repeat approvals, and cashier cash totals. Fixture data
   is rolled back. Schema checks may add missing compatibility columns only
   within this disposable test database. A successful run ends with:
   All checks passed; fixture records rolled back.
C. Also open the pages in a browser: log in to both applications, open an ERP
   cashier shift, submit and verify a test transfer, then make its payout.
   Confirm the cashbook and shift reflect it once. Test a grocery invoice,
   payment and approval; verify the original customer order becomes paid.
D. Confirm original usernames work with your known passwords. Passwords were
   not reset, and were not tested against plaintext passwords.

WORKFLOW
Money transfers:
- Customers submit deposits through the transfer portal.
- Admin/Manager checks the bank proof and verifies in the connected ERP hub.
- Verification records SA bank money in the cashbook as Bank Transfer, not
  physical till cash. A normalized bank reference may be claimed only once.
- Cashier opens a shift and pays the recipient in ZAR or USD from the hub.
- The payout records one cash-out, one shift expense, and a permanent source
  link. The saved payout entitlement is respected. Repeating it is blocked.
- USD conversions use the ERP ZAR-per-USD setting and save the rate used.
- Connected payout expenses and cashbook entries cannot be deleted using the
  ordinary expense/cashbook delete buttons.

Groceries:
- Create the invoice in Transfer Staff > Grocery Orders.
- It appears in ERP > Grocery Payments immediately, using the same database.
- Select that invoice to record a payment. The first payment fixes its exchange
  rate. Only one ERP order is created for each original order.
- Customer cash received at the till requires an open shift and is included
  in the drawer total immediately, even while approval is pending.
- SA bank deposits do not increase physical till cash.
- Admin/Manager approval posts the cashbook and updates the original order
  when fully paid. Partial payments do not mark the order paid.
- Rejected bank references remain reserved for review. Cash receipts cannot
  be rejected without a reconciled refund; an automated refund/reversal flow
  is not included. Do not delete linked records to correct a payment.
- Cash from Till on the old grocery form meant money received. The replacement
  labels this explicitly as Customer cash received at till. Remittance cash
  paid out uses the separate transfer payout workflow.

NAMECHEAP
After local checks pass, create a NEW cPanel database and user, grant that user
access, and import the combined SQL into the empty database. Upload only the
cutprice folder. Set the exact cPanel-prefixed database/user/password in
cutprice/connection.php. Both sections must run on this same database server.
Do not upload database/, validation/, or this instruction file into the public
website. You can rename the web folder; its internal links are relative.

DATA AND DUPLICATES
- Source (3): 12 tables, 14 rows.
- Source (4): 102 tables, 85 rows.
- All 99 supplied rows are preserved field-for-field.
- No exact duplicate rows (excluding numeric id) were found, so none were
  deleted. Matching admin usernames were not treated as proof of one identity.
- Transfer tables use the cp_ prefix to resolve conflicting schemas. The
  original table IDs and foreign-key relationships are retained.
- Six small integration tables provide unique source links, bank reference
  claims, submission IDs, and till records. Total: 94 tables.
- The supplied ERP export contains no product or sale rows. Those were already
  absent from the uploaded SQL; this package does not invent or recover them.
- Obsolete bundled SQL snapshots, launch/install scripts and exposed transfer
  test/reset pages were removed from the deployable copy to avoid accidental
  reimport or reset. Vendor documentation remains.

LIMITS
This connects both applications within one MySQL database. Separate online and
local database servers are not automatically kept in sync by this integration.
For offline shop use, run both parts on one Laragon/XAMPP server; LAN tills
must use that same server. Disconnected payout approval is not supported.
Public queued requests keep their operation ID when retried. Private staff
pages are no longer cached by the transfer service worker. Existing offline
queues should be completed on the old installation before changing its URL.
Automatic email-based financial approval is replaced by manual ERP approval
so it cannot bypass the linked payment ledger. All unrelated ERP modules are
carried over from the provided application ZIP and have not been re-tested.

UPDATE: Econet Container and Workshop removed. See MODULE_REMOVAL.txt.
