# Deploy the Chon Stay Platform on Namecheap

Exact steps, in order. Everything in Step 0 is already done, so you
start at Step 1. You need your own cPanel, because cPanel cannot be
reached from here. Nothing in this guide spends money or creates a new
account.

## v13.27 upgrade, Nov 23, 2026. Read this first.

This package (chon-pms-namecheap-v13-27.zip) is v13.26 plus a
domain migration, approved by the owner Nov 23, 2026.

THE MOVE: the PMS moves from https://pms.chonstay.24kgoals.com
to https://pms.chonstay.com, and the hotel website moves from
https://chonstay.24kgoals.com to https://chonstay.com. The
server folder moves too: the new document root is
/home/certivgm/pms.chonstay.com, a fresh folder with no
24kgoals.com in the path. The old folder stays in place until
the move is verified, then it is deleted.

WHAT CHANGED, and nothing else:
1. The guest check-in link base is now
   https://pms.chonstay.com/checkin/, and the public booking
   URL is now https://pms.chonstay.com/book, so new check-in
   links and booking confirmations point at the new domain.
2. The iCal feed event UID domain is now @chonstay.com.
3. The housekeeping inspection alert and completion emails now
   link to https://pms.chonstay.com.
4. The CHON logo in the PMS header and on the login page now
   links to the hotel website at https://chonstay.com.
5. The read-only API document (openapi.json) now lists
   https://pms.chonstay.com as its server.
6. The frontend file is renamed to app-v13-27.js so the live
   version is unambiguous.

No behaviour, role, rate, or data changes. No database change.
No phpMyAdmin step. Bookings, users, rooms, connectors, and
ledger entries are untouched, and check-in tokens already
issued stay valid on the new domain.

The five cPanel cron jobs call the PMS by its old domain.
Update their URLs to https://pms.chonstay.com so the
scheduled sync, night audit, reconciliation, automation, and
report email keep working on the new domain.

Upgrade steps: create the pms.chonstay.com domain in cPanel
Domains with document root /home/certivgm/pms.chonstay.com.
Upload the zip there, extract, confirm files 644 and folders
755. Copy the uploads folder from the old folder
/home/certivgm/pms.chonstay.24kgoals.com into the new one;
it holds the receipt photos and ID captures. In Setup Node.js
App, edit the app: Application root to the new folder,
Application URL to pms.chonstay.com, then Run NPM Install and
Restart. After Restart, open https://pms.chonstay.com/ and
sign in as chonadmin. Click the CHON logo in the header and
check the hotel website opens at https://chonstay.com in a
new tab.

## v13.26 upgrade, Nov 21, 2026. Read this first.

This package (chon-pms-namecheap-v13-26.zip) is v13.25 plus a
balcony data correction, confirmed by the owner Nov 21, 2026.

THE FACTS: only Blue (floor 7) has a balcony. Vivid, Euphoria,
Dreamscape, Still, and Dune have an indoor sitting room next to
the window view, NOT a balcony. Sanctuary (floor 1) has no
balcony, no view, and no sitting room by a window view.

THE PROBLEM: the PMS seeded all six non-Sanctuary rooms with
balcony 1, so the public booking engine showed "Balcony" on the
room cards of five rooms that have no balcony.

THE FIX: the seed data (server.js ROOM_SEED and schema.sql) now
marks only Blue with balcony 1, and a startup migration corrects
any database already seeded with the old values. The migration
is three plain UPDATEs, no ALTER, so it cannot take a metadata
lock; it runs on every startup and is a no-op once the data is
correct. No behaviour, role, or other data changes. No
phpMyAdmin step.

Upgrade steps: same as before. Upload the zip to
/home/certivgm/pms.chonstay.24kgoals.com, extract overwriting,
confirm files 644 and folders 755, Restart in Setup Node.js App.
No NPM Install needed. After Restart, the public booking engine
room cards should show "Balcony" only for Blue.

## v13.25 upgrade, Nov 19, 2026. Read this first.

This package (chon-pms-namecheap-v13-25.zip) is v13.24 plus one
rule change, approved by Chau Nov 19.

THE RULE: the owner and the manager can perform all tasks. The
self-inspection block from v13.22 is removed. An owner or
manager can now inspect a room they cleaned themselves. The
Inspect button shows for any finished task to the owner and the
manager. Housekeeping staff still cannot inspect (owner or
manager only).

This also clears the Blue task: after the upgrade, chonadmin can
click Inspect on it, which clears the task from the board and
sends the completion email.

Upgrade steps: same as before. Upload the zip to
/home/certivgm/pms.chonstay.24kgoals.com, extract overwriting,
confirm files 644 and folders 755, Restart in Setup Node.js App.
No NPM Install needed. No phpMyAdmin step.

## v13.24 upgrade, Nov 19, 2026. Read this first.

This package (chon-pms-namecheap-v13-24.zip) is v13.23 plus a
room reconciliation, approved by Chau Nov 19.

THE PROBLEM: v13.23 fixed the status for tasks finished after
the upgrade, but Blue was finished before it, when finishing a
task still set the room to Clean. So Blue showed Clean while its
cleaning was still waiting for inspection.

THE FIX: on every startup, any room with a finished but
uninspected task is set to Needs inspection. Out of order rooms
are left alone. This heals Blue automatically on Restart, and
heals any other room in the same state.

Upgrade steps: same as before. Upload the zip to
/home/certivgm/pms.chonstay.24kgoals.com, extract overwriting,
confirm files 644 and folders 755, Restart in Setup Node.js App.
No NPM Install needed. No phpMyAdmin step. After Restart, Blue
should show Needs inspection.

## v13.23 upgrade, Nov 19, 2026. Read this first.

This package (chon-pms-namecheap-v13-23.zip) is v13.22 plus the
room status fix, approved by Chau Nov 19.

THE PROBLEM: a room showed Clean while its cleaning was still
waiting for a manager to inspect. Finishing a task set the room
to Clean immediately, before inspection.

THE FIX: the room statuses now follow the workflow exactly.
Needs cleaning, Cleaning, Needs inspection, Clean, Out of
order. Finishing a task sets the room to Needs inspection. Only
when a manager inspects and approves it does the room become
Clean. "Inspected" is gone as a room status (it stays as a task
status, for the finished task record).

DATABASE: the rooms.housekeeping_status ENUM is reshaped
automatically at startup. Any rooms currently marked Inspected
are moved to Clean first. No phpMyAdmin step.

Upgrade steps: same as before. Upload the zip to
/home/certivgm/pms.chonstay.24kgoals.com, extract overwriting,
confirm files 644 and folders 755, Restart in Setup Node.js App.
No NPM Install needed.

## v13.22 upgrade, Nov 19, 2026. Read this first.

This package (chon-pms-namecheap-v13-22.zip) is v13.21 plus the
housekeeping workflow fix, approved by Chau Nov 19.

THE WORKFLOW, corrected: housekeeping claims a cleaning and
finishes it (checklist plus photo). The manager is then alerted
by email that the room is ready for inspection. A manager
inspects it. Once inspected, the room is deemed cleaned, the
completion email goes to admin@chonstay.com, and the task
disappears from the board.

WHAT CHANGED:
1. INSPECTED TASKS DISAPPEAR: an inspected task no longer shows
in the Housekeeping tasks list, so the board only shows work
still to do. The task record stays in the database and the
audit log. Done tasks (awaiting inspection) still show.
2. NO SELF-INSPECTION: the person who cleaned a room cannot
inspect their own work, even if they are the owner. The server
rejects it, and the Inspect button is hidden for them, with a
note that another manager must inspect. Housekeeping staff
already could not inspect (owner or manager only); this closes
the gap for an owner or manager who did the cleaning.
3. EMAIL MOVED: the "room cleaned" email now goes out only
after inspection, so it means inspected and approved, not just
finished. It names who cleaned and who inspected. Finishing a
task now sends a "ready for inspection" alert email instead.

Upgrade steps: same as before. Upload the zip to
/home/certivgm/pms.chonstay.24kgoals.com, extract overwriting,
confirm files 644 and folders 755, Restart in Setup Node.js App.
No NPM Install needed. No phpMyAdmin step.

## v13.21 upgrade, Nov 19, 2026. Read this first.

This package (chon-pms-namecheap-v13-21.zip) is v13.20 plus two
housekeeping changes, approved by Chau Nov 19.

1. CLEANING EMAIL: when a room cleaning is finished (checklist
complete, photo attached), the PMS sends an email to
admin@chonstay.com with the room name, task kind, who finished
it, when (Vietnam time), the full checklist, and a note that the
photo is attached to the task in the PMS. The mailer sends text
only, so the photo itself is not in the email. A failed send is
logged in the audit log but never blocks the task completion.

2. PHOTO PURGE: cleaning photos older than 30 days are purged
automatically. The purge runs with the scheduled night audit
(03:00 Vietnam time daily), so no extra cron job is needed.
Only the photo is cleared; the task, its checklist, and who
finished it stay. Defect photos are NOT purged, a defect may
stay open for months and the photo is the evidence. Each purge
is logged in the audit log with the count.

Upgrade steps: same as before. Upload the zip to
/home/certivgm/pms.chonstay.24kgoals.com, extract overwriting,
confirm files 644 and folders 755, Restart in Setup Node.js App.
No NPM Install needed. No phpMyAdmin step.

## v13.20 upgrade, Nov 19, 2026. Read this first.

This package (chon-pms-namecheap-v13-20.zip) is v13.19 plus the
housekeeping cleaning checklist, approved by Chau Nov 19.

WHAT IT DOES: every cleaning task now carries a checklist, one
item per cleaning step, in English and Vietnamese. Turnover has
10 items (bed, bathroom, towels, amenities, fridge, floors,
surfaces, bin, air conditioning, lights and TV). Deep clean has
the same 10 plus 5 more (windows, curtains, mattress, grout,
vents). Inspection has 5 items (ready for guest, turnover
verified, no defects, photo taken, linen correct).

A task cannot be finished until every checklist item is ticked
AND a photo is attached. The Finish button stays disabled until
both are done, and the server enforces the same rule, so a task
finished through the API is held to the same standard. Finished
tasks show their completed checklist, read-only, so a manager
inspecting the room can see exactly what was done.

DATABASE: a new checklist_json column on housekeeping_tasks,
added automatically at startup on the first run. Existing tasks
get an empty checklist, which the server fills from the template
for their kind when read. No phpMyAdmin step.

Upgrade steps: same as before. Upload the zip to
/home/certivgm/pms.chonstay.24kgoals.com, extract overwriting,
confirm files 644 and folders 755, Restart in Setup Node.js App.
No NPM Install needed.

## v13.19 upgrade, Nov 19, 2026. Read this first.

This package (chon-pms-namecheap-v13-19.zip) is v13.18 plus ONE
fix: the Beds24 sync now pulls cancelled bookings too.

THE BUG: the sync called GET /bookings?propertyId=367148 with no
status parameter. Beds24 API V2 defaults to confirmed, request,
new, black, inquiry and EXCLUDES cancelled bookings unless asked
explicitly. After both test bookings were cancelled in Beds24,
Sync now pulled 0, created 0, updated 0, and the Test Guest
booking stayed Confirmed in the PMS.

THE FIX: one line in server.js. The API call now passes all six
statuses: status=confirmed&status=request&status=new&status=black
&status=inquiry&status=cancelled. The sync already handles a
cancelled booking correctly when it receives one (marks the PMS
booking cancelled, removes it from the calendar). After this
upgrade, run Sync now: it should pull the Test Guest cancellation
(1 updated) and the booking should show as Cancelled.

Upgrade steps: same as before. Upload the zip to
/home/certivgm/pms.chonstay.24kgoals.com, extract overwriting,
confirm files 644 and folders 755, Restart in Setup Node.js App.
No NPM Install needed. No phpMyAdmin step.

## v13.18 upgrade, Nov 19, 2026. Read this first.

This package (chon-pms-namecheap-v13-18.zip) is v13.17 plus ONE
fix, the root cause of the Nov 19 sign-in hang. Nothing else
changed.

THE BUG: v13.10 changed the frontend normRole() to check
USER_ROLES.indexOf(role), but USER_ROLES was never defined in
the frontend JavaScript. Every normRole() call threw
ReferenceError: USER_ROLES is not defined. Any signed-in user
loading the page hit this in render(), which never completed, so
the page stuck on Loading forever. A fresh browser showed the
login form because that path does not call normRole. The API
worked because curl never runs the frontend JavaScript. That is
why v13.9 worked and every version from v13.10 through v13.17
hung, and why all the server-side theories (sessions lock, ENUM,
pool, migration) were wrong.

THE FIX: one line in public/app-v13-18.js, before normRole:
const USER_ROLES = ["owner", "manager", "frontdesk",
"housekeeping", "readonly"];
Verified in node: normRole returns the right role for all 5 roles,
maps admin to owner and staff to frontdesk, and falls back to
frontdesk for empty, unknown, null, or undefined.

