# The back office

The back office is a website for owners and managers, served by the hub on the same address
and port as everything else (for example `http://192.168.1.20:8080`). Use it on a laptop or a
phone to set up a shop, edit the menu and staff, change shop settings, pair and remove devices,
and see sales.

A POS device on its own (single-device mode) has no back office; its owner does all of this in
the app's Settings. Move the shop to a [hub](https://docs.openkedai.com/hub/) to use the back office.

> Status: pre-alpha. In English, Bahasa Melayu and 简体中文: choose a language below the sign-in
> form, or under **Account** once signed in.

## Getting in

There are three ways to sign in for the first time:

- **A new shop.** Open the hub's address in a browser and choose **Set up a new shop**. The
  wizard asks for the hub's setup code (printed in the hub's log when it starts, or set with
  `OPENKEDAI_SETUP_CODE`), then the shop's name, SST registration and service charge, your name
  and POS PIN, and an email and password. It ends on the pairing page, ready for the first POS
  device.
- **A shop moved to the hub from its POS device.** On that device, signed in as an owner or
  manager, go to **Settings → Hub → Back office → Get a sign-in code**. In the browser, choose
  **I have a code from the POS**, enter the code, and choose an email and password. The code
  works once, for 30 minutes.
- **A manager.** An owner opens **Staff**, picks the manager and sets an email and password for
  them.

**Forgot your password?** Get a new code from a POS device as above. It sets a new password and
signs you out everywhere else.

One account can run several shops on the same hub: **Account → Add another shop** runs the
wizard again, and **Switch shop** moves between them.

Only owners and managers can sign in. Making someone a cashier, or removing them from the staff,
closes the back office for them at once.

## What's in it

| Page | |
| --- | --- |
| **Reports** | Sales for a day or a period: totals, average order, by payment (including plugin payment types), by order type, SST by code, by item, by day. CSV exports of orders, items sold, and payments with refunds |
| **Shifts** | Every device's shifts, newest first, with each X- or Z-report: sales, payments, cash drawer, counted cash and the difference |
| **Menu** | Items with price, tax code, category, service charge, kitchen printing and modifier groups; categories with colours; modifier groups and their prices |
| **Staff** | Names, roles and POS PINs; who can sign in to the back office |
| **Shop settings** | Name, receipt code, address, SST number, menu prices with or without tax (per order type), service charge, cash rounding, blind close, receipt header and footer, receipt and kitchen ticket languages, DuitNow QR image |
| **Devices** | Pair a device with a QR code or a code, rename devices, remove a device |
| **Plugins** | Installed plugins, their settings, and a way past an event a plugin keeps failing on |

Changes to the menu, staff and settings reach every device at once, or as soon as it's back
online. Reports are worked out from the shop's sales as stored on the hub, so a device that is
offline shows up once it has synced. A sale counts on the day it was closed on its device, by
that device's clock.

Deleting a menu item, category or modifier group hides it; past receipts keep their own copy of
names and prices.

## Languages

The back office speaks English, Bahasa Melayu and 简体中文. Choose yours under **Language** on the
sign-in page or on **Account**; it changes at once and is remembered in that browser. Each POS
device chooses its own language too, on the PIN pad or in **Settings → Language**.

What prints is set for the whole shop in **Shop settings → Receipt**:

- **Receipt language:** the language receipts print in.
- **Second language:** optional. Labels such as Total then print in both languages ("Total /
  Jumlah"), and so do labels before a value ("Receipt / Resit K1-0042"). Tax lines, which
  hold several numbers, stay in the first language.
- **Kitchen ticket language:** for the kitchen; by default the same as receipts.

Item names print as you typed them. To show a dish in two languages, put both in its name, for
example "Char Kuey Teow 炒粿条".

## Removing a device

On **Devices**, pick the device and choose **Remove**, or on another POS device go to
**Settings → Hub → Devices**. The device stops syncing at once and shows **Removed from hub**.
It keeps selling on its own, and its sales wait on it. To bring it back, give it a new pairing
code: on the removed device, **Settings → Hub** asks for one. Its waiting sales go up to the hub
then.

A device can't remove itself, so a shop never locks itself out by accident.

## Security

- Passwords are at least 8 characters and are stored only as a hash (scrypt).
- Signing in sets a cookie that lasts 30 days from last use. Signing out, or changing the
  password, ends it.
- Too many wrong passwords or codes from one address, or for one email, are refused for a while.
- On a shop network without HTTPS, anyone on the same network could watch the traffic. To use
  the back office over the internet, put HTTPS in front of the hub (see [Running a hub](https://docs.openkedai.com/hub/)).
