Skip to content

Commit 6124eea

Browse files
committed
[ADD] pos_customer_display: enhance pos customer display
- added customer name in customer display. - display amount per guest in customer display. - added refund items subsection.
1 parent fbf9ee9 commit 6124eea

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "POS Customer Display",
3+
"version": "1.0",
4+
"summary": """Improve customer's display to show customer name, amount, number of guest and segregate refund section""",
5+
"depends": ["base", "point_of_sale"],
6+
"category": "Point of Sale",
7+
"assets": {
8+
"point_of_sale.customer_display_assets": [
9+
"pos_customer_display/static/src/js/customer_display_extend.xml"
10+
],
11+
"point_of_sale.assets_prod": [
12+
"pos_customer_display/static/src/js/customer_display_extend.js"
13+
],
14+
},
15+
"installable": True,
16+
"application": False,
17+
"license": "LGPL-3"
18+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { patch } from "@web/core/utils/patch";
2+
import { PosOrder } from "@point_of_sale/app/models/pos_order";
3+
4+
patch(PosOrder.prototype, {
5+
getCustomerDisplayData() {
6+
const orderlines = this.getSortedOrderlines();
7+
8+
const activeItems = [];
9+
const refundedItems = [];
10+
for (const line of orderlines) {
11+
if (line.refunded_orderline_id) {
12+
refundedItems.push(line.getDisplayData());
13+
} else {
14+
activeItems.push(line.getDisplayData());
15+
}
16+
}
17+
18+
const guests = Math.max(this.guest_count || 0, 0);
19+
const totalWithTax = this.get_total_with_tax();
20+
const amountPerGuest = guests > 0 ? totalWithTax / guests : null;
21+
22+
return {
23+
...super.getCustomerDisplayData(),
24+
25+
customerName: this.get_partner_name() || "Guest",
26+
amountPerGuest,
27+
activeItems,
28+
refundedItems,
29+
};
30+
},
31+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<templates id="template" xml:space="preserve">
3+
<t t-name="pos_customer.CustomerDisplay" t-inherit="point_of_sale.CustomerDisplay" t-inherit-mode="extension">
4+
<xpath expr="//div[@t-if='order.amount and !order.finalized']" position="inside">
5+
<div class="d-flex flex-column justify-content-center gap-1 w-100 w-sm-50 ms-auto">
6+
<div class="row fw-bolder">
7+
<div class="col text-end">Customer</div>
8+
<div class="col text-end" t-out="order.displayCustomerName"/>
9+
</div>
10+
<t t-if="order.amountDividedPerGuest">
11+
<div class="row fw-bolder">
12+
<div class="col text-end">Amount</div>
13+
<div class="col text-end" t-out="format_float(order.amountDividedPerGuest, 2)"/> / Guest
14+
</div>
15+
</t>
16+
</div>
17+
</xpath>
18+
19+
<xpath expr="//div[hasclass('o_customer_display_main')]/OrderWidget" position="replace">
20+
<OrderWidget t-if="!order.finalized" lines="order.activeItems"/>
21+
22+
<t t-if="order.refundedItems">
23+
<div class="mt-3 p-2 fw-bold">Refunded Items</div>
24+
<OrderWidget t-if="!order.finalized" lines="order.refundedItems"/>
25+
</t>
26+
</xpath>
27+
</t>
28+
</templates>

0 commit comments

Comments
 (0)