Roles were already set by hand in phpMyAdmin for v13.17
(chonadmin owner, chonmgr manager, chondesk/chonstaff frontdesk,
chonkeep housekeeping). No phpMyAdmin step needed for this
upgrade.

Upgrade steps: same as before. Upload the zip to
/home/certivgm/pms.chonstay.24kgoals.com, extract overwriting,
confirm files 644 and folders 755, Restart in Setup Node.js App.
No NPM Install needed.

## v13.17 upgrade, Nov 19, 2026. Read this first.

This package (chon-pms-namecheap-v13-17.zip) is the v13.16 rebuild
WITHOUT the role migration. The migrateUserRoles function is
DELETED from server.js. There is no ALTER TABLE and no UPDATE on
the users table anywhere in the code. The 5-role system (Owner,
Manager, Front Desk, Housekeeping, Read-only), the role change UI,
the pool timeouts, the once-per-process table checks, the browser
timeouts, and the v13.4 database sessions are all included.

BEFORE uploading, set the roles by hand in phpMyAdmin, on the
certivgm_chonpms database, SQL tab. Run these two statements (the
role column is already VARCHAR, so the new values store fine):

UPDATE users SET role = 'owner' WHERE username = 'chonadmin';
UPDATE users SET role = 'manager' WHERE username = 'chonmgr';
UPDATE users SET role = 'frontdesk' WHERE username IN ('chondesk', 'chonstaff');
UPDATE users SET role = 'housekeeping' WHERE username = 'chonkeep';

If a user still holds admin or staff, the code treats admin as
Owner and staff as Front Desk (normalizeRole), so nothing breaks.

Upgrade steps: same as before. Upload the zip to
/home/certivgm/pms.chonstay.24kgoals.com, extract overwriting,
confirm files 644 and folders 755, Restart in Setup Node.js App.
No NPM Install needed.

## v13.16 upgrade, Nov 19, 2026. Read this first.

This package (chon-pms-namecheap-v13-16.zip) rebuilds the v13.8 to
v13.15 updates on top of the working v13.4, with the hang causes
removed. It includes the 5-role system (Owner, Manager, Front
Desk, Housekeeping, Read-only) and the role change UI, plus four
fixes learned from the Nov 19 sign-in outage:

1. Sign-in works EXACTLY as in v13.4: database sessions (random
   64-hex token, INSERT on login, DELETE on logout, JOIN lookup
   on every request). The stateless signed tokens from v13.13 to
   v13.15 are REMOVED. They were built on a diagnosis (the
   sessions table INSERT hangs) that the v13.4 revert disproved,
   since v13.4 signs in fine with the same table. A password
   change or reset signs the user out everywhere again, as before.
2. The role migration runs at server startup (boot), not on login.
   Login does no UPDATEs and no ALTER.
3. The database pool fails fast: acquireTimeout 15 seconds,
   connectTimeout 10 seconds. A hung query errors out instead of
   blocking the browser forever.
4. ALL ensure table functions run at most once per server process
   (connector, ledger, bank, money, ops, connect, phase 4), so no
   action re-runs CREATE TABLE and no metadata lock can hang a
   dashboard load.
5. The browser never spins forever: page load gives up the session
   check after 25 seconds and shows the login form, and sign-in
   shows a "taking too long, please try again" error after 30
   seconds, instead of a stuck Loading screen or Signing in button.

Note: this version re-applies the 5 roles on startup. The users
table currently holds admin/staff (after the v13.4 revert), and the
startup migration maps them back: chonadmin to Owner, chonmgr to
Manager, chondesk and chonstaff to Front Desk, chonkeep to
Housekeeping.

Upgrade steps: same as before. Upload the zip to
/home/certivgm/pms.chonstay.24kgoals.com, extract overwriting,
confirm files 644 and folders 755, Restart in Setup Node.js App.
No NPM Install needed. No phpMyAdmin step.

## v13.15 upgrade, Nov 19, 2026. Read this first.

This package (chon-pms-namecheap-v13-15.zip) supersedes v13.14.
Upload v13.15 instead. v13.14 fixed the Loading hang on a fresh
load, but after a successful sign-in the browser stuck on Loading
again (and on "Signing in..." before that). Cause: after sign-in,
the app loads the dashboard before it renders anything, and
getDashboard calls ensureOpsTables and ensureConnectTables, which
run CREATE TABLE IF NOT EXISTS on every call. Those statements
take a metadata lock, which hangs intermittently on this shared
hosting, so the dashboard never returns and the page never renders.

Fix: ensureOpsTables and ensureConnectTables now run at most once
per server process (a flag each, same pattern as the v13.11 role
migration). The first call after a restart creates any missing
tables; every later call returns immediately, with no CREATE TABLE
and no metadata lock. Nothing else changes.

Upgrade steps: same as v13.14. Upload the zip to
/home/certivgm/pms.chonstay.24kgoals.com, extract overwriting,
confirm files 644 and folders 755, Restart in Setup Node.js App.
No NPM Install needed. No phpMyAdmin step.

## v13.14 upgrade, Nov 19, 2026. Read this first.

This package (chon-pms-namecheap-v13-14.zip) supersedes v13.13.
Upload v13.14 instead. v13.13 fixed the sign-in INSERT hang, but
browsers still stuck on the Loading screen, including a fresh cloud
browser test that sat on Loading for 30+ seconds. Cause: v13.13
kept a legacy fallback in requireUser that looked up old 64-hex
tokens in the sessions table, and that SELECT hangs intermittently
on this hosting, same as the writes did.

Fix: the legacy lookup is removed. A token that is not a valid
stateless token is rejected immediately, with no sessions table
read at all. No code path in the app touches the sessions table
anymore (login signs, logout is client-side, requireUser reads
only the users table). Browsers holding a pre-v13.13 token simply
see the login form and sign in fresh, which works. The login
fallback that INSERTed a DB session when no connector key was set
is also removed: without CHON_CONNECTOR_KEY, login now returns a
clear error telling the admin to set the key and restart.

Upgrade steps: same as v13.13. Upload the zip to
/home/certivgm/pms.chonstay.24kgoals.com, extract overwriting,
confirm files 644 and folders 755, Restart in Setup Node.js App.
No NPM Install needed. No phpMyAdmin step.

## v13.13 upgrade, Nov 19, 2026. Read this first.

This package (chon-pms-namecheap-v13-13.zip) supersedes v13.12.
Upload v13.13 instead. It fixes the intermittent sign-in hang that
persisted through v13.12, a clean reinstall, app restarts, a CageFS
reset, and a clear database (SHOW PROCESSLIST showed no locks, CHECK
TABLE sessions reported OK).

Cause: sign-in and sign-out write to the sessions table (INSERT on
login, DELETE on logout), and those writes hang intermittently on
this shared hosting, sometimes for 20 seconds or more, while SELECTs
and users-table writes answer in 1 to 6 seconds. The hang comes and
goes, which is why tests pass one minute and fail the next.

Fix: stateless sessions. Sign-in no longer writes to the sessions
table at all. The token is a signed statement (user id plus 24h
expiry, HMAC-SHA256 keyed from CHON_CONNECTOR_KEY, the same key
that encrypts connector secrets). Login does SELECTs plus password
verify plus signing, no INSERT. Sign-out is client-side, no DELETE.
Role and active status are read from the users table on every
request, so role changes and deactivation take effect immediately.
One tradeoff: a password change does not sign out other sessions
until the token expires (at most 24h). Legacy 64-hex tokens stored
in browsers are still accepted (validated against the sessions
table), so nobody is signed out by the upgrade.

Upgrade steps: same as v13.12. Upload the zip to
/home/certivgm/pms.chonstay.24kgoals.com, extract overwriting,
confirm files 644 and folders 755, Restart in Setup Node.js App.
No NPM Install needed (node_modules is a cPanel symlink, leave it
alone). No phpMyAdmin step. The sessions table stays in the
database (legacy tokens may still be validated against it), but
nothing writes to it anymore.

## v13.12 upgrade, Nov 19, 2026. Read this first.

This package (chon-pms-namecheap-v13-12.zip) supersedes v13.11.
Upload v13.12 instead. It fixes the root cause of the blank role
and the sign-in hang Chau reported the same day.

Cause: the users.role column was created as ENUM('admin','staff')
in schema.sql, so it only accepts those two values. The v13.8 to
v13.11 role migrations tried to store owner, manager, frontdesk,
housekeeping and readonly, which the ENUM does not allow. The
database blanked the roles instead, which is why chonadmin showed
a blank role in v13.9 and the Owner tabs disappeared.

Fix in v13.12: migrateUserRoles now widens the column first with
ALTER TABLE users MODIFY role VARCHAR(32) NOT NULL DEFAULT
'staff', then runs the same by-username migration. The ALTER is
idempotent, safe to run on an already widened column. The
migration also repairs roles the earlier versions blanked to ''
(the v13.10 repair clause). schema.sql is updated to VARCHAR(32)
for future fresh installs.

IMPORTANT: upload v13.12 only AFTER the sessions table lock is
cleared (Namecheap support, SHOW PROCESSLIST). A new zip does not
clear a database lock. Once the lock is cleared, upload, extract,
Restart, then sign in as chonadmin. The chip should read "Logged
in as chonadmin, Owner" and the Users tab should show all five
roles correctly.

What v13.12 changes: server.js (one ALTER in migrateUserRoles)
and schema.sql (role column type). The frontend files are renamed
to v13-12 so the live version is unambiguous; their content is
identical to v13.11.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v13-12.zip, right click it, Extract,
   Extract Files, overwriting the files already there. Confirm files
   are 644 and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and sign in as chonadmin.
   The session chip should read "Logged in as chonadmin, Owner".
   Open Users and confirm the five roles: chonadmin Owner, chonmgr
   Manager, chondesk Front Desk, chonkeep Housekeeping, chonstaff
   Front Desk.

## v13.11 upgrade, Nov 19, 2026. Read this first if v13.4 is already live.

This package (chon-pms-namecheap-v13-11.zip) supersedes v13.10.
Upload v13.11 instead. It includes everything in v13.10 plus two
fixes for slow sign-ins Chau reported the same day: after uploading
v13.10 and restarting, the login page stuck on "Signing in..." and
API calls took 8 to 18 seconds.

Cause: the role migration ran on every login, adding 8 UPDATE
statements to every sign-in. When the database was responding
slowly, those extra queries made logins hang. The connection pool
was also small (5 connections), so a few slow queries could queue
up later requests.

Fixes in v13.11:
1. The migration now runs at most once per server process. The
   once-only flag moved inside migrateUserRoles, so every caller
   (login, seed, first authenticated request) shares the same
   guard. Logins after the first one skip the migration entirely.
2. The database connection pool grows from 5 to 10 connections,
   so a few slow queries cannot queue up the rest of the app.

What v13.11 changes: server.js only (migration guard,
connectionLimit). The frontend files are renamed to v13-11 so the
live version is unambiguous; their content is identical to v13-10.
No manual database change: the migration already ran in v13.10, so
v13.11's first run is a no-op.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v13-11.zip, right click it, Extract,
   Extract Files, overwriting the files already there. Confirm files
   are 644 and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and sign in as chonadmin.
   Sign-in should complete in a few seconds. The session chip
   should read "Logged in as chonadmin · Owner", and the tab bar
   should show Users, Connectors, and API Config. Your bookings,
   users, rooms, connectors, and ledger entries are untouched.
5. Optional: after extraction, delete the old public/app-v13-10.js
   and public/styles-v13-10.css from the server folder, and the old
   book-v13-10, checkin-v13-10, ocr-fields-v13-10, and
   ocr-loader-v13-10 files. They are not used any more (index.html
   now points at the v13-11 files). Leaving them does no harm, but
   deleting them avoids confusion.

## v13.10 upgrade, Nov 19, 2026. Read this first if v13.4 is already live.

This package (chon-pms-namecheap-v13-10.zip) supersedes v13.9. Upload
v13.10 instead. It includes everything in v13.9 plus two fixes for a
bug Chau reported the same day: after uploading v13.9, the session
chip read "Logged in as chonadmin" with a blank role, and the Users,
Connectors, and API Config tabs were missing from the tab bar.

Cause: chonadmin's stored role in the database was not admin, staff,
or any of the 5 new roles (it was NULL, empty, or an unexpected
value), so the v13.9 migration's WHERE clause (role IN admin, staff)
never matched it, and the frontend's normRole returned "" for it,
which blanked the chip and hid the Owner tabs.

Fixes in v13.10:
1. The migration's by-username update no longer requires the current
   role to be admin or staff. It now sets each of the 5 users to
   their approved role unless the role is already correct, so it
   repairs a NULL, empty, or unexpected stored role. Any other user
   left with a NULL or empty role becomes frontdesk.
2. The frontend normRole now falls back to frontdesk instead of ""
   for an unknown, empty, or missing role, so a bad stored role can
   never blank the session chip or hide the tabs again.

