OpenSaleTabs
OpenSaleTabs shows the till's open sales as cart tabs, one cell per sale with who and the total or a partly paid chip, plus a + cell for a new sale.
Import
import { OpenSaleTabs } from '@tallyui/components';Usage
import { openSales, useParkedSales, useSale } from '@tallyui/pos';
import { OpenSaleTabs } from '@tallyui/components';
// Inside a component under TaxProvider; switchSale needs the drafts option.
const sale = useSale(settings, { registerId, cashierRef, drafts });
const { parked } = useParkedSales(drafts);
<OpenSaleTabs
sales={openSales(sale.order, parked)}
currency={settings.currency}
onSelect={(id) => void sale.switchSale(id).then(showRefusal)}
onNew={() => void sale.switchSale(null).then(showRefusal)}
/>Renders a horizontal strip with one tab per open sale: the current sale and each parked draft. A tab reads who the sale is for: the customer's name, or for a guest Guest · and the single item's name or the item count (an empty guest sale reads Guest). Under it is the sale's total, or, once a leg took money and a balance is still due, Partly paid · {amount} due. On tabs other than the current one that line is a chip; the current tab keeps it as plain muted text. The current tab is underlined, even when it is the only one.
A parked sale that has waited an hour or more adds its age after the total, in hours and in the warning colour ($16.83 · 5 h); the age updates once a minute.
The + cell at the end opens a new sale. A blank cart is no tab, so while the till is on one the + cell is its tab: it is underlined, reads New, and pressing it does nothing.
On the web, ← and → step between the tabs, and from the last sale onto New, as v2.
Open sales
openSales(order, parked) from @tallyui/pos builds the sales prop. It merges the current sale, when it has lines, fees or shipping, with the parked summaries from useParkedSales(drafts), skipping a draft that has the current sale's id. Tabs are sorted by id with numeric collation, so a tab keeps its place across switches. Each entry carries id, customerName, itemCount, firstItem, totalMinor, paidMinor, balanceDueMinor, parkedAt and current.
useSale has two methods for the tabs:
switchSale(draftId)parks the current sale when it has lines, fees or shipping, then opens the parked draftdraftId, or an empty sale fornull. It resolves tonull, or a refusal message, and changes nothing when refused: while the sale is saving, for a partly paid sale (SALE_PARTLY_PAID), with a payment in motion, or in the tender stage (SALE_IN_TENDER). A finished sale on its receipt is not parked. It throws whenuseSalewas given nodraftscollection.closeSale()discards the current sale without parking it and starts an empty one. It returnsnull, or a refusal: while saving, when a leg of an unfinished sale took or holds money, or in the tender stage.
A parked draft whose legs took money keeps the prices it was paid against when it is resumed.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
sales | OpenSale[] | required | The open sales, from openSales(sale.order, parked) |
currency | string | required | Currency used to format totals and the balance due |
onSelect | (id: string) => void | required | Called with a tab's sale id when it is pressed; call sale.switchSale(id) |
onNew | () => void | required | Called when + is pressed while the till is not on a blank cart; call sale.switchSale(null) |
className | string | — | Classes merged onto the bar's root, so an app can restyle it; at the top of the cart, for example border-t-0 border-b |
SalesCardPanel
SalesCardPanel opens a Sales room card's figure in full as a side panel, with a total row, a status line, Close and an optional Export CSV.
CustomerDisplayScreen
CustomerDisplayScreen is what the customer sees in a second window on the same device, the store's welcome, the cart with its totals, or the payment card.