feat: include customer and kitchen notes in receipt lines and add basic receipt flag to export data
This commit is contained in:
parent
d3a3633359
commit
8a33de6916
@ -64,9 +64,12 @@ patch(PosPrinterService.prototype, {
|
|||||||
// Capture the order object from props before rendering to HTML
|
// Capture the order object from props before rendering to HTML
|
||||||
if (props && props.order) {
|
if (props && props.order) {
|
||||||
this._currentPrintOrder = 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 {
|
} else {
|
||||||
this._currentPrintOrder = null;
|
this._currentPrintOrder = null;
|
||||||
|
this._currentPrintBasic = false;
|
||||||
}
|
}
|
||||||
// Call the parent chain (PosPrinterService.print → PrinterService.print)
|
// Call the parent chain (PosPrinterService.print → PrinterService.print)
|
||||||
// which renders the component to HTML then calls this.printHtml(el)
|
// which renders the component to HTML then calls this.printHtml(el)
|
||||||
@ -687,11 +690,34 @@ patch(PosPrinterService.prototype, {
|
|||||||
? line.displayPriceUnit
|
? line.displayPriceUnit
|
||||||
: (qty !== 0 ? lineTotal / qty : line.price_unit || 0);
|
: (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 {
|
return {
|
||||||
productName: line.full_product_name || line.product_id?.display_name || '',
|
productName: line.full_product_name || line.product_id?.display_name || '',
|
||||||
quantity: qty,
|
quantity: qty,
|
||||||
price: unitPrice,
|
price: unitPrice,
|
||||||
total: lineTotal
|
total: lineTotal,
|
||||||
|
note,
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.filter(l => l.productName);
|
.filter(l => l.productName);
|
||||||
@ -728,7 +754,15 @@ patch(PosPrinterService.prototype, {
|
|||||||
barcode: orderData.orderName || null
|
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);
|
console.log('[BluetoothPrint] Built receipt data from model:', receiptData);
|
||||||
return receiptData;
|
return receiptData;
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user