What v13.10 changes: server.js (hardened migrateUserRoles),
public/app-v13-10.js (normRole fallback). The frontend files are
renamed to v13-10 so the live version is unambiguous. No manual
database change: the migration runs on the first authenticated
request after restart.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v13-10.zip, right click it, Extract,
   Extract Files, overwriting the files already there. Confirm files
   are 644 and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and hard refresh. The session
   chip should read "Logged in as chonadmin · Owner", and the tab
   bar should show Users, Connectors, and API Config again. Open
   the Users tab and check the 5 users show their correct roles:
   chonadmin Owner, chonmgr Manager, chondesk Front Desk, chonkeep
   Housekeeping, chonstaff Front Desk. Your bookings, users, rooms,
   connectors, and ledger entries are untouched.
5. Optional: after extraction, delete the old public/app-v13-9.js
   and public/styles-v13-9.css from the server folder, and the old
   book-v13-9, checkin-v13-9, ocr-fields-v13-9, and ocr-loader-v13-9
   files. They are not used any more (index.html now points at the
   v13-10 files). Leaving them does no harm, but deleting them
   avoids confusion.

## v13.9 upgrade, Nov 19, 2026. Read this first if v13.4 is already live.

This package (chon-pms-namecheap-v13-9.zip) supersedes v13.8, which
was packaged and uploaded, but the role migration did not run for
users who were already logged in. Upload v13.9 instead. It includes
everything in v13.8 (5-role system, Sanctuary no extra bed, Ledger
phone stacking, tab bar scroll, skip unconfigured connectors, Scopes
checkbox fix) plus three fixes Chau reported from the Users tab:

1. The role migration now runs on the first authenticated request
   after the server restarts, not only on login. v13.8 ran it only
   on login and seed, so a user who was already logged in kept the
   old stored role (admin or staff) and the Users tab showed the
   wrong role: chonmgr showed as Owner instead of Manager, and
   chonkeep showed as Front Desk instead of Housekeeping. v13.9
   fixes this: after upload and restart, the next page load migrates
   all 5 users to the approved mapping (chonadmin Owner, chonmgr
   Manager, chondesk Front Desk, chonkeep Housekeeping, chonstaff
   Front Desk).
2. Each user card in the Users tab now has a role dropdown and a
   Change role button, so the Owner can change any user's role
   without deleting and recreating the account. You cannot change
   your own role, and you cannot demote the last active owner.
   Changing a role signs that user out, so the new role takes effect
   on their next login.
3. The Change my password button is removed from the top of every
   page. Password changes now happen only in the Users tab, where
   the Owner sets a new password for each user. Non-owner users who
   need a password change ask the Owner, or use Forgot password on
   the login page.

What v13.9 changes: server.js (migration on first request, setUserRole
action), public/app-v13-9.js (role dropdown and Change role button,
header button removed, Users note rewritten for the 5 roles). The
frontend files are renamed to v13-9 so the live version is
unambiguous. No manual database change: the migration runs on
startup.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v13-9.zip, right click it, Extract,
   Extract Files, overwriting the files already there. Confirm files
   are 644 and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and hard refresh. Log in as
   chonadmin. Open the Users tab and check the 5 users show their
   correct roles: chonadmin Owner, chonmgr Manager, chondesk Front
   Desk, chonkeep Housekeeping, chonstaff Front Desk. Check each
   user card has a role dropdown and a Change role button. Check the
   Change my password button is gone from the top of the page. Your
   bookings, users, rooms, connectors, and ledger entries are
   untouched.
5. Optional: after extraction, delete the old public/app-v13-8.js and
   public/styles-v13-8.css from the server folder, and the old
   book-v13-8, checkin-v13-8, ocr-fields-v13-8, and ocr-loader-v13-8
   files. They are not used any more (index.html now points at the
   v13-9 files). Leaving them does no harm, but deleting them avoids
   confusion.

## v13.8 upgrade, Nov 19, 2026. Read this first if v13.4 is already live.

This package (chon-pms-namecheap-v13-8.zip) supersedes v13.7, which
was packaged but not uploaded. Upload v13.8 instead of v13.7. It
includes everything in v13.7 (Sanctuary no extra bed, Ledger phone
stacking, tab bar scroll, skip unconfigured connectors, Scopes
checkbox fix) plus a new 5-role user system, approved by Chau Nov 19:

The old system had only 2 roles, Admin and Staff, which was too
coarse: a housekeeper could see the Ledger, and a front desk clerk
could change rates. v13.8 has 5 roles:

- Owner: everything, including users, connectors, API, rates,
  financials, and all operations.
- Manager: all operations, rates, reports, ledger, night audit,
  cashier. No user management, no connectors, no API.
- Front Desk: calendar, front desk, Today board, bookings, guests,
  groups, Ve Cafe POS, messaging. No ledger, reports, night audit,
  cashier, rates, users, or connectors.
- Housekeeping: housekeeping tab only. Can update room status and
  complete tasks. Cannot see bookings, guests, money, or rates.
- Read-only: view calendar, bookings, and reports. Cannot change
  anything.

The 5 existing users are migrated automatically on the next login
after upload, using the mapping Chau approved Nov 19: chonadmin
becomes Owner, chonmgr becomes Manager, chondesk becomes Front Desk,
chonkeep becomes Housekeeping, chonstaff becomes Front Desk. No
password changes, no accounts are deactivated. The new user form
offers all 5 roles, in English and Vietnamese.

What v13.8 changes: server.js (role helpers, permission checks,
migration), public/app-v13-8.js (tab visibility, view routing, role
labels, user form). The frontend files are renamed to v13-8 so the
live version is unambiguous. No manual database change: the
migration runs on startup.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v13-8.zip, right click it, Extract,
   Extract Files, overwriting the files already there. Confirm files
   are 644 and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and hard refresh. Log in as
   chonadmin. Open the Users tab and check the 5 users show their
   new roles: chonadmin Owner, chonmgr Manager, chondesk Front Desk,
   chonkeep Housekeeping, chonstaff Front Desk. Log in as chonkeep
   and check only the Housekeeping tab appears. Your bookings, users,
   rooms, connectors, and ledger entries are untouched.
5. Optional: after extraction, delete the old public/app-v13-7.js and
   public/styles-v13-7.css from the server folder, and the old
   book-v13-7, checkin-v13-7, ocr-fields-v13-7, and ocr-loader-v13-7
   files. They are not used any more (index.html now points at the
   v13-8 files). Leaving them does no harm, but deleting them avoids
   confusion.

## v13.7 upgrade, Nov 19, 2026. Read this first if v13.4 is already live.

This package (chon-pms-namecheap-v13-7.zip) supersedes v13.6, which
was packaged but not uploaded. Upload v13.7 instead of v13.6. It
includes everything in v13.6 (Ledger phone stacking, tab bar scroll,
skip unconfigured connectors, Scopes checkbox fix) plus one correction
Chau reported from the booking summary:

Sanctuary is the only room that cannot accommodate additional guests.
Max 2 people, no extra bed. The other 6 rooms offer an extra bed at
300,000 VND ($12) per person. v13.7 fixes the public booking engine
(/book) so Sanctuary no longer offers extra beds:

1. The availability API returns extraBedVnd 0 for Sanctuary and
   300,000 for the other 6 rooms.
2. The booking form hides the Extra beds selector entirely when the
   selected room has no extra bed (Sanctuary). It still shows for
   the other 6 rooms.
3. Selecting a room resets the extra bed count to 0, so switching
   from another room to Sanctuary cannot carry extra beds over.
4. The server-side quote forces extraBeds to 0 for Sanctuary even
   if a caller passes extraBeds for it in the API, so no booking
   can be priced with an extra bed for Sanctuary.

What v13.7 changes: server.js, public/book/book-v13-7.js, plus the
v13.6 changes. The frontend files are renamed to v13-7 so the live
version is unambiguous. No database change. The rooms already in
the database are untouched; the fix is keyed on the room slug
"sanctuary".

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v13-7.zip, right click it, Extract,
   Extract Files, overwriting the files already there. Confirm files
   are 644 and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/book and pick Sanctuary for
   any dates. Check the Extra beds selector does not appear. Pick
   another room and check it does appear. Your bookings, users,
   rooms, connectors, and ledger entries are untouched.
5. Optional: after extraction, delete the old public/app-v13-6.js and
   public/styles-v13-6.css from the server folder, and the old
   book-v13-6, checkin-v13-6, ocr-fields-v13-6, and ocr-loader-v13-6
   files. They are not used any more (index.html now points at the
   v13-7 files). Leaving them does no harm, but deleting them avoids
   confusion.

## v13.6 upgrade, Nov 18, 2026. Read this first if v13.4 is already live.

This package (chon-pms-namecheap-v13-6.zip) supersedes v13.5, which
was packaged but not uploaded. Upload v13.6 instead of v13.5. It
includes everything in v13.5 (Ledger phone stacking, tab bar scroll,
skip unconfigured connectors) plus one fix Chau reported from the
API & Config tab:

The Scopes checkboxes in the Create token form were misaligned: each
checkbox sat on the left and its label (Bookings (read), Rooms and
rates (read), and so on) sat far to the right, centred and wrapping
to two lines. Cause: the global input rule gave every checkbox
width: 100%, padding, and a border, so the checkbox took the full
row width inside its flex label and pushed the label text away. The
min-height rule above it already excluded checkboxes and radios; the
width rule did not. v13.6 excludes them from the width rule too, so
every checkbox in the app (API scopes, housekeeping, notifications,
and the rest) renders at its natural size beside its label.
(styles-v13-6.css.)

What v13.6 changes: styles-v13-6.css only, plus the v13.5 changes
(server.js, app-v13-6.js). The frontend files are renamed to v13-6
so the live version is unambiguous. No database change.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v13-6.zip, right click it, Extract,
   Extract Files, overwriting the files already there. Confirm files
   are 644 and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and hard refresh. Log in as
   chonadmin. Open API & Config and check each Scopes checkbox sits
   beside its label. On your phone, open the Ledger tab and check
   the rows stack top to bottom with the buttons at the bottom. Open
   Night Audit and check the tab bar shows it. Check the audit log
   after the next quarter hour and confirm no new connector.sync.error
   entries appear for unconfigured connectors. Your bookings, users,
   rooms, connectors, and ledger entries are untouched.
5. Optional: after extraction, delete the old public/app-v13-1.js and
   public/styles-v13-1.css from the server folder, and the old
   book-v13-1, checkin-v13-1, ocr-fields-v13-1, and ocr-loader-v13-1
   files. They are not used any more (index.html now points at the
   v13-6 files). Leaving them does no harm, but deleting them avoids
   confusion.

## v13.5 upgrade, Nov 18, 2026. Read this first if v13.4 is already live.

This package (chon-pms-namecheap-v13-5.zip) fixes three things
Chau reported from his phone and computer:

1. Ledger on a phone: expense and revenue rows were squeezed side
   by side and unreadable. On screens up to 560px wide the rows now
   stack top to bottom, the title wraps instead of cutting off, and
   the Approve, Edit, Receipts, and Delete buttons sit at the
   bottom, full width. (styles-v13-5.css media query.)
2. Tab bar: when Night Audit (or any tab far right) was open, the
   tab bar still showed the first tabs, so the active tab was
   hidden until the user scrolled right to find it. After every
   render the bar now scrolls so the active tab is visible, showing
   it and the tabs to its right. It only adjusts the bar's own
   horizontal scroll, never the page, and only when the active tab
   is out of view. (app-v13-5.js scrollActiveTabIntoView.)
3. Connector sync errors: the scheduled sync (every 15 minutes)
   tried to sync connectors that were never set up and logged an
   error for each (No SePay API key, No iCal feed URL, No Beds24
   key), filling the audit log. The scheduled sync now skips
   unconfigured connectors silently: no sync attempt, no audit log
   entry, no status change. They start syncing as soon as their
   credentials are saved. A manual Sync now still reports the
   missing setup, because the admin asked for that sync.
   (server.js connectorIsConfigured.)

What v13.5 changes: server.js, app-v13-5.js, styles-v13-5.css. The
frontend files are renamed to v13-5 so the live version is
unambiguous. No database change.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v13-5.zip, right click it, Extract,
   Extract Files, overwriting the files already there. Confirm files
   are 644 and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and hard refresh. Log in as
   chonadmin. On your phone, open the Ledger tab and check the rows
   stack top to bottom with the buttons at the bottom. Open Night
   Audit and check the tab bar shows Night Audit instead of the
   first tabs. Check the audit log after the next quarter hour and
   confirm no new connector.sync.error entries appear for
   unconfigured connectors. Your bookings, users, rooms,
   connectors, and ledger entries are untouched.
5. Optional: after extraction, delete the old public/app-v13-1.js and
   public/styles-v13-1.css from the server folder, and the old
   book-v13-1, checkin-v13-1, ocr-fields-v13-1, and ocr-loader-v13-1
   files. They are not used any more (index.html now points at the
   v13-5 files). Leaving them does no harm, but deleting them avoids
   confusion.

