TenderPane
TenderPane is the tender pane for a host that owns the tender reducer, with the balance headline, payment legs, method tiles, keypad, quick-cash chips, Take and Complete sale.
Import
import { TenderPane } from '@tallyui/components';Usage
import { useReducer } from 'react';
import { initTenderState, tenderReducer, useSale } from '@tallyui/pos';
import { TenderPane } from '@tallyui/components';
// Inside a component under TaxProvider, while sale.stage.kind is 'tender'.
const sale = useSale(settings, { registerId, cashierRef });
const [state, dispatch] = useReducer(tenderReducer, { methodId: 'cash', balanceMinor: sale.order.balanceDueMinor }, initTenderState);
<TenderPane sale={sale} state={state} dispatch={dispatch} />TenderPane is the pane inside Tender, laid out as WCPOS v2's. Use Tender unless the host keeps the tender reducer itself. It renders nothing outside the tender stage.
The headline's caption reads To pay, or Remaining once money is paid (pending legs never count). The balance sits beside it when it differs from the entry, and the entry is the large figure underneath. Under the caption are the amount paid so far and any change. Each payment leg shows its method, amount and status, and a leg the till took shows the time it was taken; Paid in full names the time of the last payment. The next pending leg is marked Next, and Cancel payment shows where the method can void the leg.
Pass ledger={false} when the host shows the legs in the cart column with Cart's tenderLedger, as WCPOS v2 does.
While a balance remains, the cashier picks Cash or Card terminal and sets the entry on the keypad, where digits shift in from the right, or, for cash, with a quick-cash chip: the exact amount, then the next 5, 10 and 50. A method that gives no change, such as Card terminal, gets one Full balance chip instead, which sets the entry to the amount due (Exact while a split plan is active). A chip or a keypad press only sets the entry. A hint under it reads the change, what is left after a part payment, or that the method can't give change. Take {amount} in {method} records the leg with sale.addTender, and the entry is pre-typed with the next leg's amount. Card terminal also takes a terminal reference.
While something is due, Split on the headline shows Split the rest with 2 to 6 equal ways; after a typed amount, the ways divide what is left after this payment. A way sets the plan and the entry is pre-typed with each share. A method tile keeps the share that is due, and pressing Split again clears the plan.
Complete sale is enabled once nothing is due and no leg is in motion, and calls sale.complete. Back calls sale.cancelTender. The sale's error and its Continue control show as the sale state requires.
A held leg, one taken before the sale was reopened or one the store or a closed register's closure already holds, shows no Cancel payment, no Remove payment and no terminal reference input.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
sale | ReturnType<typeof useSale> | required | The sale from useSale |
state | TenderState | required | The tender reducer's state, from tenderReducer in @tallyui/pos |
dispatch | (action: TenderAction) => void | required | The reducer's dispatch; the pane sends method picks, keypad keys, entries and recorded legs |
methods | PaymentMethodDescriptor[] | defaultPaymentMethods() | The methods offered: each manual-capture descriptor gets a tile and records its wire method (cash or external) plus its own id as methodId; other capture modes are not shown |
ledger | boolean | true | Draws the payments ledger in the pane; pass false when Cart's tenderLedger shows it in the cart column |
back | boolean | true | Draws the Back button (sale.cancelTender); pass false when the host leaves the tender stage itself, as WCPOS v2's phone checkout does |
confirmVoid | boolean | false | WCPOS v2's "Cancel this payment?" before a leg is voided: Cancel payment opens a question with the leg's amount ("Return €10.00 cash to the customer" for cash, else "Void €15.00 on Card terminal"), and the leg is voided only on confirm. Default off: Cancel payment voids at once |