/** @odoo-module */ import { patch } from "@web/core/utils/patch"; import { Orderline } from "@point_of_sale/app/components/orderline/orderline"; import { PosOrder } from "@point_of_sale/app/models/pos_order"; patch(Orderline.prototype, { get lineScreenValues() { const res = super.lineScreenValues; // In POS, the internal note (line.note) is typically shown only in display mode. // We override this to also include the parsed internalNote when printing receipts. if (this.props.mode === "receipt" && this.line.note) { try { res.internalNote = JSON.parse(this.line.note); } catch (e) { res.internalNote = [{ text: this.line.note }]; // Fallback if not valid JSON } } return res; } }); patch(PosOrder.prototype, { getCashierName() { const employee = this.employee_id || this.original_employee_id || this.user_id; const name = employee ? (employee.name || "") : ""; if (!name) { return ""; } // Extract prefix if present (e.g. "Served by:", "Order Taker:") let temp = name.trim(); let prefix = ""; const prefixMatch = temp.match(/^(served\s+by:?|order\s+taker:?|kasir:?)\s*/i); if (prefixMatch) { prefix = prefixMatch[0]; temp = temp.substring(prefix.length).trim(); } const parts = temp.split(/\s+/); if (parts.length <= 2) { return name; } return prefix + parts[0] + " " + parts[parts.length - 1]; } });