## v13.4 upgrade, Nov 18, 2026. Read this first if v13.1 is already live.

This package (chon-pms-namecheap-v13-4.zip) supersedes v13.3, which
was packaged but not uploaded. Upload v13.4 instead of v13.3. It
includes everything in v13.3 (the logo link back to the Chon website
and the favicon) with one change: the favicon is now the gold C
monogram on the dark wood-brown tile, matching the Guest Dashboard
logo mark, instead of the full CHON Boutique Stay wordmark, which
was too hard to read at favicon size. Frontend only, no server or
database change.

What v13.4 changes: the four favicon files only (favicon.svg,
favicon.ico, favicon-32.png, apple-touch-icon.png). The frontend
files are renamed to v13-4 so the live version is unambiguous, but
their contents are unchanged from v13.3.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v13-4.zip, right click it, Extract,
   Extract Files, overwriting the files already there. Confirm files
   are 644 and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and hard refresh. Log in as
   chonadmin. Check the browser tab shows the gold C logo, and click
   the CHON Boutique Stay logo in the header to check the Chon
   website opens in a new tab. Your bookings, users, rooms,
   connectors, and ledger entries are untouched.
5. Optional: after extraction, delete the old public/app-v13-1.js and
   public/styles-v13-1.css from the server folder, and the old
   book-v13-1, checkin-v13-1, ocr-fields-v13-1, and ocr-loader-v13-1
   files. They are not used any more (index.html now points at the
   v13-4 files). Leaving them does no harm, but deleting them avoids
   confusion.

## v13.3 upgrade, Nov 18, 2026. Read this first if v13.1 is already live.

This package (chon-pms-namecheap-v13-3.zip) supersedes v13.2, which
was packaged but not uploaded. Upload v13.3 instead of v13.2. It
includes the v13.2 logo link (the CHON Boutique Stay logo in the
header and on the login page links back to the Chon website in a new
tab) plus a Chon favicon: the CHON Boutique Stay wordmark on the
maroon lockup tile, as favicon.svg, favicon.ico, favicon-32.png, and
apple-touch-icon.png, referenced from index.html. The browser tab
now shows the Chon logo instead of the generic globe icon. Frontend
only, no server or database change.

What v13.3 changes: public/index.html (favicon links), the four new
favicon files, and app-v13-3.js and styles-v13-3.css (the v13.2 logo
link, renamed). The frontend files are renamed to v13-3 so the live
version is unambiguous.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v13-3.zip, right click it, Extract,
   Extract Files, overwriting the files already there. Confirm files
   are 644 and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and hard refresh. Log in as
   chonadmin. Check the browser tab shows the Chon logo, and click
   the CHON Boutique Stay logo in the header to check the Chon
   website opens in a new tab. Your bookings, users, rooms,
   connectors, and ledger entries are untouched.
5. Optional: after extraction, delete the old public/app-v13-1.js and
   public/styles-v13-1.css from the server folder, and the old
   book-v13-1, checkin-v13-1, ocr-fields-v13-1, and ocr-loader-v13-1
   files. They are not used any more (index.html now points at the
   v13-3 files). Leaving them does no harm, but deleting them avoids
   confusion.

## v13.2 upgrade, Nov 18, 2026. Read this first if v13.1 is already live.

