package models // PosHealth is what a till reports about itself every 30 seconds. // // This is a liveness signal, not a record. It lives in Redis under a TTL and is // never written to Postgres: a terminal that dies simply stops refreshing and // disappears from the board on its own, with no reaper job and no row left // claiming "online" three days after the shop closed. // // The fields exist to answer questions a person actually asks when a shop // phones in: is the till on, is it reaching us, is it selling anything, and is // the hardware in the way. type PosHealth struct { // Identity. Terminalid is the short code printed on invoices — the thing a // support call starts with. Terminalid string `json:"terminal_id"` Locationid string `json:"location_id"` Storename string `json:"store_name"` Appversion string `json:"app_version"` // "online" while the till is refreshing this. The broker's Last Will // overwrites it with "offline" if the terminal loses power mid-shift, which // is the only way to tell *closed for the night* from *unplugged*. Status string `json:"status"` // Queue depth — the number that matters most. A shop quietly accumulating // unsynced takings looks completely normal from the shop floor, and this is // the only thing that makes it visible before someone reconciles a till and // finds a day missing. Pendingbills int `json:"pending_bills"` Pendingregistrations int `json:"pending_registrations"` Oldestpendingat string `json:"oldest_pending_at"` // Today's trading. A till that is connected but has rung nothing in three // hours usually means a jammed printer or an absent cashier, and neither // shows up in a plain online/offline board. Todaybills int `json:"today_bills"` Todayamount float64 `json:"today_amount"` Lastbillat string `json:"last_bill_at"` // Device state, for pre-emptive support. // // Pointers so that *not reported* is distinguishable from *reported as // zero*. Not every build collects these — battery and free storage need // platform packages a desktop till has no use for — and writing an // uncollected reading as 0 would show a board full of terminals on a flat // battery with an unreachable printer. A nil field is skipped entirely. Batterylevel *int `json:"battery_level,omitempty"` Batterycharging *bool `json:"battery_charging,omitempty"` Storagefreemb *int `json:"storage_free_mb,omitempty"` Printerreachable *bool `json:"printer_reachable,omitempty"` Drawerstatus *string `json:"drawer_status,omitempty"` // Stamped by the till. The consumer also stamps its own arrival time, and // the two disagreeing is itself a signal — a till whose clock is wrong // writes bills under the wrong business date. Reportedat string `json:"reported_at"` }