Debian Codegraph @

addons/pos_discount/static/tests/tours/test_taxes_global_discount.js

raw symbols SCIP
1 import * as Chrome from "@point_of_sale/../tests/pos/tours/utils/chrome_util";
2 import * as Dialog from "@point_of_sale/../tests/generic_helpers/dialog_util";
3 import * as ProductScreen from "@point_of_sale/../tests/pos/tours/utils/product_screen_util";
4 import * as PaymentScreen from "@point_of_sale/../tests/pos/tours/utils/payment_screen_util";
5 import * as ReceiptScreen from "@point_of_sale/../tests/pos/tours/utils/receipt_screen_util";
6 import * as TicketScreen from "@point_of_sale/../tests/pos/tours/utils/ticket_screen_util";
7 import { escapeRegExp } from "@web/core/utils/strings";
8 import { registry } from "@web/core/registry";
9
10 export function addDocument(documentParams) {
11 const steps = [];
12 for (const values of documentParams) {
13 steps.push(...ProductScreen.addOrderline(values.product, values.quantity));
14 }
15 steps.push(...[ProductScreen.clickPartnerButton(), ProductScreen.clickCustomer("AAAAAA")]);
16 return steps;
17 }
18
19 export function clickDiscountNumpad(num) {
20 return {
21 content: `click discount numpad button: ${num}`,
22 trigger: `.o_dialog div.numpad button:contains(/^${escapeRegExp(num)}$/)`,
23 run: "click",
24 };
25 }
26
27 export function addDiscount(percentage) {
28 const steps = [ProductScreen.clickControlButton("Discount")];
29 for (const num of percentage.split("")) {
30 steps.push(clickDiscountNumpad(num));
31 }
32 steps.push({
33 trigger: `.popup-input:contains(/^${escapeRegExp(percentage)}$/)`,
34 run: "click",
35 });
36 steps.push(Dialog.confirm());
37 return steps;
38 }
39
40 export function payAndInvoice(totalAmount) {
41 return [
42 ProductScreen.clickPayButton(),
43
44 PaymentScreen.totalIs(totalAmount),
45 PaymentScreen.clickPaymentMethod("Bank"),
46 PaymentScreen.remainingIs("0.0"),
47
48 PaymentScreen.clickInvoiceButton(),
49 PaymentScreen.clickValidate(),
50
51 ReceiptScreen.receiptAmountTotalIs(totalAmount),
52 ReceiptScreen.clickNextOrder(),
53 ];
54 }
55
56 registry
57 .category("web_tour.tours")
58 .add("test_taxes_l10n_in_pos_global_discount_round_per_line_price_excluded", {
59 steps: () =>
60 [
61 Chrome.startPoS(),
62 Dialog.confirm("Open Register"),
63
64 ...addDocument([
65 { product: "product_1_1", quantity: "1" },
66 { product: "product_1_2", quantity: "1" },
67 ]),
68 ...addDiscount("2"),
69 ProductScreen.checkTotalAmount("35.91"),
70 ProductScreen.checkTaxAmount("4.76"),
71 ...payAndInvoice("35.91"),
72 ...addDocument([
73 { product: "product_1_1", quantity: "1" },
74 { product: "product_1_2", quantity: "1" },
75 ]),
76 ...addDiscount("7"),
77 ProductScreen.checkTotalAmount("34.08"),
78 ProductScreen.checkTaxAmount("4.53"),
79 ...payAndInvoice("34.08"),
80 ...addDocument([
81 { product: "product_1_1", quantity: "1" },
82 { product: "product_1_2", quantity: "1" },
83 ]),
84 ...addDiscount("18"),
85 ProductScreen.checkTotalAmount("30.04"),
86 ProductScreen.checkTaxAmount("3.99"),
87 ...payAndInvoice("30.04"),
88 // On refund, check if the global discount line is correctly prorated in the refund order
89 ...ProductScreen.clickRefund(),
90 TicketScreen.filterIs("Paid"),
91 TicketScreen.selectOrder("001"),
92 ProductScreen.clickNumpad("1"),
93 TicketScreen.confirmRefund(),
94 PaymentScreen.totalIs("-17.95"), // -18.32 (product_1_1) + 0.37 (discount)
95 ].flat(),
96 });
97
98 registry
99 .category("web_tour.tours")
100 .add("test_taxes_l10n_in_pos_global_discount_round_globally_price_excluded", {
101 steps: () =>
102 [
103 Chrome.startPoS(),
104 Dialog.confirm("Open Register"),
105
106 ...addDocument([
107 { product: "product_2_1", quantity: "1" },
108 { product: "product_2_2", quantity: "1" },
109 ]),
110 ...addDiscount("2"),
111 ProductScreen.checkTotalAmount("35.94"),
112 ProductScreen.checkTaxAmount("4.79"),
113 ...payAndInvoice("35.94"),
114 ...addDocument([
115 { product: "product_2_1", quantity: "1" },
116 { product: "product_2_2", quantity: "1" },
117 ]),
118 ...addDiscount("7"),
119 ProductScreen.checkTotalAmount("34.10"),
120 ProductScreen.checkTaxAmount("4.56"),
121 ...payAndInvoice("34.10"),
122 ...addDocument([
123 { product: "product_2_1", quantity: "1" },
124 { product: "product_2_2", quantity: "1" },
125 ]),
126 ...addDiscount("18"),
127 ProductScreen.checkTotalAmount("30.07"),
128 ProductScreen.checkTaxAmount("4.02"),
129 ...payAndInvoice("30.07"),
130 ].flat(),
131 });
132
133 registry
134 .category("web_tour.tours")
135 .add("test_taxes_l10n_in_pos_global_discount_round_per_line_price_included", {
136 steps: () =>
137 [
138 Chrome.startPoS(),
139 Dialog.confirm("Open Register"),
140
141 ...addDocument([
142 { product: "product_3_1", quantity: "1" },
143 { product: "product_3_2", quantity: "1" },
144 ]),
145 ...addDiscount("2"),
146 ProductScreen.checkTotalAmount("35.91"),
147 ProductScreen.checkTaxAmount("4.76"),
148 ...payAndInvoice("35.91"),
149 ...addDocument([
150 { product: "product_3_1", quantity: "1" },
151 { product: "product_3_2", quantity: "1" },
152 ]),
153 ...addDiscount("7"),
154 ProductScreen.checkTotalAmount("34.08"),
155 ProductScreen.checkTaxAmount("4.53"),
156 ...payAndInvoice("34.08"),
157 ...addDocument([
158 { product: "product_3_1", quantity: "1" },
159 { product: "product_3_2", quantity: "1" },
160 ]),
161 ...addDiscount("18"),
162 ProductScreen.checkTotalAmount("30.04"),
163 ProductScreen.checkTaxAmount("3.99"),
164 ...payAndInvoice("30.04"),
165 ].flat(),
166 });
167
168 registry
169 .category("web_tour.tours")
170 .add("test_taxes_l10n_in_pos_global_discount_round_globally_price_included", {
171 steps: () =>
172 [
173 Chrome.startPoS(),
174 Dialog.confirm("Open Register"),
175
176 ...addDocument([
177 { product: "product_4_1", quantity: "1" },
178 { product: "product_4_2", quantity: "1" },
179 ]),
180 ...addDiscount("2"),
181 ProductScreen.checkTotalAmount("35.93"),
182 ProductScreen.checkTaxAmount("4.79"),
183 ...payAndInvoice("35.93"),
184 ...addDocument([
185 { product: "product_4_1", quantity: "1" },
186 { product: "product_4_2", quantity: "1" },
187 ]),
188 ...addDiscount("7"),
189 ProductScreen.checkTotalAmount("34.09"),
190 ProductScreen.checkTaxAmount("4.56"),
191 ...payAndInvoice("34.09"),
192 ...addDocument([
193 { product: "product_4_1", quantity: "1" },
194 { product: "product_4_2", quantity: "1" },
195 ]),
196 ...addDiscount("18"),
197 ProductScreen.checkTotalAmount("30.06"),
198 ProductScreen.checkTaxAmount("4.02"),
199 ...payAndInvoice("30.06"),
200 ].flat(),
201 });
202
203 registry
204 .category("web_tour.tours")
205 .add("test_taxes_l10n_br_pos_global_discount_round_per_line_price_excluded", {
206 steps: () =>
207 [
208 Chrome.startPoS(),
209 Dialog.confirm("Open Register"),
210
211 ...addDocument([
212 { product: "product_1_1", quantity: "1" },
213 { product: "product_1_2", quantity: "1" },
214 ]),
215 ...addDiscount("2"),
216 ProductScreen.checkTotalAmount("94.08"),
217 ProductScreen.checkTaxAmount("30.7"),
218 ...payAndInvoice("94.08"),
219 ].flat(),
220 });
221
222 registry
223 .category("web_tour.tours")
224 .add("test_taxes_l10n_br_pos_global_discount_round_globally_price_excluded", {
225 steps: () =>
226 [
227 Chrome.startPoS(),
228 Dialog.confirm("Open Register"),
229
230 ...addDocument([
231 { product: "product_2_1", quantity: "1" },
232 { product: "product_2_2", quantity: "1" },
233 ]),
234 ...addDiscount("2"),
235 ProductScreen.checkTotalAmount("94.08"),
236 ProductScreen.checkTaxAmount("30.71"),
237 ...payAndInvoice("94.08"),
238 ].flat(),
239 });
240
241 registry
242 .category("web_tour.tours")
243 .add("test_taxes_l10n_br_pos_global_discount_round_per_line_price_included", {
244 steps: () =>
245 [
246 Chrome.startPoS(),
247 Dialog.confirm("Open Register"),
248
249 ...addDocument([
250 { product: "product_3_1", quantity: "1" },
251 { product: "product_3_2", quantity: "1" },
252 ]),
253 ...addDiscount("2"),
254 ProductScreen.checkTotalAmount("94.08"),
255 ProductScreen.checkTaxAmount("30.7"),
256 ...payAndInvoice("94.08"),
257 ].flat(),
258 });
259
260 registry
261 .category("web_tour.tours")
262 .add("test_taxes_l10n_br_pos_global_discount_round_globally_price_included", {
263 steps: () =>
264 [
265 Chrome.startPoS(),
266 Dialog.confirm("Open Register"),
267
268 ...addDocument([
269 { product: "product_4_1", quantity: "1" },
270 { product: "product_4_2", quantity: "1" },
271 ]),
272 ...addDiscount("2"),
273 ProductScreen.checkTotalAmount("94.08"),
274 ProductScreen.checkTaxAmount("30.71"),
275 ...payAndInvoice("94.08"),
276 ].flat(),
277 });
278
279 registry
280 .category("web_tour.tours")
281 .add("test_taxes_l10n_be_pos_global_discount_round_per_line_price_excluded", {
282 steps: () =>
283 [
284 Chrome.startPoS(),
285 Dialog.confirm("Open Register"),
286
287 ...addDocument([
288 { product: "product_1_1", quantity: "1" },
289 { product: "product_1_2", quantity: "1" },
290 ]),
291 ...addDiscount("2"),
292 ProductScreen.checkTotalAmount("42.25"),
293 ProductScreen.checkTaxAmount("9.34"),
294 ...payAndInvoice("42.25"),
295 ].flat(),
296 });
297
298 registry
299 .category("web_tour.tours")
300 .add("test_taxes_l10n_be_pos_global_discount_round_globally_price_excluded", {
301 steps: () =>
302 [
303 Chrome.startPoS(),
304 Dialog.confirm("Open Register"),
305
306 ...addDocument([
307 { product: "product_2_1", quantity: "1" },
308 { product: "product_2_2", quantity: "1" },
309 ]),
310 ...addDiscount("2"),
311 ProductScreen.checkTotalAmount("42.24"),
312 ProductScreen.checkTaxAmount("9.33"),
313 ...payAndInvoice("42.24"),
314 ].flat(),
315 });
316
317 registry
318 .category("web_tour.tours")
319 .add("test_taxes_l10n_be_pos_global_discount_round_per_line_price_included", {
320 steps: () =>
321 [
322 Chrome.startPoS(),
323 Dialog.confirm("Open Register"),
324
325 ...addDocument([
326 { product: "product_3_1", quantity: "1" },
327 { product: "product_3_2", quantity: "1" },
328 ]),
329 ...addDiscount("2"),
330 ProductScreen.checkTotalAmount("42.25"),
331 ProductScreen.checkTaxAmount("9.34"),
332 ...payAndInvoice("42.25"),
333 ].flat(),
334 });
335
336 registry
337 .category("web_tour.tours")
338 .add("test_taxes_l10n_be_pos_global_discount_round_globally_price_included", {
339 steps: () =>
340 [
341 Chrome.startPoS(),
342 Dialog.confirm("Open Register"),
343
344 ...addDocument([
345 { product: "product_4_1", quantity: "1" },
346 { product: "product_4_2", quantity: "1" },
347 ]),
348 ...addDiscount("2"),
349 ProductScreen.checkTotalAmount("42.25"),
350 ProductScreen.checkTaxAmount("9.33"),
351 ...payAndInvoice("42.25"),
352 ].flat(),
353 });