Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions pos_customer_display/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "POS Customer Display",
"version": "1.0",
"summary": """Improve customer's display to show customer name, amount, number of guest and segregate refund section""",
"depends": ["base", "point_of_sale"],
"category": "Point of Sale",
"assets": {
"point_of_sale.customer_display_assets": [
"pos_customer_display/static/src/js/customer_display_extend.xml"
],
"point_of_sale.assets_prod": [
"pos_customer_display/static/src/js/customer_display_extend.js"
],
},
"installable": True,
"application": False,
"license": "LGPL-3"
}
31 changes: 31 additions & 0 deletions pos_customer_display/static/src/js/customer_display_extend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { patch } from "@web/core/utils/patch";
import { PosOrder } from "@point_of_sale/app/models/pos_order";

patch(PosOrder.prototype, {
getCustomerDisplayData() {
const orderlines = this.getSortedOrderlines();

const activeItems = [];
const refundedItems = [];
for (const line of orderlines) {
if (line.refunded_orderline_id) {
refundedItems.push(line.getDisplayData());
} else {
activeItems.push(line.getDisplayData());
}
}

const guests = Math.max(this.guest_count || 0, 0);
const totalWithTax = this.get_total_with_tax();
const amountPerGuest = guests > 0 ? totalWithTax / guests : null;

return {
...super.getCustomerDisplayData(),

customerName: this.get_partner_name() || "Guest",
amountPerGuest,
activeItems,
refundedItems,
};
},
});
28 changes: 28 additions & 0 deletions pos_customer_display/static/src/js/customer_display_extend.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="pos_customer.CustomerDisplay" t-inherit="point_of_sale.CustomerDisplay" t-inherit-mode="extension">
<xpath expr="//div[@t-if='order.amount and !order.finalized']" position="inside">
<div class="d-flex flex-column justify-content-center gap-1 w-100 w-sm-50 ms-auto">
<div class="row fw-bolder">
<div class="col text-end">Customer</div>
<div class="col text-end" t-out="order.customerName"/>
</div>
<t t-if="order.amountDividedPerGuest">
<div class="row fw-bolder">
<div class="col text-end">Amount</div>
<div class="col text-end" t-out="format_float(order.amountDividedPerGuest, 2)"/> / Guest
</div>
</t>
</div>
</xpath>

<xpath expr="//div[hasclass('o_customer_display_main')]/OrderWidget" position="replace">
<OrderWidget t-if="!order.finalized" lines="order.activeItems"/>

<t t-if="order.refundedItems">
<div class="mt-3 p-2 fw-bold">Refunded Items</div>
<OrderWidget t-if="!order.finalized" lines="order.refundedItems"/>
</t>
</xpath>
</t>
</templates>