| 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 { escapeRegExp } from "@web/core/utils/strings"; |
| 7 | import { registry } from "@web/core/registry"; |
| 8 | |
| 9 | export function clickDownPaymentNumpad(num) { |
| 10 | return { |
| 11 | content: `click discount numpad button: ${num}`, |
| 12 | trigger: `.o_dialog div.numpad button:contains(/^${escapeRegExp(num)}$/)`, |
| 13 | run: "click", |
| 14 | }; |
| 15 | } |
| 16 | |
| 17 | export function addDownPayment(percentage, soNth, downPaymentType) { |
| 18 | const steps = [ |
| 19 | ProductScreen.clickControlButton("Quotation/Order"), |
| 20 | { |
| 21 | content: "Select the first SO", |
| 22 | trigger: `.o_sale_order .o_data_row:nth-child(${soNth}) .o_data_cell:nth-child(1)`, |
| 23 | run: "click", |
| 24 | }, |
| 25 | ]; |
| 26 | if (downPaymentType === "percent") { |
| 27 | steps.push({ |
| 28 | content: "Select 'Apply a down payment (percentage)'", |
| 29 | trigger: ".modal-body button:contains('percentage')", |
| 30 | run: "click", |
| 31 | }); |
| 32 | } else { |
| 33 | steps.push({ |
| 34 | content: "Select 'Apply a down payment (fixed amount)'", |
| 35 | trigger: ".modal-body button:contains('fixed amount')", |
| 36 | run: "click", |
| 37 | }); |
| 38 | } |
| 39 | for (const num of percentage.split("")) { |
| 40 | steps.push(clickDownPaymentNumpad(num)); |
| 41 | } |
| 42 | steps.push({ |
| 43 | content: "Select 'Apply'", |
| 44 | trigger: ".modal-dialog button.btn-primary:contains('Apply')", |
| 45 | run: "click", |
| 46 | }); |
| 47 | return steps; |
| 48 | } |
| 49 | |
| 50 | export function payAndInvoice(totalAmount) { |
| 51 | return [ |
| 52 | ProductScreen.clickPayButton(), |
| 53 | |
| 54 | PaymentScreen.totalIs(totalAmount), |
| 55 | PaymentScreen.clickPaymentMethod("Bank"), |
| 56 | PaymentScreen.remainingIs("0.0"), |
| 57 | |
| 58 | PaymentScreen.clickInvoiceButton(), |
| 59 | PaymentScreen.clickValidate(), |
| 60 | |
| 61 | ReceiptScreen.receiptAmountTotalIs(totalAmount), |
| 62 | ReceiptScreen.clickNextOrder(), |
| 63 | ]; |
| 64 | } |
| 65 | |
| 66 | registry |
| 67 | .category("web_tour.tours") |
| 68 | .add("test_taxes_l10n_in_pos_downpayment_round_per_line_price_excluded", { |
| 69 | steps: () => |
| 70 | [ |
| 71 | Chrome.startPoS(), |
| 72 | Dialog.confirm("Open Register"), |
| 73 | |
| 74 | ...addDownPayment("2", 1, "percent"), |
| 75 | ProductScreen.checkTotalAmount("0.73"), |
| 76 | ProductScreen.checkTaxAmount("0.10"), |
| 77 | ...payAndInvoice("0.73"), |
| 78 | ...addDownPayment("0.73", 2, "fixed"), |
| 79 | ProductScreen.checkTotalAmount("0.73"), |
| 80 | ProductScreen.checkTaxAmount("0.10"), |
| 81 | ...payAndInvoice("0.73"), |
| 82 | ...addDownPayment("7", 3, "percent"), |
| 83 | ProductScreen.checkTotalAmount("2.56"), |
| 84 | ProductScreen.checkTaxAmount("0.33"), |
| 85 | ...payAndInvoice("2.56"), |
| 86 | ...addDownPayment("2.56", 4, "fixed"), |
| 87 | ProductScreen.checkTotalAmount("2.56"), |
| 88 | ProductScreen.checkTaxAmount("0.33"), |
| 89 | ...payAndInvoice("2.56"), |
| 90 | ...addDownPayment("18", 5, "percent"), |
| 91 | ProductScreen.checkTotalAmount("6.60"), |
| 92 | ProductScreen.checkTaxAmount("0.87"), |
| 93 | ...payAndInvoice("6.60"), |
| 94 | ...addDownPayment("6.60", 6, "fixed"), |
| 95 | ProductScreen.checkTotalAmount("6.60"), |
| 96 | ProductScreen.checkTaxAmount("0.87"), |
| 97 | ...payAndInvoice("6.60"), |
| 98 | ].flat(), |
| 99 | }); |
| 100 | |
| 101 | registry |
| 102 | .category("web_tour.tours") |
| 103 | .add("test_taxes_l10n_in_pos_downpayment_round_globally_price_excluded", { |
| 104 | steps: () => |
| 105 | [ |
| 106 | Chrome.startPoS(), |
| 107 | Dialog.confirm("Open Register"), |
| 108 | |
| 109 | ...addDownPayment("2", 1, "percent"), |
| 110 | ProductScreen.checkTotalAmount("0.73"), |
| 111 | ProductScreen.checkTaxAmount("0.1"), |
| 112 | ...payAndInvoice("0.73"), |
| 113 | ...addDownPayment("0.73", 2, "fixed"), |
| 114 | ProductScreen.checkTotalAmount("0.73"), |
| 115 | ProductScreen.checkTaxAmount("0.1"), |
| 116 | ...payAndInvoice("0.73"), |
| 117 | ...addDownPayment("7", 3, "percent"), |
| 118 | ProductScreen.checkTotalAmount("2.57"), |
| 119 | ProductScreen.checkTaxAmount("0.33"), |
| 120 | ...payAndInvoice("2.57"), |
| 121 | ...addDownPayment("2.57", 4, "fixed"), |
| 122 | ProductScreen.checkTotalAmount("2.57"), |
| 123 | ProductScreen.checkTaxAmount("0.33"), |
| 124 | ...payAndInvoice("2.57"), |
| 125 | ...addDownPayment("18", 5, "percent"), |
| 126 | ProductScreen.checkTotalAmount("6.60"), |
| 127 | ProductScreen.checkTaxAmount("0.87"), |
| 128 | ...payAndInvoice("6.60"), |
| 129 | ...addDownPayment("6.60", 6, "fixed"), |
| 130 | ProductScreen.checkTotalAmount("6.60"), |
| 131 | ProductScreen.checkTaxAmount("0.87"), |
| 132 | ...payAndInvoice("6.60"), |
| 133 | ].flat(), |
| 134 | }); |
| 135 | |
| 136 | registry |
| 137 | .category("web_tour.tours") |
| 138 | .add("test_taxes_l10n_in_pos_downpayment_round_per_line_price_included", { |
| 139 | steps: () => |
| 140 | [ |
| 141 | Chrome.startPoS(), |
| 142 | Dialog.confirm("Open Register"), |
| 143 | |
| 144 | ...addDownPayment("2", 1, "percent"), |
| 145 | ProductScreen.checkTotalAmount("0.73"), |
| 146 | ProductScreen.checkTaxAmount("0.10"), |
| 147 | ...payAndInvoice("0.73"), |
| 148 | ...addDownPayment("0.73", 2, "fixed"), |
| 149 | ProductScreen.checkTotalAmount("0.73"), |
| 150 | ProductScreen.checkTaxAmount("0.10"), |
| 151 | ...payAndInvoice("0.73"), |
| 152 | ...addDownPayment("7", 3, "percent"), |
| 153 | ProductScreen.checkTotalAmount("2.56"), |
| 154 | ProductScreen.checkTaxAmount("0.33"), |
| 155 | ...payAndInvoice("2.56"), |
| 156 | ...addDownPayment("2.56", 4, "fixed"), |
| 157 | ProductScreen.checkTotalAmount("2.56"), |
| 158 | ProductScreen.checkTaxAmount("0.33"), |
| 159 | ...payAndInvoice("2.56"), |
| 160 | ...addDownPayment("18", 5, "percent"), |
| 161 | ProductScreen.checkTotalAmount("6.60"), |
| 162 | ProductScreen.checkTaxAmount("0.87"), |
| 163 | ...payAndInvoice("6.60"), |
| 164 | ...addDownPayment("6.60", 6, "fixed"), |
| 165 | ProductScreen.checkTotalAmount("6.60"), |
| 166 | ProductScreen.checkTaxAmount("0.87"), |
| 167 | ...payAndInvoice("6.60"), |
| 168 | ].flat(), |
| 169 | }); |
| 170 | |
| 171 | registry |
| 172 | .category("web_tour.tours") |
| 173 | .add("test_taxes_l10n_in_pos_downpayment_round_globally_price_included", { |
| 174 | steps: () => |
| 175 | [ |
| 176 | Chrome.startPoS(), |
| 177 | Dialog.confirm("Open Register"), |
| 178 | |
| 179 | ...addDownPayment("2", 1, "percent"), |
| 180 | ProductScreen.checkTotalAmount("0.73"), |
| 181 | ProductScreen.checkTaxAmount("0.10"), |
| 182 | ...payAndInvoice("0.73"), |
| 183 | ...addDownPayment("0.73", 2, "fixed"), |
| 184 | ProductScreen.checkTotalAmount("0.73"), |
| 185 | ProductScreen.checkTaxAmount("0.10"), |
| 186 | ...payAndInvoice("0.73"), |
| 187 | ...addDownPayment("7", 3, "percent"), |
| 188 | ProductScreen.checkTotalAmount("2.57"), |
| 189 | ProductScreen.checkTaxAmount("0.33"), |
| 190 | ...payAndInvoice("2.57"), |
| 191 | ...addDownPayment("2.57", 4, "fixed"), |
| 192 | ProductScreen.checkTotalAmount("2.57"), |
| 193 | ProductScreen.checkTaxAmount("0.34"), |
| 194 | ...payAndInvoice("2.57"), |
| 195 | ...addDownPayment("18", 5, "percent"), |
| 196 | ProductScreen.checkTotalAmount("6.60"), |
| 197 | ProductScreen.checkTaxAmount("0.87"), |
| 198 | ...payAndInvoice("6.60"), |
| 199 | ...addDownPayment("6.60", 6, "fixed"), |
| 200 | ProductScreen.checkTotalAmount("6.60"), |
| 201 | ProductScreen.checkTaxAmount("0.87"), |
| 202 | ...payAndInvoice("6.60"), |
| 203 | ].flat(), |
| 204 | }); |
| 205 | |
| 206 | registry |
| 207 | .category("web_tour.tours") |
| 208 | .add("test_taxes_l10n_br_pos_downpayment_round_per_line_price_excluded", { |
| 209 | steps: () => |
| 210 | [ |
| 211 | Chrome.startPoS(), |
| 212 | Dialog.confirm("Open Register"), |
| 213 | |
| 214 | ...addDownPayment("2", 1, "percent"), |
| 215 | ProductScreen.checkTotalAmount("1.92"), |
| 216 | ProductScreen.checkTaxAmount("0.63"), |
| 217 | ...payAndInvoice("1.92"), |
| 218 | ].flat(), |
| 219 | }); |
| 220 | |
| 221 | registry |
| 222 | .category("web_tour.tours") |
| 223 | .add("test_taxes_l10n_br_pos_downpayment_round_globally_price_excluded", { |
| 224 | steps: () => |
| 225 | [ |
| 226 | Chrome.startPoS(), |
| 227 | Dialog.confirm("Open Register"), |
| 228 | |
| 229 | ...addDownPayment("2", 1, "percent"), |
| 230 | ProductScreen.checkTotalAmount("1.92"), |
| 231 | ProductScreen.checkTaxAmount("0.63"), |
| 232 | ...payAndInvoice("1.92"), |
| 233 | ].flat(), |
| 234 | }); |
| 235 | |
| 236 | registry |
| 237 | .category("web_tour.tours") |
| 238 | .add("test_taxes_l10n_br_pos_downpayment_round_per_line_price_included", { |
| 239 | steps: () => |
| 240 | [ |
| 241 | Chrome.startPoS(), |
| 242 | Dialog.confirm("Open Register"), |
| 243 | |
| 244 | ...addDownPayment("2", 1, "percent"), |
| 245 | ProductScreen.checkTotalAmount("1.92"), |
| 246 | ProductScreen.checkTaxAmount("0.63"), |
| 247 | ...payAndInvoice("1.92"), |
| 248 | ].flat(), |
| 249 | }); |
| 250 | |
| 251 | registry |
| 252 | .category("web_tour.tours") |
| 253 | .add("test_taxes_l10n_br_pos_downpayment_round_globally_price_included", { |
| 254 | steps: () => |
| 255 | [ |
| 256 | Chrome.startPoS(), |
| 257 | Dialog.confirm("Open Register"), |
| 258 | |
| 259 | ...addDownPayment("2", 1, "percent"), |
| 260 | ProductScreen.checkTotalAmount("1.92"), |
| 261 | ProductScreen.checkTaxAmount("0.63"), |
| 262 | ...payAndInvoice("1.92"), |
| 263 | ].flat(), |
| 264 | }); |
| 265 | |
| 266 | registry |
| 267 | .category("web_tour.tours") |
| 268 | .add("test_taxes_l10n_be_pos_downpayment_round_per_line_price_excluded", { |
| 269 | steps: () => |
| 270 | [ |
| 271 | Chrome.startPoS(), |
| 272 | Dialog.confirm("Open Register"), |
| 273 | |
| 274 | ...addDownPayment("2", 1, "percent"), |
| 275 | ProductScreen.checkTotalAmount("0.86"), |
| 276 | ProductScreen.checkTaxAmount("0.15"), |
| 277 | ...payAndInvoice("0.86"), |
| 278 | ].flat(), |
| 279 | }); |
| 280 | |
| 281 | registry |
| 282 | .category("web_tour.tours") |
| 283 | .add("test_taxes_l10n_be_pos_downpayment_round_globally_price_excluded", { |
| 284 | steps: () => |
| 285 | [ |
| 286 | Chrome.startPoS(), |
| 287 | Dialog.confirm("Open Register"), |
| 288 | |
| 289 | ...addDownPayment("2", 1, "percent"), |
| 290 | ProductScreen.checkTotalAmount("0.86"), |
| 291 | ProductScreen.checkTaxAmount("0.15"), |
| 292 | ...payAndInvoice("0.86"), |
| 293 | ].flat(), |
| 294 | }); |
| 295 | |
| 296 | registry |
| 297 | .category("web_tour.tours") |
| 298 | .add("test_taxes_l10n_be_pos_downpayment_round_per_line_price_included", { |
| 299 | steps: () => |
| 300 | [ |
| 301 | Chrome.startPoS(), |
| 302 | Dialog.confirm("Open Register"), |
| 303 | |
| 304 | ...addDownPayment("2", 1, "percent"), |
| 305 | ProductScreen.checkTotalAmount("0.86"), |
| 306 | ProductScreen.checkTaxAmount("0.15"), |
| 307 | ...payAndInvoice("0.86"), |
| 308 | ].flat(), |
| 309 | }); |
| 310 | |
| 311 | registry |
| 312 | .category("web_tour.tours") |
| 313 | .add("test_taxes_l10n_be_pos_downpayment_round_globally_price_included", { |
| 314 | steps: () => |
| 315 | [ |
| 316 | Chrome.startPoS(), |
| 317 | Dialog.confirm("Open Register"), |
| 318 | |
| 319 | ...addDownPayment("2", 1, "percent"), |
| 320 | ProductScreen.checkTotalAmount("0.86"), |
| 321 | ProductScreen.checkTaxAmount("0.15"), |
| 322 | ...payAndInvoice("0.86"), |
| 323 | ].flat(), |
| 324 | }); |