feat: add support for reprint labels and multi-line internal/customer notes in kitchen receipts
This commit is contained in:
parent
d2325ef723
commit
be9a402e4f
@ -77,9 +77,17 @@ class PosPrinter(models.Model):
|
|||||||
ALIGN_LEFT = ESC + b'a\x00'
|
ALIGN_LEFT = ESC + b'a\x00'
|
||||||
NEWLINE = b'\n'
|
NEWLINE = b'\n'
|
||||||
|
|
||||||
|
title = receipt_data.get('title', '')
|
||||||
|
reprint = receipt_data.get('reprint', False)
|
||||||
|
header = "KITCHEN RECEIPT"
|
||||||
|
if title:
|
||||||
|
header += f" - {title}"
|
||||||
|
if reprint:
|
||||||
|
header += " (DUPLICATE !)"
|
||||||
|
|
||||||
data = INIT
|
data = INIT
|
||||||
data += ALIGN_CENTER + SIZE_NORMAL + BOLD_ON
|
data += ALIGN_CENTER + SIZE_NORMAL + BOLD_ON
|
||||||
data += b"KITCHEN RECEIPT" + NEWLINE
|
data += f"{header}".encode('utf-8') + NEWLINE
|
||||||
data += SIZE_NORMAL + BOLD_OFF + NEWLINE
|
data += SIZE_NORMAL + BOLD_OFF + NEWLINE
|
||||||
|
|
||||||
if receipt_data.get('table'):
|
if receipt_data.get('table'):
|
||||||
@ -103,10 +111,30 @@ class PosPrinter(models.Model):
|
|||||||
data += f"{qty} x {name}".encode('utf-8') + NEWLINE
|
data += f"{qty} x {name}".encode('utf-8') + NEWLINE
|
||||||
data += SIZE_NORMAL
|
data += SIZE_NORMAL
|
||||||
if note:
|
if note:
|
||||||
data += f" NOTE: {note}".encode('utf-8') + NEWLINE
|
for note_line in note.split('\n'):
|
||||||
|
if note_line.strip():
|
||||||
|
data += f" NOTE: {note_line.strip()}".encode('utf-8') + NEWLINE
|
||||||
|
|
||||||
data += NEWLINE
|
data += NEWLINE
|
||||||
|
|
||||||
|
internal_note = receipt_data.get('internal_note')
|
||||||
|
general_customer_note = receipt_data.get('general_customer_note')
|
||||||
|
|
||||||
|
if internal_note or general_customer_note:
|
||||||
|
data += b"-" * 32 + NEWLINE
|
||||||
|
if internal_note:
|
||||||
|
data += BOLD_ON + b"INTERNAL NOTE:" + BOLD_OFF + NEWLINE
|
||||||
|
for note_line in internal_note.split('\n'):
|
||||||
|
if note_line.strip():
|
||||||
|
data += f" {note_line.strip()}".encode('utf-8') + NEWLINE
|
||||||
|
data += NEWLINE
|
||||||
|
if general_customer_note:
|
||||||
|
data += BOLD_ON + b"CUSTOMER NOTE:" + BOLD_OFF + NEWLINE
|
||||||
|
for note_line in general_customer_note.split('\n'):
|
||||||
|
if note_line.strip():
|
||||||
|
data += f" {note_line.strip()}".encode('utf-8') + NEWLINE
|
||||||
|
data += NEWLINE
|
||||||
|
|
||||||
data += b"-" * 32 + NEWLINE + NEWLINE + NEWLINE + CUT
|
data += b"-" * 32 + NEWLINE + NEWLINE + NEWLINE + CUT
|
||||||
|
|
||||||
# Start thread
|
# Start thread
|
||||||
|
|||||||
@ -54,11 +54,15 @@ patch(PosStore.prototype, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const receipt_data = {
|
const receipt_data = {
|
||||||
|
title: data.changes?.title || '',
|
||||||
|
reprint: data.reprint || false,
|
||||||
order_name: data.name || '',
|
order_name: data.name || '',
|
||||||
order_time: (typeof data.time === 'string' ? data.time : data.time?.raw) || new Date().toISOString(),
|
order_time: (typeof data.time === 'string' ? data.time : data.time?.raw) || new Date().toISOString(),
|
||||||
waiter: data.cashier || '',
|
waiter: data.cashier || '',
|
||||||
table: data.table_name || '',
|
table: data.table_name || '',
|
||||||
lines: lines
|
lines: lines,
|
||||||
|
internal_note: data.internal_note || '',
|
||||||
|
general_customer_note: data.general_customer_note || ''
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user