From 8a33de69163845e5e5b7907b9b6d764302f5f36e Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Fri, 29 May 2026 10:58:38 +0700 Subject: [PATCH] feat: include customer and kitchen notes in receipt lines and add basic receipt flag to export data --- static/src/js/pos_receipt_printer.js | 40 +++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/static/src/js/pos_receipt_printer.js b/static/src/js/pos_receipt_printer.js index fd51950..0e03aaa 100755 --- a/static/src/js/pos_receipt_printer.js +++ b/static/src/js/pos_receipt_printer.js @@ -64,9 +64,12 @@ patch(PosPrinterService.prototype, { // Capture the order object from props before rendering to HTML if (props && props.order) { this._currentPrintOrder = props.order; - console.log('[BluetoothPrint] print() called, captured order:', props.order?.pos_reference); + this._currentPrintBasic = !!props.basic_receipt; + console.log('[BluetoothPrint] print() called, captured order:', props.order?.pos_reference, + '| basic_receipt:', this._currentPrintBasic); } else { this._currentPrintOrder = null; + this._currentPrintBasic = false; } // Call the parent chain (PosPrinterService.print → PrinterService.print) // which renders the component to HTML then calls this.printHtml(el) @@ -687,11 +690,34 @@ patch(PosPrinterService.prototype, { ? line.displayPriceUnit : (qty !== 0 ? lineTotal / qty : line.price_unit || 0); + // Customer-facing note (always shown, even on basic receipt) + const customerNote = line.customer_note || ''; + + // Kitchen/internal note — stored as JSON string: [{text:"..."},…] + // pos_custom_receipt reads this as internalNote for display + let kitchenNote = ''; + if (line.note) { + try { + const tags = JSON.parse(line.note); + if (Array.isArray(tags)) { + kitchenNote = tags.map(t => t.text || '').filter(Boolean).join(', '); + } else { + kitchenNote = String(line.note); + } + } catch (_) { + kitchenNote = String(line.note); + } + } + + // Combine notes (customer note takes priority; show both if both exist) + const note = [customerNote, kitchenNote].filter(Boolean).join(' | '); + return { productName: line.full_product_name || line.product_id?.display_name || '', quantity: qty, price: unitPrice, - total: lineTotal + total: lineTotal, + note, }; }) .filter(l => l.productName); @@ -728,7 +754,15 @@ patch(PosPrinterService.prototype, { barcode: orderData.orderName || null }; - const receiptData = { headerData, orderData, lines, totals, paymentData, footerData }; + const receiptData = { + headerData, + orderData, + lines, + totals, + paymentData, + footerData, + isBasicReceipt: !!this._currentPrintBasic, + }; console.log('[BluetoothPrint] Built receipt data from model:', receiptData); return receiptData; },