feat(terminal): quick sale at the counter: cash/card/split, change, cash drawer, fiscal (platform-v2 3.3b)
- POST /api/pos/sales: all checks first (shift, lines, payment split, cash given, discount → ordering.prices.modify or manager approval, fiscal VAT groups), then the existing open_order / add_items / pay_items functions, so tickets, KDS, price events, shift totals and the fiscal receipt work as for any order. - Cash drawer: printer_service.open_cash_drawer (ESC @ + ESC p 0 25 250) to the screen's receipt printer on cash, logged and audited (DRAWER_OPENED / DRAWER_FAILED). - orders._can_access_order: the people assigned to an order may act on it (a cashier's own takeaway order); pos_cart prices a batch with the lines before it, as add_items does. - Terminal: Charge → payment dialog (exact cash pre-selected, quick amounts, change, card, split by line), per-line discounts, sale summary and "Same again". - Tests: backend +6 (socket printer receives the drawer kick, fiscal file in the bridge folder), terminal unit +1, terminal.mjs +9. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -324,6 +324,27 @@ def send_test_beep(ip: str, port: int, n1: int, n2: int, n3: int, codepage_n: in
|
||||
return False, str(e)
|
||||
|
||||
|
||||
DRAWER_KICK = bytes([0x1b, 0x70, 0x00, 0x19, 0xfa]) # ESC p m t1 t2: pin 2, 50 ms on, 500 ms off
|
||||
|
||||
|
||||
def open_cash_drawer(printer, db: Session, reason: str = "") -> Tuple[bool, str]:
|
||||
"""Pulse the cash drawer wired to `printer` (counter POS cash payments, plan step 3.3b).
|
||||
A job of its own: ESC @ then ESC p 0 25 250, nothing printed. Logs one line either way.
|
||||
Spoof printing drops it like any print. -> (ok, error)"""
|
||||
if _is_spoof_mode(db):
|
||||
logger.info("Cash drawer: spoof printing ON, not sent to %s (%s)", printer.name, reason)
|
||||
return True, ""
|
||||
try:
|
||||
p = Network(printer.ip_address, printer.port, timeout=PRINTER_TIMEOUT)
|
||||
p._raw(bytes([0x1b, 0x40]) + DRAWER_KICK)
|
||||
p.close()
|
||||
logger.info("Cash drawer: opened on %s (%s:%s) %s", printer.name, printer.ip_address, printer.port, reason)
|
||||
return True, ""
|
||||
except Exception as e:
|
||||
logger.warning("Cash drawer: FAILED on %s (%s:%s) %s: %s", printer.name, printer.ip_address, printer.port, reason, e)
|
||||
return False, str(e)
|
||||
|
||||
|
||||
def send_test_print(ip: str, port: int, name: str, codepage_n: int = 29) -> Tuple[bool, str]:
|
||||
if is_spoof_mode():
|
||||
logger.info("Spoof printing ON — dropping test print for %s", name)
|
||||
|
||||
Reference in New Issue
Block a user