Debian Codegraph @

addons/point_of_sale/static/tests/pos/tours/pricelist_tour.js

raw symbols SCIP
1 /* global posmodel */
2
3 import { registry } from "@web/core/registry";
4 import * as ProductScreen from "@point_of_sale/../tests/pos/tours/utils/product_screen_util";
5 import * as Numpad from "@point_of_sale/../tests/generic_helpers/numpad_util";
6 import * as Order from "@point_of_sale/../tests/generic_helpers/order_widget_util";
7 import * as Dialog from "@point_of_sale/../tests/generic_helpers/dialog_util";
8 import * as Pricelist from "@point_of_sale/../tests/pos/tours/utils/pricelist_util";
9 import * as Chrome from "@point_of_sale/../tests/pos/tours/utils/chrome_util";
10 import * as OfflineUtil from "@point_of_sale/../tests/generic_helpers/offline_util";
11 import * as ProductConfigurator from "@point_of_sale/../tests/pos/tours/utils/product_configurator_util";
12 import * as PaymentScreen from "@point_of_sale/../tests/pos/tours/utils/payment_screen_util";
13 import * as ReceiptScreen from "@point_of_sale/../tests/pos/tours/utils/receipt_screen_util";
14 import { refresh, scan_barcode } from "@point_of_sale/../tests/generic_helpers/utils";
15
16 registry.category("web_tour.tours").add("pos_pricelist", {
17 steps: () =>
18 [
19 Chrome.startPoS(),
20 Pricelist.setUp(),
21 Pricelist.waitForUnitTest(),
22 Dialog.confirm("Open Register"),
23 OfflineUtil.setOfflineMode(),
24 ProductScreen.clickPriceList("Fixed", true, "Public Pricelist"),
25 ProductScreen.clickPartnerButton(),
26 ProductScreen.clickCustomer("Acme Corporation"),
27 ProductScreen.clickPriceList("Public Pricelist", true),
28 ProductScreen.clickPartnerButton(),
29 ProductScreen.clickCustomer("Lumber Inc"),
30 ProductScreen.clickPriceList("Public Pricelist", true),
31 ProductScreen.clickDisplayedProduct("Wall Shelf", true, "1"),
32 ProductScreen.clickPriceList("min_quantity ordering"),
33 ProductScreen.clickReview(),
34 { ...ProductScreen.clickLine("Wall Shelf")[0], isActive: ["mobile"] },
35 Numpad.click("2"),
36 ...ProductScreen.selectedOrderlineHasDirect("Wall Shelf", "2"),
37 { ...ProductScreen.back(), isActive: ["mobile"] },
38 ...Order.hasTotal(`$ 2.00`),
39 ProductScreen.clickDisplayedProduct("Small Shelf", true, "1"),
40 ProductScreen.clickReview(),
41 { ...ProductScreen.clickLine("Small Shelf")[0], isActive: ["mobile"] },
42 Numpad.click("Price"),
43 Numpad.isActive("Price"),
44 Numpad.click("5"),
45 ...Order.hasLine({ productName: "Small Shelf", price: "5.0", withClass: ".selected" }),
46 Numpad.click("Qty"),
47 Numpad.isActive("Qty"),
48 { ...ProductScreen.back(), isActive: ["mobile"] },
49 ProductScreen.clickPriceList("Public Pricelist"),
50 ...Order.hasTotal(`$ 8.96`),
51 ProductScreen.clickPriceList("min_quantity ordering"),
52 OfflineUtil.setOnlineMode(),
53 ProductScreen.closePos(),
54 ].flat(),
55 });
56
57 // # With test_pricelist set on the order:
58 // # - First banana variant will be priced at 100 via product variant
59 // # - Second banana variant will be priced at 150 via product variant
60 // # - Third banana variant will be priced at 20 via product template
61 // # - First apple variant will be priced at 100 via product variant
62 // # - All product without rules and with product_category will be priced at 500
63 const test_pricelists_in_pos_steps = [
64 ProductScreen.clickPriceList("Test Pricelist"),
65 scan_barcode("banana_0"),
66 ProductScreen.selectedOrderlineHas("Banana", "1", "100.0", "BIG"),
67 scan_barcode("banana_1"),
68 ProductScreen.selectedOrderlineHas("Banana", "1", "150.0", "MEDIUM"),
69 scan_barcode("banana_2"),
70 ProductScreen.selectedOrderlineHas("Banana", "1", "20.0", "SMALL"),
71 scan_barcode("apple_0"),
72 ProductScreen.selectedOrderlineHas("Apple", "1", "100.0", "BIG"),
73 scan_barcode("apple_1"),
74 ProductScreen.selectedOrderlineHas("Apple", "1", "500.0", "MEDIUM"),
75 scan_barcode("apple_2"),
76 ProductScreen.selectedOrderlineHas("Apple", "1", "500.0", "SMALL"),
77
78 ProductScreen.clickPriceList("Percentage Pricelist"),
79 scan_barcode("banana_0"),
80 ProductScreen.selectedOrderlineHas("Banana", "2", "100.0", "BIG"),
81 scan_barcode("banana_1"),
82 ProductScreen.selectedOrderlineHas("Banana", "2", "150.0", "MEDIUM"),
83 scan_barcode("banana_2"),
84 ProductScreen.selectedOrderlineHas("Banana", "2", "20.0", "SMALL"),
85 scan_barcode("apple_0"),
86 ProductScreen.selectedOrderlineHas("Apple", "2", "100.0", "BIG"),
87 scan_barcode("apple_1"),
88 ProductScreen.selectedOrderlineHas("Apple", "2", "500.0", "MEDIUM"),
89 scan_barcode("apple_2"),
90 ProductScreen.selectedOrderlineHas("Apple", "2", "500.0", "SMALL"),
91
92 // Try scan a product with nested pricelist on variant
93 scan_barcode("pear_0"),
94 ProductScreen.selectedOrderlineHas("Pear", "1", "10.0", "BIG"),
95 scan_barcode("pear_1"),
96 ProductScreen.selectedOrderlineHas("Pear", "1", "20.0", "MEDIUM"),
97 scan_barcode("pear_2"),
98 ProductScreen.selectedOrderlineHas("Pear", "1", "30.0", "SMALL"),
99
100 // Try scan a product with nested pricelist on template
101 scan_barcode("lime_0"),
102 ProductScreen.selectedOrderlineHas("Lime", "1", "50.0", "BIG"),
103 scan_barcode("lime_1"),
104 ProductScreen.selectedOrderlineHas("Lime", "1", "100.0", "MEDIUM"),
105 scan_barcode("lime_2"),
106 ProductScreen.selectedOrderlineHas("Lime", "1", "200.0", "SMALL"),
107
108 // Try scan a product with nested pricelist on category
109 scan_barcode("orange_0"),
110 ProductScreen.selectedOrderlineHas("Orange", "1", "500.0", "BIG"),
111 scan_barcode("orange_1"),
112 ProductScreen.selectedOrderlineHas("Orange", "1", "300.0", "MEDIUM"),
113 scan_barcode("orange_2"),
114 ProductScreen.selectedOrderlineHas("Orange", "1", "250.0", "SMALL"),
115
116 // Try scan a product with no pricelist rules
117 scan_barcode("kiwi_0"),
118 ProductScreen.selectedOrderlineHas("Kiwi", "1", "10.0", "BIG"),
119 scan_barcode("kiwi_1"),
120 ProductScreen.selectedOrderlineHas("Kiwi", "1", "5.0", "MEDIUM"),
121 scan_barcode("kiwi_2"),
122 ProductScreen.selectedOrderlineHas("Kiwi", "1", "5.0", "SMALL"),
123
124 // Test if post-loaded product with attribute open the configrator
125 scan_barcode("cherry_3"),
126 Chrome.waitRequest(),
127 {
128 content: "Click hided product with attribute",
129 trigger: "body",
130 run: () => {
131 const productTemplate = posmodel.models["product.template"].find(
132 (p) => p.name === "Cherry"
133 );
134
135 posmodel.addLineToCurrentOrder({
136 product_tmpl_id: productTemplate,
137 });
138 },
139 },
140 ProductConfigurator.pickRadio("BIG"),
141 ProductConfigurator.pickRadio("GREEN"),
142 ProductConfigurator.isUnavailable("RED"),
143 Dialog.confirm(),
144 ProductScreen.clickPayButton(),
145 PaymentScreen.clickPaymentMethod("Bank", true, { remaining: "0.00" }),
146 PaymentScreen.clickValidate(),
147 ReceiptScreen.isShown(),
148 ReceiptScreen.clickNextOrder(),
149 ];
150
151 registry.category("web_tour.tours").add("test_pricelists_in_pos", {
152 steps: () =>
153 [
154 Chrome.startPoS(),
155 Dialog.confirm("Open Register"),
156 ...test_pricelists_in_pos_steps,
157 refresh(), // Check pricelist sorting after a refresh
158 ...test_pricelists_in_pos_steps,
159 ].flat(),
160 });