This package (chon-pms-namecheap-v13-2.zip) links the CHON Boutique
Stay logo in the PMS header and on the login page back to the Chon
website (https://chonstay.24kgoals.com), opening in a new tab so the
PMS session stays open. Frontend only: the chonLockup function in
app-v13-2.js now returns an anchor tag instead of a div, and
styles-v13-2.css adds text-decoration none to the lockup so the link
shows no underline. No server change, no database change.

What v13.2 changes: app-v13-2.js and styles-v13-2.css only. The
frontend files are renamed to v13-2 (app-v13-2.js, styles-v13-2.css,
and the book, checkin, and OCR files) so the live version is
unambiguous, but only app and styles changed in content.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v13-2.zip, right click it, Extract,
   Extract Files, overwriting the files already there. Confirm files
   are 644 and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and hard refresh. Log in as
   chonadmin. Click the CHON Boutique Stay logo in the header and
   check the Chon website opens in a new tab. Your bookings, users,
   rooms, connectors, and ledger entries are untouched.
5. Optional: after extraction, delete the old public/app-v13-1.js and
   public/styles-v13-1.css from the server folder, and the old
   book-v13-1, checkin-v13-1, ocr-fields-v13-1, and ocr-loader-v13-1
   files. They are not used any more (index.html now points at the
   v13-2 files). Leaving them does no harm, but deleting them avoids
   confusion.

## v13.1 upgrade, Nov 17, 2026. Read this first if v13 is already live.

This package (chon-pms-namecheap-v13-1.zip) fixes the Night audit,
Cashier, and Housekeeping tasks tabs, which all failed on v13 with
"That action could not be completed." The cause: the audit_pack
table has a column named `trigger`, which is a reserved word in
MariaDB, so the table could not be created and the money tables
after it (tills, petty_cash, currency_log, company_accounts,
company_transactions, audit_log) were never created either. v13.1
renames the column to `run_trigger`. The audit_pack table does not
exist yet on any live database, so there is no migration and no
phpMyAdmin step.

What v13.1 changes: server.js only (the column rename in the table
definition, the audit insert, and the pack reader). The frontend
files are renamed to v13-1 (app-v13-1.js, styles-v13-1.css, and the
book, checkin, and OCR files) so the live version is unambiguous,
but their contents are unchanged from v13.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v13-1.zip, right click it, Extract,
   Extract Files, overwriting the files already there. Confirm files
   are 644 and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and hard refresh. Log in as
   chonadmin. Open the Night audit tab and check the audit status
   loads, the Cashier tab and check it loads, and the Housekeeping
   tab and check the tasks load. Your bookings, users, rooms,
   connectors, and ledger entries are untouched.
5. Optional: after extraction, delete the old public/app-v13.js and
   public/styles-v13.css from the server folder, and the old
   book-v13, checkin-v13, ocr-fields-v13, and ocr-loader-v13 files.
   They are not used any more (index.html now points at the v13-1
   files). Leaving them does no harm, but deleting them avoids
   confusion.

## v13 upgrade, Nov 16, 2026. Read this first if v12 is already live.

This package (chon-pms-namecheap-v13.zip) is Phase 4 of the approved
PMS upgrade: finish the hooks. It includes all v2 to v12 changes
too, so v13 alone is enough, there is no need to upload an earlier
version first. Do not upload v12 or earlier instead of v13.

What v13 adds: scheduled email for the owner reporting pack (an
SMTP mailer with EN and VI flash and snapshot templates,
Admin-configured weekly or monthly schedules, a send log, and a
scheduled endpoint), receipt photo upload for the ledger (JPG, PNG
or PDF up to 5 MB, stored on the server), a dedicated guest
check-in link (`/checkin/<token>`, one unguessable token per
booking expiring at check-out, guest ID capture and signature
before arrival, pre-checked-in flag on the Today board), live
message sending (queued outbox rows sent through the configured
WhatsApp or Zalo provider, or by email through the SMTP mailer,
with delivery status and retry), and passport and ID OCR for self
check-in (client-side in the browser, no account, no API key).

The server creates the 4 new tables (`email_schedules`,
`email_send_log`, `receipts`, `checkin_tokens`), adds the
`pre_checked_in` column to `bookings`, and widens the
`message_outbox` status ENUM itself on its first start after the
upgrade. There is no phpMyAdmin step for v13, and no NPM Install is
needed: mysql2 is still the only dependency, and node_modules is
already on the server. The only new environment variables are the
five SMTP settings (CHON_SMTP_HOST, CHON_SMTP_PORT, CHON_SMTP_USER,
CHON_SMTP_PASS, CHON_SMTP_FROM): enter them in Setup Node.js App
only when the admin@chonstay.com mailbox exists and you want email
sending. Without them the Reports email settings show "Email is not
configured" and no email is sent, and everything else works.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v13.zip, right click it, Extract,
   Extract Files, overwriting the files already there. Confirm files
   are 644 and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and hard refresh. Log in as
   chonadmin. Open the Reports tab and check the email settings
   load, the Ledger tab and check a receipt uploads, and the
   Messaging tab and check the outbox loads. Your bookings, users,
   rooms, connectors, and ledger entries are untouched.
5. Optional: after extraction, delete the old public/app-v12.js and
   public/styles-v12.css from the server folder. They are not used
   any more (index.html now points at app-v13.js and styles-v13.css).
   Leaving them does no harm, but deleting them avoids confusion.

Receipts live in an `uploads/` folder next to `server.js`, created
by the server on startup. The folder is NOT in the zip: cPanel
Extract does not delete files that are not in the zip, so uploaded
receipts survive an upgrade. Do not delete the `uploads/` folder.
Receipts are never served from a public path: opening one needs a
logged-in session, and the response is marked private, no-store.
Shared hosting has 20 GB SSD; receipts are small (5 MB each at
most), so storage is not a concern at Chon's volume.

Check-in links: a Staff or Admin creates the link from a booking
(Front Desk or Reservation 360), and the check-in message template
now links to the guest's own link instead of the booking page. The
link expires at check-out (12:00 hotel time) and an Admin can
revoke it. A guest who completed check-in shows as pre-checked-in
on the Today board. The public page shows nothing at all when the
link is invalid, expired, revoked, or already used.

Messaging send: on the Messaging tab, an admin opens a provider
card (WhatsApp or Zalo), enters the provider details and saves,
the same as v12. Queued outbox rows are now sent when Staff
presses Send: WhatsApp needs a phone number id and an access token
from a Meta WhatsApp Business account; Zalo needs an access token
from a Zalo Official Account, and the recipient must be the
guest's Zalo user id, because the OA customer-service API does not
accept phone numbers (phone-based sending needs Zalo ZNS
templates, a later step). Email rows send through the SMTP mailer
to the guest's email address, and need the SMTP settings above. A
failed send records the reason on the row and can be retried.

New cron job (uses the same CHON_SYNC_TOKEN as the other crons, and
the same token scheme: `?token=` or the X-CHON-SYNC-TOKEN header).
Add it in cPanel Cron Jobs:
- Report email, once a day at 06:00: `curl -s
  "https://pms.chonstay.24kgoals.com/api/email/run?token=YOUR_SYNC_TOKEN"`
  (replace YOUR_SYNC_TOKEN with the CHON_SYNC_TOKEN value). It
  sends every due, enabled email schedule (weekly on its day,
  monthly on its day) and skips schedules already sent. Without
  the cron job, reports only go out when an Admin presses Send now.

Limit: the v13 build was verified with a stubbed in-memory database
in tests (314 checks, 0 failures), not against a live MySQL server,
and no live SMTP server, WhatsApp, or Zalo account exists yet. The
first live start, which creates the 4 tables and the bookings
column, is the live check. If the new tabs do not load after the
restart, the cPanel server log shows the error.

## v12 upgrade, Nov 16, 2026. Read this first if v11.1 is already live.

This package (chon-pms-namecheap-v12.zip) is Phase 3 of the approved
PMS upgrade: connect and automate. It includes all v2 to v11.1 changes
too, so v12 alone is enough, there is no need to upload an earlier
version first. Do not upload v11.1 or earlier instead of v12.

What v12 adds: sync integrity (every import writes a revision row, a
booking changed locally is never overwritten by an import, and
reconciliation compares a provider feed against PMS bookings without
changing any booking), two-way iCal push (a feed URL per room that
publishes blocked dates with no guest names), an automation engine
(rules that fire on booking, check-in, payment, folio and audit
events), a messaging framework (WhatsApp and Zalo provider cards,
templates, an outbox and threads; no message ever leaves the PMS in
v12), a direct booking engine (a public `/book` page with
availability, quote and booking endpoints, plus an ARI feed), scoped
API tokens with a read-only `/api/v1` REST API, a smart-lock
lifecycle stub (events logged, no lock connected), and
hotel-as-YAML config (export and import of rooms, rate plans, meal
plans and the VAT rate, with a diff preview).

The server creates the 18 new tables and the 4 new bookings columns
itself on its first start after the upgrade. There is no phpMyAdmin
step for v12, and no new environment variables: the
CHON_CONNECTOR_KEY and CHON_SYNC_TOKEN values already set for v7 stay
as they are. No NPM Install is needed: mysql2 is still the only
dependency, and node_modules is already on the server.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v12.zip, right click it, Extract,
   Extract Files, overwriting the files already there. Confirm files
   are 644 and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and hard refresh. Log in as
   chonadmin. Open the Connectors tab and check that each connector
   card shows its last sync result. Open the Automation, Messaging
   and API and Config tabs (Admin only) and check that they load.
   Your bookings, users, rooms, connectors, and ledger entries are
   untouched.
5. Optional: after extraction, delete the old public/app-v11-1.js and
   public/styles-v11-1.css from the server folder. They are not used
   any more (index.html now points at app-v12.js and styles-v12.css).
   Leaving them does no harm, but deleting them avoids confusion.

New cron jobs (both use the same CHON_SYNC_TOKEN as the sync and
audit crons, and the same token scheme: `?token=` or the
X-CHON-SYNC-TOKEN header). Add them in cPanel Cron Jobs:
- Reconciliation, once a day at 04:00: `curl -s
  "https://pms.chonstay.24kgoals.com/api/reconcile/run?token=YOUR_SYNC_TOKEN"`
  (replace YOUR_SYNC_TOKEN with the CHON_SYNC_TOKEN value). It runs
  reconciliation for every enabled reservation connector and clears
  sync log rows stuck in 'running' for more than 60 minutes.
- Automation, every hour: `curl -s
  "https://pms.chonstay.24kgoals.com/api/automation/run?token=YOUR_SYNC_TOKEN"`.
  It fires overdue housekeeping escalations (once per task per day)
  and expires smart-lock codes for stays whose check-out passed
  without checkout.

The public booking page lives at
https://pms.chonstay.24kgoals.com/book (no login). Public bookings
arrive confirmed, source "direct", with the note "Booked on the
public booking page. Please confirm with the guest." Staff confirm
with the guest by phone or email. The page and its endpoints expose
no staff data and no guest contact details of other guests. The
ARI feed for Google Hotel free links is at
https://pms.chonstay.24kgoals.com/api/public/ari?checkIn=YYYY-MM-DD&checkOut=YYYY-MM-DD.

API tokens: an admin creates them on the API and Config tab, with
one or more of the four read scopes (bookings, rooms, ledger,
guests). The token value is shown once, at creation: copy it then,
it cannot be shown again. Tokens are stored as hashes, and a revoked
token is refused at once. The OpenAPI document is at
https://pms.chonstay.24kgoals.com/api/v1/openapi.json (no auth).

Messaging provider setup: on the Messaging tab, an admin opens a
provider card (WhatsApp or Zalo), enters the provider details and
saves. The details are encrypted with CHON_CONNECTOR_KEY, the same
scheme as connector keys, so CHON_CONNECTOR_KEY must be set before
saving. Configuring a provider moves its queued outbox rows to
"ready". Nothing is sent in v12: live sending is a future hook, and
no WhatsApp, Zalo, or email account is needed yet. The WhatsApp
setup path, when live sending is built, is a Meta WhatsApp Business
account with a phone number id and an API key; the Zalo path is a
Zalo Official Account with an oa id and an access token.

Smart locks: no smart lock is connected in v12. The API and Config
tab shows "No smart lock connected", lifecycle events are logged
with status "no_provider", and the stub provider cannot be enabled.
Connect a real lock provider only if locks are installed.

Limit: the v12 build was verified with a stubbed in-memory database
in tests (375 checks, 0 failures), not against a live MySQL server,
and no live SePay, messaging, or smart-lock credentials exist yet.
The first live start, which creates the 18 tables and the bookings
columns, is the live check. If the new tabs do not load after the
restart, the cPanel server log shows the error.

## v11.1 upgrade, Nov 16, 2026. Read this first if v11 is already live.

This package (chon-pms-namecheap-v11-1.zip) is a small patch release:
one new revenue account, 4001 Room Revenue (VI "Doanh thu phòng"),
in a new revenue group 'rooms'. It includes all v2 to v11 changes
too, so v11.1 alone is enough, there is no need to upload an earlier
version first. Do not upload v11 or earlier instead of v11.1.

Until now the ledger had only 4101 Food, 4102 Beverage, 4201 Other
Operated and 4301 Miscellaneous Income, so Beds24, Booking.com and
Agoda payouts had nowhere proper to post and sat in the bank review
queue. A SePay mapping rule or a statement import row can now map
money in to 4001, and 4001 appears in the Add revenue dropdown and
in the revenue list like any other account. A 4001 entry is the cash
receipt of room revenue already counted in the monthly summary's
Room revenue line (computed from bookings), so the summary sums only
4101 and 4102 for F&B and only 4201 and 4301 for Other, and 4001
never adds to Room, F&B, Other, or Total revenue.

The server widens the revenue_group ENUM and seeds 4001 itself on
its first start after the upgrade. There is no phpMyAdmin step for
v11.1, and no new environment variables: the CHON_CONNECTOR_KEY and
CHON_SYNC_TOKEN values already set for v7 stay as they are. No NPM
Install is needed: mysql2 is still the only dependency, and
node_modules is already on the server.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v11-1.zip, right click it, Extract,
   Extract Files, overwriting the files already there. Confirm files
   are 644 and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and hard refresh. Log in as
   chonadmin. Open the Ledger tab, click Add revenue, and check that
   4001 Room Revenue appears in the account dropdown under the Room
   revenue group. Open the Connectors tab, add a mapping rule for
   money in, and check that 4001 appears in the account list. Your
   bookings, users, rooms, connectors, and ledger entries are
   untouched.
5. Optional: after extraction, delete the old public/app-v11.js and
   public/styles-v11.css from the server folder. They are not used
   any more (index.html now points at app-v11-1.js and
   styles-v11-1.css). Leaving them does no harm, but deleting them
   avoids confusion.

Limit: the v11.1 patch was verified with a stubbed in-memory
database in tests, not against a live MySQL server, and no live
SePay keys exist yet. The first live start, which widens the ENUM
and seeds 4001, is the live check. If the 4001 account does not
appear in the Add revenue dropdown after the restart, the cPanel
server log shows the error.

## v11 upgrade, Nov 16, 2026. Read this first if v1 to v10 is already live.

This package (chon-pms-namecheap-v11.zip) is Phase 2 of the approved
PMS upgrade, daily operations and revenue. It includes all v2 to v10
changes too, so v11 alone is enough, there is no need to upload an
earlier version first. Do not upload v10 or earlier instead of v11.

1. Housekeeping phone workflow. The Housekeeping view now has task
   cards per room: Staff claims a task, starts it, finishes it with
   a photo from the phone camera, and an Admin inspects it to
   confirm. Tasks carry an SLA due time (default 14:00, the
   check-in time); overdue tasks show on the Today board. Turnover
   tasks are created automatically for dirty rooms. Staff can report
   a defect from the phone, which puts the room Out of Order until
   maintenance marks it fixed, when the room returns to Dirty.
2. Today board and Reservation 360. A new Today tab shows arrivals,
   departures, in-house balances, and the 7-room board for the
   current business date, with overdue tasks and open defects as
   alerts. The booking detail now shows live billing (folio balance)
   and lets you amend dates: the new dates are re-priced by the rate
   engine and the difference is shown before you confirm.
3. Guest 360 and duplicate merge. A new Guests tab: one record per
   guest with stay history, lifetime spend, and VIP and blacklist
   flags (Admin sets them; a blacklist flag warns when you create a
   booking for that guest, it never blocks it). An Admin can merge
   two guest records and undo the merge once.
4. Self check-in with ID capture. From the Today board or the
   booking detail, capture an ID photo with the phone camera, enter
   the ID fields (name, ID or passport number, nationality, date of
   birth, expiry date), and sign on screen. ID data is only visible
   to logged-in Staff and Admin, never in logs or on any public
   page. An Admin can purge ID captures for departed guests. No
   passport OCR is built yet: the typed-in fields are the working
   path, and OCR is a documented future hook.
5. Groups and whole-property buyouts. A new Groups tab: create a
   group with a rooming list, a group rate (per room per night, or a
   flat total), a deposit with a due date, and a printable
   quotation. The group creates the underlying room bookings,
   blocked on the calendar. A group taking all 7 rooms is a
   whole-property buyout.
6. Ve Cafe POS. A new Cafe POS tab: 8 tables, tap to open a bill, an
   Admin-managed menu (seeded with a small starter list, clearly
   marked as a starter to edit), split bills across payers, room
   charges posting to the guest folio with VAT, and a kitchen
   display view. KOT and bill views print through the browser. When
   a bill closes, cafe sales post to the ledger (food 4101, beverage
   4102, other 4201). POS cash counts towards the open till; card
   and room payments do not. The night audit now really blocks on
   open cafe bills, so close them before running the audit.
7. Rate-engine depth. A rate engine section in Rooms and rates
   (Admin configures, Staff views and quotes): seasons with a rate
   multiplier or a per-room override, rate plans, meal plans,
   vouchers, floor and ceiling guardrails per room (the engine
   refuses a price outside the band, it never silently clamps), and
   dynamic rules (weekend uplift, event dates, occupancy
   thresholds). Every booking is priced by the engine and shows the
   breakdown; with nothing configured, a quote equals the old
   calculation exactly. The Nov 9 rates stay as the base rates.
   Cancellation, no-show and deposit policies are Admin-configurable
   fields that default to unset ("not set, Admin to configure"),
   because Chon has no published cancellation policy and none is
   invented.
8. Owner reporting pack. A new Reports tab (Admin only): a flash
   dashboard for a chosen month (occupancy, ADR, RevPAR, total
   revenue, GOP), budget vs actual (Admin enters monthly targets per
   line), monthly snapshots, and a custom report builder (pick a
   date range and metrics, download as CSV). No scheduled email is
   built: no SMTP is configured, and that is a documented future
   hook.

No schema import is needed. Do NOT re-import schema.sql and do NOT
touch the database. The server creates the new tables itself on its
first start after the upgrade (housekeeping_tasks,
housekeeping_defects, guests, guest_merges, id_captures, groups,
group_rooms, pos_tables, pos_menu_items, pos_bills, pos_bill_items,
pos_bill_payments, rate_seasons, rate_season_rooms, rate_plans,
meal_plans, vouchers, rate_guardrails, rate_rules, report_budgets,
report_snapshots) and adds six columns to bookings (guest_id,
group_id, rate_plan_id, meal_plan_id, voucher_code, price_json).
There is no phpMyAdmin step for v11, and no new environment
variables: the CHON_CONNECTOR_KEY and CHON_SYNC_TOKEN values already
set for v7 stay as they are. No NPM Install is needed: mysql2 is
still the only dependency, and node_modules is already on the server.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v11.zip, right click it, Extract,
   Extract Files, overwriting the files already there. Confirm files
   are 644 and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and hard refresh. Log in as
   chonadmin. Check the new tabs: Today, Guests, Groups, Cafe POS
   (Staff and Admin), and Reports (Admin only), next to the existing
   tabs. Open Housekeeping and check that a dirty room has a
   turnover task with Claim, Start and Finish. Open Cafe POS and
   check that 8 tables show with the starter menu. Open Rooms and
   rates and check the rate engine section with the Standard plan.
   Your bookings, users, rooms, connectors, and ledger entries are
   untouched.
5. Optional: after extraction, delete the old public/app-v10.js and
   public/styles-v10.css from the server folder. They are not used
   any more (index.html now points at app-v11.js and
   styles-v11.css). Leaving them does no harm, but deleting them
   avoids confusion.

Notes on the new features:
- Bookings made before v11 have no guest record, no rate plan, no
  meal plan, and no price breakdown stored. They work exactly as
  before; the guest link, plans and breakdown are stored only for
  bookings created or amended after the upgrade. A date amend on an
  old booking re-prices it with the engine and stores the breakdown.
- The starter cafe menu (Vietnamese coffee, iced tea, orange juice,
  mineral water, beer, banh mi, pho, spring rolls) is a placeholder
  to edit, not a real Ve Cafe menu. Change the items and prices in
  the POS menu manager before using it with real guests.
- The meal plans seed with a zero add-on, so the admin sets the
  price for breakfast and for breakfast and dinner. Room only stays
  zero by definition.
- A group deposit is tracked on the group (amount, due date, paid
  flag). Deposit cash itself is recorded as a folio payment when
  the group checks in, the same as any other payment.
- The first night audit after the upgrade blocks on any open cafe
  bill, so close the cafe bills before running it.

Limit: the v11 features were verified with a stubbed in-memory
database in tests, not against a live MySQL server, and no live
SePay or Beds24 keys exist yet. The first real housekeeping task,
POS sale and night audit on the live install are the live checks.
Run them by hand the first time and check the results.

## v10 upgrade, Nov 16, 2026. Read this first if v1 to v9 is already live.

This package (chon-pms-namecheap-v10.zip) is Phase 1 of the approved
PMS upgrade, money correctness. It includes all v2 to v9 changes too,
so v10 alone is enough, there is no need to upload an earlier version
first. Do not upload v9 or earlier instead of v10.

1. Guest folio per stay. Every checked-in stay now has a folio, an
   itemized bill, opened automatically at check-in and reachable from
   Front desk, Bookings, and the booking detail. Room nights and
   extra beds post from the agreed booking rate, manual charges can
   be added (cafe and misc until the Phase 2 POS arrives), payments
   are recorded (cash, card, bank transfer), and checkout back-fills
   any unposted nights, then settles the folio into a numbered
   invoice (INV-2026-0001, and so on). Folio lines are append-only:
   they are never edited or deleted, and a void posts a reversing
   line after an admin approval with a reason. Amounts are stored in
   VND, and each line shows its VAT component (rates include VAT).
2. Night audit / End of Day. A new Night audit tab with a business
   date, a blocker checklist (arrivals checked in or marked no-show,
   departures checked out or extended, the till closed), and a Run
   button (Admin only). Running the audit posts the room nights for
   every occupied room, saves an audit pack snapshot (occupancy,
   revenue posted, payments, folio balances, till totals), and moves
   the business date to the next day. Running it twice for the same
   date posts nothing the second time. No-show bookings are flagged
   with a per-booking choice: charge one night or waive it. Chon has
   no published no-show policy, so the admin decides each time, and
   no charge is ever invented. The audit also runs automatically at
   03:00 through a cPanel cron job (see below).
3. Cashier discipline. A new Cashier tab: one till at a time (Staff
   opens it with a starting float, Admin closes it with counted cash
   against expected cash and a variance note), petty cash that posts
   to the ledger as an expense, a currency desk log for guest
   exchanges, and the pending void and discount requests, which an
   admin approves or rejects with the reason on record.
4. Split billing and a city ledger. Any folio line can be routed to
   the guest or to a company account. Company accounts (Admin only
   to create and edit) carry a balance with aging (current, 30, 60,
   90+ days), and payments against a company account reduce its
   balance. A folio routed partly to a company shows both balances
   at settlement.
5. Audit trail. Every state-changing action now writes who, what,
   which record, and a short detail to an audit log, viewable on a
   new Audit log tab (Admin only), filterable by date, user and
   action.
6. Versioned frontend files. The frontend files are now app-v10.js
   and styles-v10.css instead of app.js and styles.css, so the
   LiteSpeed stale Brotli cache that kept serving the v8 frontend
   after the v9 upload can never happen again: each release is a
   fresh URL. The old app.js and styles.css are NOT in this package,
   so delete them from the server folder after extraction if they
   are still there (they are not used any more, and leaving them
   costs nothing, but deleting them avoids confusion).

No schema import is needed. Do NOT re-import schema.sql and do NOT
touch the database. The server creates the new tables itself on its
first start after the upgrade (pms_settings, folios, folio_lines,
folio_payments, folio_adjustments, invoices, audit_pack, tills,
petty_cash, currency_log, company_accounts, company_transactions,
audit_log). There is no phpMyAdmin step for v10, and no new
environment variables: the CHON_CONNECTOR_KEY and CHON_SYNC_TOKEN
values already set for v7 stay as they are. No NPM Install is needed:
mysql2 is still the only dependency, and node_modules is already on
the server.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v10.zip, right click it, Extract,
   Extract Files, overwriting the files already there. Confirm files
   are 644 and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and hard refresh. Log in as
   chonadmin. Check the new tabs: Night audit, Cashier, and Audit
   log (Admin only) next to the existing tabs. Open a checked-in
   booking and check that a Folio button opens the folio with its
   lines and balance. Your bookings, users, rooms, connectors, and
   ledger entries are untouched.
5. Optional: after extraction, delete the old public/app.js and
   public/styles.css from the server folder. They are not used any
   more (index.html now points at app-v10.js and styles-v10.css).
   Leaving them does no harm, but deleting them avoids confusion.

To set up the scheduled night audit (recommended): in cPanel, Cron
Jobs, add a job that runs every day at 03:00 and calls the audit
endpoint with your token (replace YOUR_SYNC_TOKEN with the
CHON_SYNC_TOKEN value, the same token as the sync endpoint):

```
curl -fsS "https://pms.chonstay.24kgoals.com/api/audit/run?token=YOUR_SYNC_TOKEN"
```

The endpoint closes the current business date and opens the next
one. If the checklist is not clear (an arrival still unchecked, a
departure still in house, a till still open), it answers with the
blockers and does not force a close, so run it by hand from the
Night audit tab instead. A bad token answers 401, a missing
CHON_SYNC_TOKEN answers 503, and an audit already in progress
answers 409. Nothing runs inside the app itself: no background jobs,
no timers.

Notes on the new features:
- The business date starts at today on the first run, and moves
  forward one day per completed audit. If the audit is not run for
  a few days, the business date stays behind, and the next audit
  closes the oldest open date first. That is correct night-audit
  behaviour: dates close in order.
- The VAT rate defaults to 10 percent (the standard Vietnamese VAT
  rate) and an Admin can change it on the Night audit tab. The rate
  applies to lines posted after the change; lines already posted
  keep the VAT they were posted with.
- A folio can still take a payment after settlement, for a guest who
  pays later: the payment reduces the invoice balance due.
- A stay checked in before v10 has no folio until it is opened: open
  the folio from the booking and it is created on the spot, with no
  lines, and checkout back-fills the nights.

Limit: the money features were verified with a stubbed in-memory
database in tests, not against a live MySQL server, and no live
SePay or Beds24 keys exist yet, so the first real night audit on the
live install is the live check. Run it by hand from the Night audit
tab the first time, and check the audit pack it saves.

## v9 upgrade, Nov 16, 2026. Read this first if v1, v2, v3, v4, v5, v6, v7 or v8 is already live.

This package (chon-pms-namecheap-v9.zip) adds the first working
payment pull, plus bank statement import. It includes all v2 to v8
changes too, so v9 alone is enough, there is no need to upload an
earlier version first. Do not upload v8 or earlier instead of v9.

1. SePay payment connector. SePay is a Vietnamese open-banking
   aggregator (sepay.vn) that reads bank activity for a business.
   Techcombank is not on SePay's direct-API bank list, so the
   Techcombank account connects through SMS Banking: SePay reads
   the bank's SMS balance notifications. The connector stores an
   API key and a webhook secret (encrypted with the same
   AES-256-GCM scheme as the Beds24 key), Test calls SePay GET
   /accounts/list, Sync pulls GET /transactions, and a webhook
   endpoint takes live balance-change events. Pulled transactions
   are stored once, idempotent on the SePay transaction id, so a
   webhook and a Sync pull of the same transaction never
   double-post. Money in becomes a revenue entry, money out an
   expense entry, both pending until an admin approves them.
2. Bank mapping rules and a review queue. On the Ledger tab, an
   admin rule matches a description substring to a ledger account
   (money in to a revenue account, money out to an expense
   account). A transaction with a matching rule posts to the ledger
   as a pending entry; without a rule it waits in the review queue,
   where an admin assigns the account and posts it. Bank-imported
   entries always arrive pending, the same model as Staff entries,
   and carry a Bank tag on the ledger rows.
3. Statement import. On the Ledger tab, upload a Techcombank
   Business statement in CSV format. The file is read in the
   browser, previewed with column mapping, and imported in chunks
   of 500 rows. Rows already in the PMS are skipped, so re-uploading
   the same file never double-imports. CSV only: no XLSX dependency
   is added, so export CSV from Techcombank Business.
4. Circular 64 notice. The Connectors page, Payments section, now
   explains that Vietnam's Circular 64 requires banks to expose
   standardized Open APIs by March 1, 2027, including transaction
   history, and that the direct Techcombank connector will be built
   then. SePay is the working route until then. A Techcombank card
   in the Payments chooser shows the roadmap as "Coming with
   Circular 64".

No schema import is needed. Do NOT re-import schema.sql and do NOT
touch the database. The server creates the new tables itself on its
first start after the upgrade (bank_mapping_rules and
bank_transactions) and adds a source column to expenses and
revenues, so bank-imported entries can be tagged. There is no
phpMyAdmin step for v9, and no new environment variables: the
CHON_CONNECTOR_KEY and CHON_SYNC_TOKEN values already set for v7
stay as they are. CHON_SEPAY_BASE_URL exists in .env.example for
tests only; leave it unset in cPanel. No NPM Install is needed:
mysql2 is still the only dependency, and node_modules is already on
the server.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v9.zip, right click it, Extract, Extract
   Files, overwriting the files already there. Confirm files are 644
   and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and hard refresh. Log in as
   chonadmin. Check the four changes: the Connectors tab, Payments
   section, shows the Circular 64 notice and offers SePay in the
   chooser; the Ledger tab has a Bank transactions to review section,
   a Bank mapping rules section, and an Import a bank statement
   section. Your bookings, users, rooms, connectors, and ledger
   entries are untouched.

To set up SePay (needs a SePay account, not yet created):
1. Create a SePay account at https://sepay.vn and link the
   Techcombank business account. Switch SMS Banking notifications
   on for the account, because that is how SePay reads Techcombank
   activity. Note: Techcombank is not on SePay's direct-API bank
   list, so the Free and Startup plans, which list only the 12
   direct-API banks, may not cover it; check the plan when you link
   the account.
2. In SePay, under API, create an API key. In the PMS, open the
   Connectors tab, Add payment connector, SePay, Configure, and
   paste the API key. Save it, then run Test connection: it calls
   GET /accounts/list and reports how many bank accounts are linked.
3. In SePay, under Webhooks, add a webhook with this URL:
   https://pms.chonstay.24kgoals.com/api/connectors/sepay/webhook
   The same URL is shown in the SePay Configure dialog. Choose
   event type All, so money in and money out both arrive. Set a
   webhook secret in SePay and paste the same secret into the
   Configure dialog; if you leave the webhook secret empty in the
   PMS, the API key is used to check webhooks instead.
4. Enter the Techcombank account number in the Configure dialog,
   so only that account's transactions are imported when several
   bank accounts are linked to the same SePay account.
5. Run Sync now. New transactions post to the ledger as pending
   entries when a mapping rule matches, or wait in the review queue
   on the Ledger tab when no rule matches. The scheduled sync
   (every 15 minutes, see the v7 section below) pulls SePay too,
   once it is configured, so a missed webhook is picked up on the
   next run.

To add a mapping rule: open the Ledger tab, scroll to Bank mapping
rules, pick the direction (money in or money out), type the text to
match in the description (for example VNPAY, ELECTRICITY, or a
supplier name), pick the ledger account, and Add rule. Rules are
checked in priority order, lowest number first. A rule only applies
to transactions that arrive after it is added; transactions already
in the review queue are posted by hand.

To import a statement: open the Ledger tab, scroll to Import a bank
statement, and choose the CSV file exported from Techcombank
Business. The preview shows how many rows are ready to import and
how many are skipped (missing date, amount or description), and the
first 5 rows. Check the column mapping: date, amount (or separate
money in and money out columns), description, and reference. Fix a
wrong column with its dropdown, then Import statement. The import
runs in chunks and reports how many rows posted, how many went to
the review queue, how many were already in the PMS, and how many
were skipped. For a very large statement (thousands of rows),
export it per month instead of all at once, so each import finishes
in a few minutes.

Limit: no live SePay credentials exist yet, so the SePay adapter
was verified only against mocked SePay responses, the same limit as
the Beds24 adapter in v7. The first real sync with a real key is
the live check. The webhook and the Sync pull share one ingest
pipeline, so a transaction that arrives both ways is stored once.

## v8 upgrade, Nov 12, 2026. Read this first if v1, v2, v3, v4, v5, v6 or v7 is already live.

This package (chon-pms-namecheap-v8.zip) adds five owner-requested
changes, all in one upload. It includes all v2, v3, v4, v5, v6 and v7
changes too, so v8 alone is enough, there is no need to upload an
earlier version first. Do not upload v6 or v7 instead of v8.

1. Custom connector providers. The Connectors chooser always offers
   a custom provider in both groups, even when every built-in
   provider in the group is already added. A custom reservation
   provider is a name plus iCal feed URLs per room, so any channel
   that publishes an iCal feed can be added as its own named
   connector (for example "Airbnb iCal"). It runs the same iCal pull
   with its own status, Test, Sync, log, and conflicts, and imported
   bookings record the custom provider name. A custom payment
   provider is a name plus account details, stored for later:
   payment pull is still not built, so its Test and Sync are
   disabled. Multiple custom providers can be added; the built-in
   providers keep their one-instance rule.
2. Remove asks first. Deleting any connector now shows a
   confirmation step and states that imported bookings stay.
3. Miscellaneous expenses. Account 5801 Miscellaneous Expenses, in
   its own Miscellaneous group, in the Add expense dropdown, the
   monthly summary, and the department filter.
4. Other revenue. A separate Other revenue list on the Ledger tab
   for Ve Cafe sales and any other income, with 4 revenue accounts
   (4101 Food, 4102 Beverage, 4201 Other Operated, 4301
   Miscellaneous Income), the same Staff and Admin model as
   expenses, and a monthly summary that now shows Room revenue,
   F&B revenue, Other revenue, Total revenue, and GOP equals Total
   revenue minus Total approved expenses.
5. The header lockup and the Certified Private AI credit. The
   in-app header now uses the same CHON Boutique Stay lockup as the
   login page, and the login and header subtitles read "Property
   Management System by Certified Private AI", with the name linked
   to https://certifiedpai.com/contact/ in a new tab.

No schema import is needed. Do NOT re-import schema.sql and do NOT
touch the database. The server creates the new tables itself on its
first start after the upgrade (revenue_categories and revenues with
their 4 accounts seeded, the 5801 account seeded into
expense_categories, and the provider_kind and display_name columns
added to connectors with the built-in rows backfilled). There is no
phpMyAdmin step for v8, and no new environment variables: the
CHON_CONNECTOR_KEY and CHON_SYNC_TOKEN values already set for v7 stay
as they are.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v8.zip, right click it, Extract, Extract
   Files, overwriting the files already there. Confirm files are 644
   and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and hard refresh. Log in as
   chonadmin. Check the five changes: the header shows the CHON
   Boutique Stay lockup with the "Property Management System by
   Certified Private AI" subtitle; the Connectors tab chooser offers
   a custom provider in both groups; Remove on any card asks for
   confirmation first; the Ledger Add expense dropdown has a
   Miscellaneous group with 5801 Miscellaneous Expenses; the Ledger
   tab has an Other revenue list with an Add revenue button, and the
   monthly summary shows F&B revenue, Other revenue, and Total
   revenue. Your bookings, users, rooms, connectors, and ledger
   entries are untouched.

To add a custom reservation provider: open the Connectors tab, Add
reservation connector, Add custom reservation provider, type the
name (for example "Airbnb iCal"), paste one iCal feed URL per room
(the channel gives each room an export feed URL in its calendar
settings), and Save. Then Test connection to check each feed can be
reached, then Sync now. The blocked dates appear on the calendar as
bookings with source iCal, guest name from the feed when it has one,
and a total of 0 VND, because iCal feeds carry no price. If a feed
is down, the sync logs an error and keeps the bookings it already
has. The scheduled sync (every 15 minutes, see the v7 section below)
pulls custom reservation providers too, once they are configured.

To record other revenue: open the Ledger tab, scroll to Other
revenue, Add revenue, pick the date, the revenue account (4101 Food
or 4102 Beverage for Ve Cafe sales, 4201 or 4301 for anything else),
a description, the amount in VND, and the outlet. Staff entries land
pending for an admin to approve; an admin add is approved straight
away. Only approved revenue counts towards Total revenue and GOP.

## v7 upgrade, Nov 12, 2026. Read this first if v1, v2, v3, v4, v5 or v6 is already live.

This package (chon-pms-namecheap-v7.zip) adds the connector pull
framework to the Connectors tab (Admin only): each connector card now
has a status, a Test connection button, a Sync now button, a config
form, and a sync log. The iCal adapter pulls blocked dates from one
feed URL per room, with no API key needed. The Beds24 adapter pulls
reservations once an invite code or long-life token is saved. A sync
never deletes a booking and never double-books a room: an imported
booking that overlaps a live booking is recorded as a conflict and
shown on the Connectors page instead. Payment cards keep the same
frame with Test and Sync disabled: payment pull is not built yet.
This package includes all v2, v3, v4, v5 and v6 changes too, so v7
alone is enough, there is no need to upload an earlier version first.

No schema import is needed. Do NOT re-import schema.sql and do NOT
touch the database. The server creates the new tables itself on its
first start after the upgrade (connectors is extended with config and
encrypted secrets, connector_sync_logs and connector_conflicts are
created, and the external id columns are added to bookings). There is
no phpMyAdmin step for v7.

Two new environment variables are optional, but needed for
connectors. In cPanel, Setup Node.js App, Environment variables, add
them before or after the upload (either order works, the app starts
without them, but connectors are limited until they are set):

- CHON_CONNECTOR_KEY: a long random passphrase, or a 64 character hex
  string. It encrypts the Beds24 keys saved on the Connectors page.
  Without it, no Beds24 key can be saved, and the Connectors page says
  so. The iCal pull needs no key. Pick it once and keep it safe:
  changing it later makes keys saved before the change undecryptable,
  and they must be saved again.
- CHON_SYNC_TOKEN: a long random string. It protects the scheduled
  sync endpoint, /api/sync/run. Without it, the endpoint answers 503
  and syncs only happen when an admin presses Sync now.

Do not put either value in chat or in a ticket: set them directly in
cPanel.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v7.zip, right click it, Extract, Extract
   Files, overwriting the files already there. Confirm files are 644
   and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and hard refresh. Log in as
   chonadmin, open the Connectors tab: the five cards are now live
   cards with a status pill (Not connected yet), a last sync line
   (Never synced), and Configure, Test connection, Sync now, Sync
   log, and Remove buttons. On the Payments cards, Test and Sync are
   disabled with a note that payment pull is not built yet. If
   CHON_CONNECTOR_KEY is missing, the page says so at the top; if
   CHON_SYNC_TOKEN is missing, it says the scheduled sync is off. Your
   bookings, users, rooms and ledger are untouched.

To connect iCal: Configure the iCal card, paste one feed URL per room
(Airbnb, Booking.com and other channels give each room an export feed
URL in their calendar settings), Save, then Test connection to check
each feed can be reached, then Sync now. The blocked dates appear on
the calendar as bookings with source iCal, guest name from the feed
when it has one, and a total of 0 VND, because iCal feeds carry no
price. If a feed is down, the sync logs an error and keeps the
bookings it already has.

To connect Beds24: in Beds24, go to Settings, Marketplace, API, and
create an invite code (or a long-life token, which is read-only and
never expires). The scopes the pull needs are read:bookings,
read:bookings-personal, and read:properties. Configure the Beds24
card, pick the key type, paste the key, and Save. Invite codes expire
quickly, so run Test connection right away: it reads the property
(367148) and reports connected or the exact error. Then Sync now pulls
the reservations for the property and imports them through the pull
engine. The key is stored encrypted and only its last 4 characters
are ever shown. Note: the Beds24 pull has been verified only against
mocked Beds24 responses in tests, because no live API key exists yet.
The first real sync with a real key is the live check. If it reports
an error, the exact error is shown on the card and in the sync log.

To set up the scheduled sync (optional): in cPanel, Cron Jobs, add a
job that runs every 15 minutes and calls the sync endpoint with your
token (replace YOUR_SYNC_TOKEN with the CHON_SYNC_TOKEN value):

```
curl -fsS "https://pms.chonstay.24kgoals.com/api/sync/run?token=YOUR_SYNC_TOKEN"
```

The endpoint runs all enabled reservation connectors and returns a
JSON summary. A bad token answers 401, a missing CHON_SYNC_TOKEN
answers 503, and a sync already in progress answers 409. Nothing runs
inside the app itself: no background jobs, no timers.

Steps 1 to 6 below are the first-time install only. Skip them if v1,
v2, v3, v4, v5 or v6 is already live and you are doing the v7 upgrade
above.

## v6 upgrade, Nov 12, 2026. Read this first if v1, v2, v3, v4 or v5 is already live.

This package (chon-pms-namecheap-v6.zip) adds the native hotel expense
ledger: a new Ledger tab, visible to Staff and Admin, next to Rooms &
rates. Staff add expense entries (they start pending), admins approve,
reject, edit or delete them, and the monthly summary shows room revenue
against approved expenses by department, with gross operating profit.
The ledger uses a USALI-lite chart of accounts (20 accounts, 5000
series, seeded by the server). Amounts are entered and stored in VND
and displayed in USD in EN mode and VND in VI mode, the same currency
rule as the rest of the platform. This package includes all v2, v3, v4
and v5 changes too, so v6 alone is enough, there is no need to upload
an earlier version first.

No schema import and no environment variable change are needed. Do NOT
re-import schema.sql and do NOT touch the Node.js app settings or the
database. The server creates the two ledger tables (`expense_categories`
and `expenses`) itself, on its first start after the upgrade, and seeds
the 20 accounts, the same way it created the connectors table for v3.
There is no phpMyAdmin step for v6.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v6.zip, right click it, Extract, Extract
   Files, overwriting the files already there. Confirm files are 644
   and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and hard refresh. Log in as
   chonadmin and check that a Ledger tab is there next to Rooms &
   rates, that the monthly summary shows with 0 revenue and 0 expenses
   to start, and that Add expense opens the form with the 20 accounts
   grouped by department. Add a test expense as chonadmin: it should
   show as Approved straight away. Log in as a Staff user and check
   that the Ledger tab is there too, that adding an expense shows it
   as Pending, and that there are no Approve, Reject, Edit or Delete
   buttons on it. Log back in as chonadmin, approve the Staff expense,
   then delete both test expenses, so the ledger starts clean. Your
   bookings, users and rooms are untouched.

Steps 1 to 6 below are the first-time install only. Skip them if v1,
v2, v3, v4 or v5 is already live and you are doing the v6 upgrade above.

## v5 upgrade, Nov 11, 2026. Read this first if v1, v2, v3 or v4 is already live.

This package (chon-pms-namecheap-v5.zip) removes the Current password
field from the "Change my password" dialog. The dialog now asks only
for the new password (at least 8 characters) and its confirmation.
The server no longer checks the current password for this action: the
user is already logged in, so the session token is the proof of
identity. Login still checks the password as normal, and the admin
Users flows are unchanged. This package includes all v2, v3 and v4
changes too (currency follows the EN / VI toggle, contact email
admin@chonstay.com, Connectors page shell, CHON Boutique Stay login
lockup), so v5 alone is enough, there is no need to upload v2, v3 or
v4 first.

No schema change and no environment variable change are needed. Do NOT
re-import schema.sql and do NOT touch the Node.js app settings or the
database.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v5.zip, right click it, Extract, Extract
   Files, overwriting the files already there. Confirm files are 644
   and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and hard refresh. Log in,
   click "Change my password" in the header, and the dialog should
   show only "New password, at least 8 characters" and "Confirm new
   password". Your bookings, users and rooms are untouched.

## v4 upgrade, Nov 11, 2026. Read this first if v1, v2 or v3 is already live.

This package (chon-pms-namecheap-v4.zip) changes the login page only:
the wood-slat sign logo is replaced by the CHON Boutique Stay lockup
(cream Noto Serif capitals on a deep plum tile, recreated as real text,
so it scales cleanly), the redundant "Chon Boutique Stay" heading below
it is removed, and the page is resized so the whole login view fits in
one viewport with no scrolling at 1280x800 and 1366x768. Underneath the
logo it reads only "Property Management System" (EN) or "Hệ thống Quản
lý Khách sạn" (VI). Everything else on the login page is unchanged,
and the small mark in the app header is unchanged. This package
includes all v2 and v3 changes too (currency follows the EN / VI
toggle, contact email admin@chonstay.com, Connectors page shell), so
v4 alone is enough, there is no need to upload v2 or v3 first.

No schema change and no environment variable change are needed. Do NOT
re-import schema.sql and do NOT touch the Node.js app settings or the
database.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v4.zip, right click it, Extract, Extract
   Files, overwriting the files already there. Confirm files are 644
   and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and hard refresh. The login
   page should show the CHON Boutique Stay lockup at the top, then
   "Property Management System", then the CHỐN PMS card, all in one
   view with no scrolling. Your bookings, users and rooms are
   untouched.

Steps 1 to 6 below are the first-time install only. Skip them if v1,
v2, v3 or v4 is already live and you are doing the v5 upgrade above.

## v3 upgrade, Nov 11, 2026. Read this first if v1 or v2 is already live.

This package (chon-pms-namecheap-v3.zip) adds the Connectors page
shell only. There is a new Connectors tab in the platform, Admin only,
next to Users, hidden from Staff. It has two groups, Reservations on
top and Payments below, each with an Add button. Reservations offers
Beds24 and iCal, Payments offers AsiaPay, MoMo and PayPal. Adding one
puts a blank placeholder card on the page reading "Not connected yet",
with no functionality behind it: no credential fields, no Test button,
no Sync button. No connection is live yet, the real integrations are
built later. This package includes all v2 changes too (currency follows
the EN / VI toggle, contact email admin@chonstay.com), so if v2 was
never uploaded, v3 alone is enough, there is no need to upload v2 first.

No schema import and no environment variable change are needed. Do NOT
re-import schema.sql and do NOT touch the Node.js app settings or the
database. The server creates the one tiny table it needs for the
placeholder list (`connectors`) itself, on its first start after the
upgrade, the same way it created the chonadmin account. There is no
phpMyAdmin step for v3.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v3.zip, right click it, Extract, Extract
   Files, overwriting the files already there. Confirm files are 644
   and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and hard refresh. Log in as
   chonadmin and check that a Connectors tab is there next to Users,
   that the page starts blank with "Add reservation connector" and
   "Add payment connector", and that adding Beds24 shows a card
   reading "Not connected yet". Log in as a Staff user and check that
   the Connectors tab is not there at all. Your bookings, users and
   rooms are untouched.

Steps 1 to 6 below are the first-time install only. Skip them if v1
or v2 is already live and you are doing the v3 upgrade above.

## v2 upgrade, Nov 11, 2026. Read this first if v1 is already live.

This package (chon-pms-namecheap-v2.zip) is a frontend-only change:
the VND/USD toggle is removed, currency now follows the EN / VI
language toggle (EN shows USD, VI shows VND, at 25,600 VND per USD,
rounded to the nearest dollar), and the contact email shown in the
platform is now admin@chonstay.com instead of the old Gmail address.
Rates are still stored in VND, and the rate edit box still edits in VND.

No schema re-import and no environment variable change are needed.
Do NOT re-import schema.sql: it would not harm the rooms, but it is
not needed, and the users table must keep the accounts already made.
Do NOT touch the Node.js app settings or the database.

Upgrade steps:
1. In cPanel File Manager, go to /home/certivgm/pms.chonstay.24kgoals.com.
2. Upload chon-pms-namecheap-v2.zip, right click it, Extract, Extract
   Files, overwriting the files already there. Confirm files are 644
   and folders are 755 after extraction.
3. In Setup Node.js App, open the PMS.CHONSTAY.24KGOALS.COM app and
   click Restart. No NPM Install is needed: the dependencies did not
   change, and node_modules is already on the server.
4. Open https://pms.chonstay.24kgoals.com/ and hard refresh. Check that
   the VND/USD toggle is gone, that Rooms & rates shows $46 for
   Sanctuary in EN and 1.190.000 ₫ in VI, and that the header shows
   admin@chonstay.com. Your bookings, users and rooms are untouched.

Steps 1 to 6 below are the first-time install only. Skip them if v1
is already live and you are doing the v2 upgrade above.

## Step 0. Already done, Nov 11, 2026. Do not repeat.

- Subdomain `pms.chonstay.24kgoals.com` created in cPanel, document
  root `/home/certivgm/pms.chonstay.24kgoals.com`, Not Redirected,
  Force HTTPS Redirect Off, cPanel AutoSSL StandardSSL in progress.
- Cloudflare DNS, zone `24kgoals.com`: `pms.chonstay.24kgoals.com`
  A `162.0.215.135`, DNS only (grey cloud, proxy off), same IP as
  chonstay. SSL mode Full (strict). The Cloudflare Origin Certificate
  for `*.24kgoals.com`, already installed in cPanel, covers this
  subdomain, and it expires Nov 1, 2041.
- MySQL database `certivgm_chonpms`, user `certivgm_chonpms`,
  ALL PRIVILEGES, user added to the database. The database password is
  held by you only. You will need it in Step 3, and your chonadmin
  password too.

## Step 1. Import the database schema in phpMyAdmin

1. In cPanel, open phpMyAdmin (under Databases).
2. In the left sidebar, click the database `certivgm_chonpms`.
   Make sure it is that database, not another one.
3. Click the Import tab at the top.
4. Click Choose File and pick `schema.sql` from this package.
   (If you have only the zip, extract it on your computer first and
   pick `schema.sql` from the extracted folder.)
5. Leave the format as SQL and click Import (or Go) at the bottom.
6. You should see a green success message. In the left sidebar under
   `certivgm_chonpms` you should now see 66 tables: `api_tokens`,
   `audit_log`, `audit_pack`, `automation_rules`, `automation_runs`,
   `bank_mapping_rules`, `bank_transactions`, `bookings`,
   `company_accounts`, `company_transactions`, `config_snapshots`,
   `connector_conflicts`, `connector_sync_logs`, `connectors`,
   `currency_log`, `expense_categories`, `expenses`,
   `folio_adjustments`, `folio_lines`, `folio_payments`, `folios`,
   `group_rooms`, `groups`, `guest_merges`, `guests`,
   `housekeeping_defects`, `housekeeping_tasks`, `ical_push_log`,
   `ical_push_tokens`, `id_captures`, `invoices`, `ledger_notes`,
   `meal_plans`, `message_items`, `message_outbox`,
   `message_templates`, `message_threads`, `messaging_providers`,
   `notifications`, `password_reset_requests`, `petty_cash`,
   `pms_settings`, `pos_bill_items`, `pos_bill_payments`,
   `pos_bills`, `pos_menu_items`, `pos_tables`, `rate_guardrails`,
   `rate_plans`, `rate_rules`, `rate_season_rooms`, `rate_seasons`,
   `reconciliation_diffs`, `reconciliation_runs`,
   `report_budgets`, `report_snapshots`, `revenue_categories`,
   `revenues`, `rooms`, `sessions`, `smart_lock_events`,
   `smart_lock_providers`, `sync_revisions`, `tills`, `users`,
   `vouchers`.
   (On an upgrade the server creates the newer tables itself, so an
   existing install ends up with the same 66.)
7. Click the `rooms` table, then Browse. You should see 7 rows:
   Sanctuary floor 1 rate 1190000, Vivid floor 2 rate 1790000,
   Euphoria, Dreamscape, Still, Dune and Blue floors 3 to 7 rate
   1990000 each. If the rooms are there, the import worked.
8. The `users` table is empty at this point. That is correct. The
   chonadmin account is created by the app itself in Step 4, from the
   password you set in Step 3, so no password ever sits in a SQL file.

## Step 2. Upload the app to the subdomain document root

1. In cPanel, open File Manager.
2. Go to the exact folder `/home/certivgm/pms.chonstay.24kgoals.com`.
   This is the document root of the subdomain, not the chonstay folder.
   It should be empty, or hold only what cPanel put there.
3. Click Upload, pick `chon-pms-namecheap.zip`, and wait for the
   upload to finish (the green bar reaches 100 percent).
4. Back in File Manager, right click the zip and click Extract, then
   Extract Files. The files go straight into this folder.
5. After extraction, the folder should contain: `server.js`,
   `package.json`, `package-lock.json`, `schema.sql`, `.env.example`,
   `.gitignore`, `README.md`, `DEPLOY.md`, and a `public` folder with
   `index.html`, `styles-v11-1.css`, `app-v11-1.js`, and a `fonts` folder
   with 6 `.woff2` files. (The frontend files are versioned from v10
   on, so each release is a fresh URL the server cache cannot confuse
   with an old one.)
6. Confirm permissions: files 644, folders 755. In File Manager,
   right click a file, Change Permissions, and check it reads 644.
   Check one folder too, it should read 755. If anything is different,
   fix it there before moving on, because wrong permissions are what
   caused 403 errors on the chonstay site before.
7. You can delete the zip from the server after extracting, to keep
   the folder clean. Keep your copy on your computer.

## Step 3. Create the Node.js app in cPanel

1. In cPanel, open Setup Node.js App (under Software).
2. Click Create Application.
3. Fill in the form exactly like this:
   - Node.js version: 22 (pick the newest 22.x in the list). If 22 is
     not listed, pick 20. Do not pick 18 or older if you can avoid it.
   - Application mode: Production
   - Application root: `/home/certivgm/pms.chonstay.24kgoals.com`
   - Application URL: `pms.chonstay.24kgoals.com` (leave the
     domain as it is, no path after it)
   - Application startup file: `server.js`
   - Passenger log file: leave the default it suggests.
4. Click Create. cPanel creates the app and shows its detail page.
5. On the detail page, find Environment variables and click Add
   Variable for each of these, exactly as written. The two passwords
   are the ones only you hold, type them in, do not paste them
   anywhere else.
   - `DB_HOST` = `localhost`
   - `DB_PORT` = `3306`
   - `DB_USER` = `certivgm_chonpms`
   - `DB_PASSWORD` = your database password for `certivgm_chonpms`
   - `DB_NAME` = `certivgm_chonpms`
   - `CHON_ADMIN_PASSWORD` = your chonadmin password, the same one
     you use in the Muse platform
   Do not set `PORT`. cPanel sets that itself.
6. Click Save, or the button that saves the variables, if there is one.

## Step 4. Install dependencies and start the app

1. Still on the app detail page in Setup Node.js App, click
   Run NPM Install. Wait for it to finish. It installs one package,
   `mysql2`, and takes under a minute. If the button is greyed out,
   click Restart first, then Run NPM Install.
2. Click Restart (or Start, if the app is stopped). The status should
   show the app as running.
3. The first start creates the chonadmin account from the
   `CHON_ADMIN_PASSWORD` you set, and checks the 7 rooms are there.
   This takes a few seconds. If you open the site too fast and see an
   error, wait 10 seconds and refresh.

## Step 5. Test it in Chrome

1. Open https://pms.chonstay.24kgoals.com/ in Chrome.
2. You should see the Chon login page: the wood slat Chon sign,
   "Chốn Boutique Stay", "Property Management System" underneath,
   a card headed "CHỐN PMS" with "Sign in with your role account.",
   a Username field, a Password field, a plum Sign in button, and a
   Forgot password? link underneath. EN / VI toggle at the top right.
3. Log in as `chonadmin` with your chonadmin password. The calendar
   should open, showing the 7 rooms down the left side and 14 days
   across the top, with no bookings yet.
4. Quick checks that prove it works end to end:
   - Click New booking, fill in a guest name and dates, and save it.
     The booking should appear on the calendar, blocking that room.
   - Try to book the same room on overlapping dates. It should be
     refused, with a message that the room is already booked. That is
     the double-booking protection working.
   - Go to Front desk, check the test booking in, then check it out.
     The room should move to Needs cleaning on the Housekeeping board.
   - Delete the test booking from the Bookings list (open it, then
     Cancel booking) when you are done, so the calendar starts clean.
5. Optional, to check the server itself: open
   https://pms.chonstay.24kgoals.com/api/health in Chrome. You should
   see JSON with `"db":"connected"`, `"rooms":7`, `"adminSeeded":true`.
   If it says `"db":"error"`, read the `dbError` text, it names the
   problem, usually a wrong database password or a variable typo.

## Step 6. After it works (optional, recommended)

1. In cPanel Domains, find `pms.chonstay.24kgoals.com` and turn
   Force HTTPS Redirect On, so staff always reach the login over
   HTTPS. Only do this after Step 5 passes, so a redirect cannot hide
   a real error.
2. In the platform, go to Users (admin only) and create a Staff
   account for each person who will use it day to day, so everyone
   logs in with their own username. chonadmin stays the admin.
3. The CHỐN PMS link on the Chon website already points to
   `https://pms.chonstay.24kgoals.com` (updated in the live site
   package v99, Nov 11, 2026). Nothing more to do here.

## If something goes wrong

- The login page loads but login fails with a database error: the
  database variables are wrong. In Setup Node.js App, re-check
  `DB_HOST` (localhost), `DB_USER` (certivgm_chonpms), `DB_NAME`
  (certivgm_chonpms), and retype `DB_PASSWORD`. Then Restart the app.
- The login page shows "No admin account exists yet": the app started
  but `CHON_ADMIN_PASSWORD` was missing or shorter than 8 characters.
  Set it in the environment variables and Restart the app.
- The page shows a Passenger or "Application error" page: open the
  Passenger log file shown on the app detail page, or click the log
  link there. The last lines name the error. Common causes: a typo in
  an environment variable, `npm install` not run yet, or the wrong
  startup file (it must be `server.js`).
- The site is slow on the first visit after a while: normal on shared
  hosting. The app sleeps when idle and wakes on the next visit.
  If it never wakes, Restart it in Setup Node.js App.
- The rooms table is empty after import: you imported into the wrong
  database. Re-import `schema.sql` into `certivgm_chonpms`, then
  Restart the app.

## What is NOT in this deployment

- Two-way OTA sync (pushing availability and rates out to Airbnb,
  Expedia, Booking.com and Agoda through their APIs). The v7
  connectors pull in only: iCal feeds and Beds24 reservations are
  pulled into the PMS and block the room, and an overlapping import
  is logged as a conflict instead of double-booking. Pushing
  availability out through channel APIs is a later phase. What v12
  does add is iCal push: each room publishes its blocked dates on a
  feed URL, which a channel or calendar can subscribe to.
- A real smart lock. Only the 'stub' provider exists in v13,
  lifecycle events are logged with status "no_provider", and the
  stub cannot be enabled. Connect a real lock provider only if
  locks are installed.
- Payment gateway checkout (AsiaPay, PayPal). Beds24 remains the
  fallback for payment. The AsiaPay, MoMo and PayPal cards on the
  Connectors page store config only: their payment pull is not built
  yet. SePay (v9) is the exception: it pulls bank activity into the
  ledger, but it is not a checkout.
- Live Beds24 data until a key is provided: the Beds24 adapter is
  built and verified against mocked responses, but no live API key
  exists yet, so the first real sync with a real key is the live
  check. The same applies to SePay: no live SePay credentials exist
  yet, and the adapter was verified only against mocked responses.
- A direct Techcombank API connector. It waits for Circular 64 full
  compliance, Mar 1, 2027. SePay plus statement import is the
  working route until then.
- AI auto-extraction of receipt contents (n8n reading a receipt
  photo and filling the ledger entry). Receipt upload itself is
  built in v13; extraction is a later add-on needing a VPS for n8n
  plus a Gemini API key, the same stack as the chatbot, which is on
  hold. The ledger is management reporting on the USALI structure,
  not Vietnamese statutory accounting.
- Bookings from the Muse prototype do not carry over. This server
  starts with the 7 rooms and zero bookings.
