feat: include customer and kitchen notes in receipt lines and add basic receipt flag to export data

This commit is contained in:
Suherdy Yacob 2026-05-29 10:58:38 +07:00
parent d3a3633359
commit 8a33de6916

View File

@ -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;
},