| 1 |
import { run } from "@point_of_sale/../tests/generic_helpers/utils"; |
| 2 |
|
| 3 |
export function postMessage(message, description = "") { |
| 4 |
return run(() => { |
| 5 |
window.customerDisplayChannel.postMessage( |
| 6 |
typeof message === "string" ? JSON.parse(message) : message |
| 7 |
); |
| 8 |
}, `send message to customer display: ${description}, with value: ${message}`); |
| 9 |
} |
| 10 |
|
| 11 |
export function amountIs(method, amount) { |
| 12 |
return { |
| 13 |
content: `Check that the ${method} amount is ${amount}`, |
| 14 |
trigger: `div.row:has(div:contains('${method}')):has(div:contains('${amount}'))`, |
| 15 |
}; |
| 16 |
} |
| 17 |
|
| 18 |
export function addProduct(product, description = "") { |
| 19 |
return { |
| 20 |
trigger: "div:contains('Welcome.')", |
| 21 |
run: async () => { |
| 22 |
window.customerDisplayChannel = new BroadcastChannel("UPDATE_CUSTOMER_DISPLAY"); |
| 23 |
postMessage(product, description).run(); |
| 24 |
}, |
| 25 |
}; |
| 26 |
} |
| 27 |
|
| 28 |
export const ADD_PRODUCT = |
| 29 |
'{"lines":[{"productName":"Letter Tray","price":"$ 2,972.75","qty":"1.00","unit":"Units","unitPrice":"$ 2,972.75","customerNote":"","internalNote":"[]","comboParent":"","packLotLines":[],"price_without_discount":"$ 2,972.75","isSelected":false,"imageSrc":"/web/image/product.product/855/image_128"}],"finalized":false,"amount":"2,972.75","paymentLines":[],"change":0,"onlinePaymentData":{}}'; |
| 30 |
|
| 31 |
export const ADD_PRODUCT_SELECTED = |
| 32 |
'{"lines":[{"productName":"Letter Tray","price":"$ 2,972.75","qty":"1.00","unit":"Units","unitPrice":"$ 2,972.75","customerNote":"","internalNote":"[]","comboParent":"","packLotLines":[],"price_without_discount":"$ 2,972.75","isSelected":true,"imageSrc":"/web/image/product.product/855/image_128"}],"finalized":false,"amount":"2,972.75","paymentLines":[],"change":0,"onlinePaymentData":{}}'; |
| 33 |
|
| 34 |
export const ADD_MULTI_PRODUCTS = (() => { |
| 35 |
const count = 20; |
| 36 |
const lines = Array.from({ length: count }, (_, i) => { |
| 37 |
const price = (Math.random() * 100 + 1).toFixed(2); |
| 38 |
return { |
| 39 |
productName: `Product ${i + 1}`, |
| 40 |
price: `$${price}`, |
| 41 |
qty: "1.00", |
| 42 |
unit: "Units", |
| 43 |
unitPrice: `$${price}`, |
| 44 |
customerNote: "", |
| 45 |
internalNote: "[]", |
| 46 |
comboParent: "", |
| 47 |
packLotLines: [], |
| 48 |
price_without_discount: `$${price}`, |
| 49 |
isSelected: i === count - 1, |
| 50 |
imageSrc: "/web/image/product.product/855/image_128", |
| 51 |
}; |
| 52 |
}); |
| 53 |
const amount = lines |
| 54 |
.reduce((sum, line) => sum + parseFloat(line.price.replace("$", "")), 0) |
| 55 |
.toFixed(2); |
| 56 |
return JSON.stringify({ |
| 57 |
lines, |
| 58 |
finalized: false, |
| 59 |
amount, |
| 60 |
paymentLines: [], |
| 61 |
change: 0, |
| 62 |
onlinePaymentData: {}, |
| 63 |
}); |
| 64 |
})(); |
| 65 |
|
| 66 |
export const PAY_WITH_CASH = |
| 67 |
'{"lines":[{"productName":"Letter Tray","price":"$ 2,972.75","qty":"1.00","unit":"Units","unitPrice":"$ 2,972.75","customerNote":"","internalNote":"[]","comboParent":"","packLotLines":[],"price_without_discount":"$ 2,972.75","isSelected":true,"imageSrc":"/web/image/product.product/855/image_128"}],"finalized":false,"amount":"2,972.75","paymentLines":[{"name":"Cash","amount":"2,972.75"}],"change":0,"onlinePaymentData":{}}'; |
| 68 |
|
| 69 |
export const ORDER_IS_FINALIZED = |
| 70 |
'{"lines":[{"productName":"Letter Tray","price":"$ 2,972.75","qty":"1.00","unit":"Units","unitPrice":"$ 2,972.75","customerNote":"","internalNote":"[]","comboParent":"","packLotLines":[],"price_without_discount":"$ 2,972.75","isSelected":false,"imageSrc":"/web/image/product.product/855/image_128"}],"finalized":true,"amount":"2,972.75","paymentLines":[{"name":"Cash","amount":"2,972.75"}],"change":0,"onlinePaymentData":{}}'; |
| 71 |
|
| 72 |
export const NEW_ORDER = |
| 73 |
'{"lines":[],"finalized":false,"amount":"0.00","paymentLines":[],"change":0,"onlinePaymentData":{}}'; |
| 74 |
|
| 75 |
export const QR_URL = |
| 76 |
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; |
| 77 |
|
| 78 |
export const PAY_WITH_CARD = { |
| 79 |
lines: [ |
| 80 |
{ |
| 81 |
productName: "Letter Tray", |
| 82 |
price: "$ 2,972.75", |
| 83 |
qty: "1.00", |
| 84 |
unit: "Units", |
| 85 |
unitPrice: "$ 2,972.75", |
| 86 |
oldUnitPrice: "", |
| 87 |
customerNote: "", |
| 88 |
internalNote: "", |
| 89 |
comboParent: "", |
| 90 |
packLotLines: [], |
| 91 |
price_without_discount: "$ 2,972.75", |
| 92 |
isSelected: true, |
| 93 |
imageSrc: "/web/image/product.product/855/image_128", |
| 94 |
}, |
| 95 |
], |
| 96 |
finalized: false, |
| 97 |
amount: "2,972.75", |
| 98 |
paymentLines: [{ name: "CARD", amount: "2,972.75" }], |
| 99 |
change: 0, |
| 100 |
onlinePaymentData: {}, |
| 101 |
qrPaymentData: null, |
| 102 |
}; |
| 103 |
|
| 104 |
export const SEND_QR = { |
| 105 |
lines: [ |
| 106 |
{ |
| 107 |
productName: "Letter Tray", |
| 108 |
price: "$ 2,972.75", |
| 109 |
qty: "1.00", |
| 110 |
unit: "Units", |
| 111 |
unitPrice: "$ 2,972.75", |
| 112 |
oldUnitPrice: "", |
| 113 |
customerNote: "", |
| 114 |
internalNote: "", |
| 115 |
comboParent: "", |
| 116 |
packLotLines: [], |
| 117 |
price_without_discount: "$ 2,972.75", |
| 118 |
isSelected: true, |
| 119 |
imageSrc: "/web/image/product.product/855/image_128", |
| 120 |
}, |
| 121 |
], |
| 122 |
finalized: false, |
| 123 |
amount: "2,972.75", |
| 124 |
paymentLines: [{ name: "CARD", amount: "2,972.75" }], |
| 125 |
change: 0, |
| 126 |
onlinePaymentData: {}, |
| 127 |
qrPaymentData: { |
| 128 |
amount: "$ 2,972.75", |
| 129 |
name: "CARD", |
| 130 |
qrCode: QR_URL, |
| 131 |
}, |
| 132 |
}; |
| 133 |
|
| 134 |
export const PAY_ONLINE = { |
| 135 |
lines: [ |
| 136 |
{ |
| 137 |
productName: "Letter Tray", |
| 138 |
price: "$ 2,972.75", |
| 139 |
qty: "1.00", |
| 140 |
unit: "Units", |
| 141 |
unitPrice: "$ 2,972.75", |
| 142 |
oldUnitPrice: "", |
| 143 |
customerNote: "", |
| 144 |
internalNote: "", |
| 145 |
comboParent: "", |
| 146 |
packLotLines: [], |
| 147 |
price_without_discount: "$ 2,972.75", |
| 148 |
isSelected: true, |
| 149 |
imageSrc: "/web/image/product.product/855/image_128", |
| 150 |
}, |
| 151 |
], |
| 152 |
finalized: false, |
| 153 |
amount: "2,972.75", |
| 154 |
paymentLines: [{ name: "ONLINE", amount: "2,972.75" }], |
| 155 |
change: 0, |
| 156 |
onlinePaymentData: { |
| 157 |
formattedAmount: "$ 2,972.75", |
| 158 |
orderName: "/", |
| 159 |
qrCode: QR_URL, |
| 160 |
}, |
| 161 |
}; |
| 162 |
|
| 163 |
export const PAID = { |
| 164 |
lines: [ |
| 165 |
{ |
| 166 |
productName: "Letter Tray", |
| 167 |
price: "$ 2,972.75", |
| 168 |
qty: "1.00", |
| 169 |
unit: "Units", |
| 170 |
unitPrice: "$ 2,972.75", |
| 171 |
oldUnitPrice: "", |
| 172 |
customerNote: "", |
| 173 |
internalNote: "", |
| 174 |
comboParent: "", |
| 175 |
packLotLines: [], |
| 176 |
price_without_discount: "$ 2,972.75", |
| 177 |
isSelected: true, |
| 178 |
imageSrc: "/web/image/product.product/855/image_128", |
| 179 |
}, |
| 180 |
], |
| 181 |
finalized: false, |
| 182 |
amount: "2,972.75", |
| 183 |
paymentLines: [{ name: "ONLINE", amount: "2,972.75" }], |
| 184 |
change: 0, |
| 185 |
onlinePaymentData: {}, |
| 186 |
}; |