fix: ensure consistent receipt data parsing and include order notes in all print modes
This commit is contained in:
parent
fa2f72cf61
commit
ac9b328e51
@ -123,6 +123,13 @@ patch(PosPrinterService.prototype, {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (order) {
|
||||||
|
this._currentPrintOrder = order;
|
||||||
|
}
|
||||||
|
if (printType === 'CHECKER') {
|
||||||
|
this._currentPrintBasic = true;
|
||||||
|
}
|
||||||
|
|
||||||
this._isCashPayment = printType === 'PAYMENT' && order && (typeof order.isPaidWithCash === 'function' ? order.isPaidWithCash() : false);
|
this._isCashPayment = printType === 'PAYMENT' && order && (typeof order.isPaidWithCash === 'function' ? order.isPaidWithCash() : false);
|
||||||
console.log(`[BluetoothPrint] printHtml context check - printType: ${printType}, order: ${order?.pos_reference}, resolved isCashPayment: ${this._isCashPayment}`);
|
console.log(`[BluetoothPrint] printHtml context check - printType: ${printType}, order: ${order?.pos_reference}, resolved isCashPayment: ${this._isCashPayment}`);
|
||||||
|
|
||||||
@ -552,13 +559,12 @@ patch(PosPrinterService.prototype, {
|
|||||||
// Prefer direct model data over HTML parsing — HTML parsing fails in basic_receipt mode
|
// Prefer direct model data over HTML parsing — HTML parsing fails in basic_receipt mode
|
||||||
// because prices and totals are not rendered in the DOM when basic_receipt=true.
|
// because prices and totals are not rendered in the DOM when basic_receipt=true.
|
||||||
let receiptData;
|
let receiptData;
|
||||||
const isKitchenReceipt = !!el.querySelector('.new-changes, .preset-name, .o-employee-name, .order-ref-prefix');
|
|
||||||
|
|
||||||
if (this._currentPrintOrder && !isKitchenReceipt) {
|
if (this._currentPrintOrder) {
|
||||||
console.log('[BluetoothPrint] Building receipt data from POS order model (accurate)...');
|
console.log('[BluetoothPrint] Building receipt data from POS order model (accurate)...');
|
||||||
receiptData = this._buildReceiptDataFromOrder(this._currentPrintOrder);
|
receiptData = this._buildReceiptDataFromOrder(this._currentPrintOrder);
|
||||||
} else {
|
} else {
|
||||||
console.log('[BluetoothPrint] Kitchen receipt or no order captured, parsing HTML...');
|
console.log('[BluetoothPrint] No order captured, parsing HTML...');
|
||||||
receiptData = this._parseReceiptDataFromHtml(el);
|
receiptData = this._parseReceiptDataFromHtml(el);
|
||||||
}
|
}
|
||||||
console.log('[BluetoothPrint] Receipt data:', JSON.stringify(receiptData, null, 2));
|
console.log('[BluetoothPrint] Receipt data:', JSON.stringify(receiptData, null, 2));
|
||||||
@ -794,8 +800,8 @@ patch(PosPrinterService.prototype, {
|
|||||||
cashier: formatFirstLastName((typeof order.getCashierName === 'function' ? order.getCashierName() : '') || ''),
|
cashier: formatFirstLastName((typeof order.getCashierName === 'function' ? order.getCashierName() : '') || ''),
|
||||||
customer: order.partner_id?.name || null,
|
customer: order.partner_id?.name || null,
|
||||||
tableName,
|
tableName,
|
||||||
internalNote: isBasic ? (pos?.getStrNotes ? pos.getStrNotes(order.internal_note || '[]') : (typeof order.internal_note === 'string' ? order.internal_note : '')) : '',
|
internalNote: pos?.getStrNotes ? pos.getStrNotes(order.internal_note || '[]') : (typeof order.internal_note === 'string' ? order.internal_note : ''),
|
||||||
customerNote: isBasic ? (order.general_customer_note || '') : '',
|
customerNote: order.general_customer_note || '',
|
||||||
};
|
};
|
||||||
|
|
||||||
// ── Order lines ────────────────────────────────────────────────────────
|
// ── Order lines ────────────────────────────────────────────────────────
|
||||||
@ -826,9 +832,8 @@ patch(PosPrinterService.prototype, {
|
|||||||
? line.displayPriceUnit
|
? line.displayPriceUnit
|
||||||
: (qty !== 0 ? lineTotal / qty : line.price_unit || 0);
|
: (qty !== 0 ? lineTotal / qty : line.price_unit || 0);
|
||||||
|
|
||||||
// Construct combined line note if basic receipt, else empty string
|
// Construct combined line note
|
||||||
let note = '';
|
let note = '';
|
||||||
if (isBasic) {
|
|
||||||
const noteParts = [];
|
const noteParts = [];
|
||||||
const customerNote = line.customer_note || line.customerNote || '';
|
const customerNote = line.customer_note || line.customerNote || '';
|
||||||
if (customerNote) {
|
if (customerNote) {
|
||||||
@ -841,7 +846,6 @@ patch(PosPrinterService.prototype, {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
note = noteParts.join(' | ');
|
note = noteParts.join(' | ');
|
||||||
}
|
|
||||||
|
|
||||||
// Find combo sub-lines linked to this line
|
// Find combo sub-lines linked to this line
|
||||||
const comboSubLines = orderlines
|
const comboSubLines = orderlines
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user