meemup-library 1.5.32 → 1.5.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controllers/PreviewContentController.d.ts +1 -0
- package/dist/controllers/PreviewContentController.js +18 -27
- package/dist/controllers/PrintContentController.d.ts +4 -3
- package/dist/controllers/PrintContentController.js +4 -2
- package/dist/controllers/PrintToolController.d.ts +12 -0
- package/dist/controllers/PrintToolController.js +99 -0
- package/dist/controllers/SimplePreviewController.js +165 -5
- package/dist/statics.d.ts +6 -0
- package/dist/statics.js +6 -0
- package/package.json +2 -2
|
@@ -23,6 +23,7 @@ declare class _PreviewContentController {
|
|
|
23
23
|
labelLayout(detail: IOrderDetails, template: IPrintTemplate): string;
|
|
24
24
|
paymentFailed(detail: IOrderDetails, currency: string): string;
|
|
25
25
|
packageLabel(detail: IOrderDetails, template: IPrintTemplate): string;
|
|
26
|
+
preview(account: IAccount, detail: IOrderDetails, template: IPrintTemplate): string;
|
|
26
27
|
previewForPos(account: IAccount, detail: IOrderDetails, template: IPrintTemplate): string;
|
|
27
28
|
createPrintFromTurnoverDetail(data: ITurnover, currency: string, printParts: IPointOfSalePrintParts): Promise<string>;
|
|
28
29
|
createCashDrawerPaidInOutMarkup(device: IPointOfSaleActionFormCashDrawer, setting: IPointOfSaleSetting, member: IPointOfSaleTeamMember): Promise<string>;
|
|
@@ -315,33 +315,24 @@ class _PreviewContentController {
|
|
|
315
315
|
</div>
|
|
316
316
|
</div>`;
|
|
317
317
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
// }
|
|
337
|
-
//
|
|
338
|
-
// return this.labelLayout(detail, template);
|
|
339
|
-
// case EnumPrintLayout.PACKAGE_LABEL:
|
|
340
|
-
// return this.packageLabel(detail, template);
|
|
341
|
-
// default:
|
|
342
|
-
// return `<div> template.layout : ${template.layout}</div>`;
|
|
343
|
-
// }
|
|
344
|
-
// }
|
|
318
|
+
preview(account, detail, template) {
|
|
319
|
+
switch (template.layout) {
|
|
320
|
+
case EnumPrintLayout.SIMPLE:
|
|
321
|
+
return this.simpleLayout(account, detail, template);
|
|
322
|
+
case EnumPrintLayout.LARGE:
|
|
323
|
+
return this.largeLayout(account, detail, template);
|
|
324
|
+
case EnumPrintLayout.LABEL:
|
|
325
|
+
const products = this.filterByCategoryList(this.sortProduct(detail.products, template.sortProducts), template.printOnlyCertainCategoriesList, template.printOnlyCertainCategories, template.printOnlyCertainProductsList, template.printOnlyCertainProducts);
|
|
326
|
+
if (products.length === 0) {
|
|
327
|
+
return `<div>no product </div>`;
|
|
328
|
+
}
|
|
329
|
+
return this.labelLayout(detail, template);
|
|
330
|
+
case EnumPrintLayout.PACKAGE_LABEL:
|
|
331
|
+
return this.packageLabel(detail, template);
|
|
332
|
+
default:
|
|
333
|
+
return `<div> template.layout : ${template.layout}</div>`;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
345
336
|
previewForPos(account, detail, template) {
|
|
346
337
|
let content;
|
|
347
338
|
switch (template.layout) {
|
|
@@ -3,7 +3,7 @@ import IPrintTemplate from "../interfaces/IPrintTemplate";
|
|
|
3
3
|
import IOrderDetails from "../interfaces/print/IOrderDetails";
|
|
4
4
|
import IOrderDetailCustomer from "../interfaces/print/IOrderDetailCustomer";
|
|
5
5
|
import IOrderDetailProduct from "../interfaces/print/IOrderDetailProduct";
|
|
6
|
-
declare
|
|
6
|
+
declare class _PreviewContentController {
|
|
7
7
|
createAddressText: (customer: IOrderDetailCustomer) => null | [string, string];
|
|
8
8
|
ccyFormat: (num: number, pre?: string) => string;
|
|
9
9
|
calculatePaperSize: (paper: number, width: string | number) => string;
|
|
@@ -21,5 +21,6 @@ declare const _default: {
|
|
|
21
21
|
paymentFailed(detail: IOrderDetails, currency: string): string;
|
|
22
22
|
packageLabel(detail: IOrderDetails): string;
|
|
23
23
|
preview(account: IAccount, detail: IOrderDetails, template: IPrintTemplate, symbol?: string): string;
|
|
24
|
-
}
|
|
25
|
-
|
|
24
|
+
}
|
|
25
|
+
declare const PreviewContentController: _PreviewContentController;
|
|
26
|
+
export default PreviewContentController;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import PhoneController from "./PhoneController";
|
|
2
|
-
|
|
2
|
+
class _PreviewContentController {
|
|
3
3
|
constructor() {
|
|
4
4
|
this.createAddressText = (customer) => {
|
|
5
5
|
let text = "";
|
|
@@ -512,4 +512,6 @@ export default new class {
|
|
|
512
512
|
return `<div> template.layout : ${template.layout}</div>`;
|
|
513
513
|
}
|
|
514
514
|
}
|
|
515
|
-
}
|
|
515
|
+
}
|
|
516
|
+
const PreviewContentController = new _PreviewContentController();
|
|
517
|
+
export default PreviewContentController;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import IOrderDetailProductsExtra from '../interfaces/print/IOrderDetailProductsExtra';
|
|
2
|
+
import IOrderDetailProduct from '../interfaces/print/IOrderDetailProduct';
|
|
3
|
+
declare class _PrintToolController {
|
|
4
|
+
extraItemToText(item: IOrderDetailProductsExtra, ignoreWholeText?: boolean): string;
|
|
5
|
+
productNote(item: IOrderDetailProduct): string;
|
|
6
|
+
orderItemCountText: (products: IOrderDetailProduct[], catList: number[], onlyListCategory: boolean, productList: number[], onlyListProduct: boolean) => string;
|
|
7
|
+
filterProductsByCategoryList: (products: IOrderDetailProduct[], catList: number[], onlyListCategory: boolean, productList: number[], onlyListProduct: boolean) => IOrderDetailProduct[];
|
|
8
|
+
textWithIndent(text: string, indent?: number, lineWidth?: number): string;
|
|
9
|
+
createBundleLines(bundleTitle: string, price: string, lineWidth?: number): string;
|
|
10
|
+
}
|
|
11
|
+
declare const PrintToolController: _PrintToolController;
|
|
12
|
+
export default PrintToolController;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import EnumPizzaSide from '../enums/EnumPizzaSide';
|
|
2
|
+
import MoneyController from './MoneyController';
|
|
3
|
+
class _PrintToolController {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.orderItemCountText = (products, catList, onlyListCategory, productList, onlyListProduct) => {
|
|
6
|
+
let list = this.filterProductsByCategoryList(products, catList, onlyListCategory, productList, onlyListProduct);
|
|
7
|
+
return `${MoneyController.sum(list.map(row => row.quantity))} ITEM`;
|
|
8
|
+
};
|
|
9
|
+
this.filterProductsByCategoryList = (products, catList, onlyListCategory, productList, onlyListProduct) => {
|
|
10
|
+
if (!onlyListCategory && !onlyListProduct) {
|
|
11
|
+
return products;
|
|
12
|
+
}
|
|
13
|
+
const new_product = [];
|
|
14
|
+
if (onlyListCategory && !onlyListProduct) {
|
|
15
|
+
products
|
|
16
|
+
.filter(x => catList.find(element => element === x.categoryId))
|
|
17
|
+
.forEach(row => new_product.push(row));
|
|
18
|
+
}
|
|
19
|
+
else if (!onlyListCategory && onlyListProduct) {
|
|
20
|
+
products
|
|
21
|
+
.filter(x => productList.find(element => element === x.productId))
|
|
22
|
+
.forEach(row => new_product.push(row));
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
const arr = [];
|
|
26
|
+
products
|
|
27
|
+
.filter(x => catList.find(element => element === x.categoryId))
|
|
28
|
+
.forEach(row => arr.push(row));
|
|
29
|
+
arr
|
|
30
|
+
.filter(x => productList.find(element => element === x.productId))
|
|
31
|
+
.forEach(row => {
|
|
32
|
+
new_product.push(row);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return new_product;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
extraItemToText(item, ignoreWholeText = false) {
|
|
39
|
+
let parts = [];
|
|
40
|
+
switch (item.pizzaSide) {
|
|
41
|
+
case EnumPizzaSide.all:
|
|
42
|
+
if (!ignoreWholeText) {
|
|
43
|
+
parts.push('[WHOLE]');
|
|
44
|
+
}
|
|
45
|
+
break;
|
|
46
|
+
case EnumPizzaSide.left:
|
|
47
|
+
parts.push('[LEFT]');
|
|
48
|
+
break;
|
|
49
|
+
case EnumPizzaSide.right:
|
|
50
|
+
parts.push('[RIGHT]');
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
if (item.quantity > 1) {
|
|
54
|
+
parts.push(`${item.quantity}x`);
|
|
55
|
+
}
|
|
56
|
+
parts.push(item.extraItemTitle.trim());
|
|
57
|
+
if (item.extraItemOptionId !== null && item.extraItemOptionId !== -1) {
|
|
58
|
+
parts.push(`[${item.extraItemOptionTitle.trim()}] `);
|
|
59
|
+
}
|
|
60
|
+
if (item.totalAmount !== 0) {
|
|
61
|
+
parts.push(`(${MoneyController.format(item.totalAmount, '')})`);
|
|
62
|
+
}
|
|
63
|
+
return parts.join(' ').trim();
|
|
64
|
+
}
|
|
65
|
+
productNote(item) {
|
|
66
|
+
if (item.note && (item.note + '').trim().length > 0) {
|
|
67
|
+
return item.note.trim().split(' ').join(' ');
|
|
68
|
+
}
|
|
69
|
+
return '';
|
|
70
|
+
}
|
|
71
|
+
textWithIndent(text, indent = 2, lineWidth = 48) {
|
|
72
|
+
function splitString(str, chunkSize) {
|
|
73
|
+
return Array.from({ length: Math.ceil(str.length / chunkSize) }, (_, i) => str.slice(i * chunkSize, (i + 1) * chunkSize));
|
|
74
|
+
}
|
|
75
|
+
let lineCharLength = lineWidth - indent;
|
|
76
|
+
let parts = splitString(text, lineCharLength);
|
|
77
|
+
const indentStr = ' '.repeat(indent);
|
|
78
|
+
parts = parts.map(i => indentStr + i);
|
|
79
|
+
return parts.join('\n') + '\n';
|
|
80
|
+
}
|
|
81
|
+
createBundleLines(bundleTitle, price, lineWidth = 48) {
|
|
82
|
+
function splitString(str, chunkSize) {
|
|
83
|
+
return Array.from({ length: Math.ceil(str.length / chunkSize) }, (_, i) => str.slice(i * chunkSize, (i + 1) * chunkSize));
|
|
84
|
+
}
|
|
85
|
+
let lineCharLength = lineWidth - (price.length) - 1;
|
|
86
|
+
let parts = splitString(bundleTitle, lineCharLength);
|
|
87
|
+
if (parts.length >= 1) {
|
|
88
|
+
while ((parts[0].length + price.length + 1) < lineWidth) {
|
|
89
|
+
parts[0] = parts[0] + ' ';
|
|
90
|
+
}
|
|
91
|
+
parts[0] = parts[0] + ' ' + price;
|
|
92
|
+
}
|
|
93
|
+
// const indentStr : string = ' '.repeat(indent);
|
|
94
|
+
// parts = parts.map(i=> indentStr + i);
|
|
95
|
+
return parts.join('\n') + '\n';
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const PrintToolController = new _PrintToolController();
|
|
99
|
+
export default PrintToolController;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import PrintToolController from "./PrintToolController.js";
|
|
2
|
+
import EnumFeeType from "../enums/EnumFeeType.js";
|
|
1
3
|
import PhoneController from "./PhoneController";
|
|
2
4
|
import EnumPaymentType from "../enums/EnumPaymentType";
|
|
3
5
|
import MoneyController from "./MoneyController";
|
|
@@ -7,7 +9,7 @@ import EnumPizzaSide from "../enums/EnumPizzaSide";
|
|
|
7
9
|
import EnumPaymentState from "../enums/EnumPaymentState";
|
|
8
10
|
import OrderToolController from "./OrderToolController";
|
|
9
11
|
import EnumOrderDateTimePrintModeType from "../enums/EnumOrderDateTimePrintModeType";
|
|
10
|
-
import { Formats, printPoweredBy } from "../statics";
|
|
12
|
+
import { Formats, printPoweredBy, BundleIdPreName, BundleGroupPreName, BundleProductQuantityPreName } from "../statics";
|
|
11
13
|
import dayjs from "../utils/dayjs";
|
|
12
14
|
class SimplePreviewController {
|
|
13
15
|
constructor() {
|
|
@@ -202,6 +204,7 @@ class SimplePreviewController {
|
|
|
202
204
|
return content;
|
|
203
205
|
}
|
|
204
206
|
printProducts(template, detail) {
|
|
207
|
+
var _a, _b, _c;
|
|
205
208
|
let content = this.createDivContainer(template);
|
|
206
209
|
content += `<table style="width: 100%; border-collapse: collapse;">
|
|
207
210
|
<thead style="border-bottom: 1px solid #000000;">
|
|
@@ -213,7 +216,84 @@ class SimplePreviewController {
|
|
|
213
216
|
</thead>
|
|
214
217
|
<tbody>
|
|
215
218
|
`;
|
|
216
|
-
detail.products.
|
|
219
|
+
const bundledProducts = detail.products.filter(i => Array.isArray(i.tags) && i.tags.findIndex(tag => tag.startsWith(BundleIdPreName)) !== -1);
|
|
220
|
+
if (bundledProducts.length > 0) {
|
|
221
|
+
const bundleGroups = [];
|
|
222
|
+
bundledProducts.forEach(pro => {
|
|
223
|
+
var _a;
|
|
224
|
+
const tag = (_a = pro.tags) === null || _a === void 0 ? void 0 : _a.find(i => i.startsWith(BundleGroupPreName));
|
|
225
|
+
if (tag) {
|
|
226
|
+
const bundleGroup = (tag + '').split(BundleGroupPreName)[1];
|
|
227
|
+
if (!bundleGroups.includes(bundleGroup)) {
|
|
228
|
+
bundleGroups.push(bundleGroup);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
const bundles = detail.order.items.filter(i => i.type === EnumFeeType.BundleProduct);
|
|
233
|
+
for (let ind = 0; ind < bundleGroups.length; ind++) {
|
|
234
|
+
const group = bundleGroups[ind] + '';
|
|
235
|
+
const groupTag = BundleGroupPreName + group;
|
|
236
|
+
const list = bundledProducts.filter(pro => Array.isArray(pro.tags) && pro.tags.includes(groupTag));
|
|
237
|
+
if (list.length > 0) {
|
|
238
|
+
const firstItem = list[0];
|
|
239
|
+
// const bundleGroup: string = (firstItem.tags?.find(i => i.startsWith(BundleGroupPreName)) + '').split(BundleGroupPreName)[1];
|
|
240
|
+
// const bundleId: number = +(firstItem.tags?.find(i => i.startsWith(BundleIdPreName)) + '').split(BundleIdPreName)[1];
|
|
241
|
+
const firstItemRatio = +(((_a = firstItem.tags) === null || _a === void 0 ? void 0 : _a.find(i => i.startsWith(BundleProductQuantityPreName))) + '').split(BundleProductQuantityPreName)[1];
|
|
242
|
+
const bundleQuantity = firstItem.quantity / firstItemRatio;
|
|
243
|
+
const bundle = bundles.find(i => { var _a; return ((_a = i.metadata.find(j => j.text === "BundleGroup")) === null || _a === void 0 ? void 0 : _a.value) === group; });
|
|
244
|
+
if (bundle) {
|
|
245
|
+
const sharp = ` ${bundleQuantity}×`;
|
|
246
|
+
const sumBundleDiscount = bundle.amount; // bundleQuantity * bundle.discountAmount;
|
|
247
|
+
const _total = MoneyController.sumField(list, 'totalAmount');
|
|
248
|
+
// let _lastTotal = _total - sumBundleDiscount;
|
|
249
|
+
let _lastTotal = _total - sumBundleDiscount;
|
|
250
|
+
if (_lastTotal < 0) {
|
|
251
|
+
_lastTotal = 0;
|
|
252
|
+
}
|
|
253
|
+
const price = template.showPrices ? MoneyController.format(_lastTotal, detail.company.currencySymbol) : '';
|
|
254
|
+
let bundleText = bundle.text;
|
|
255
|
+
bundleText = ((_b = bundleText === null || bundleText === void 0 ? void 0 : bundleText.replace(sharp, '')) === null || _b === void 0 ? void 0 : _b.trim()) + "";
|
|
256
|
+
content += `<tr style="height: 28px;">
|
|
257
|
+
<td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;">${sharp}</td>
|
|
258
|
+
<td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: left; font-weight: bold;">${bundleText}</td>
|
|
259
|
+
<td style="font-size:${template.fontSize}px; max-width: 90px; text-align: right;">${price}</td>
|
|
260
|
+
</tr>`;
|
|
261
|
+
for (let index = 0; index < list.length; index++) {
|
|
262
|
+
const row = list[index];
|
|
263
|
+
const sharp = `${row.quantity}× `;
|
|
264
|
+
let product = (template.showProductKitchenName && row.kitchenReceiptName !== '' && row.kitchenReceiptName !== null) ? row.kitchenReceiptName : row.title;
|
|
265
|
+
product = sharp + ((_c = product === null || product === void 0 ? void 0 : product.replace(sharp, '')) === null || _c === void 0 ? void 0 : _c.trim()) + "";
|
|
266
|
+
content += `<tr>
|
|
267
|
+
<td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
|
|
268
|
+
<td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: left; column-span: 2;">${product}</td>
|
|
269
|
+
</tr>`;
|
|
270
|
+
if (row.extrasNames) {
|
|
271
|
+
const extList = row.extras
|
|
272
|
+
.filter(item => !item.doNotPrintOnReceipt)
|
|
273
|
+
.map(item => PrintToolController.extraItemToText(item, template.skipWholePizzaToppingText))
|
|
274
|
+
.filter(i => i.length > 0);
|
|
275
|
+
for (let ind = 0; ind < extList.length; ind++) {
|
|
276
|
+
content += `<tr>
|
|
277
|
+
<td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
|
|
278
|
+
<td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: left; column-span: 2; padding-left: 24px;">${extList[ind]}</td>
|
|
279
|
+
</tr>`;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
const note = PrintToolController.productNote(row);
|
|
283
|
+
if (note !== '') {
|
|
284
|
+
content += `<tr>
|
|
285
|
+
<td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
|
|
286
|
+
<td style="font-size:${template.fontSize}px; font-weight: bold; flex: 1; width: 100%; text-align: left; column-span: 2; padding-left: 24px;">${note}</td>
|
|
287
|
+
</tr>`;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
const unBundledProducts = detail.products.filter(i => !(Array.isArray(i.tags) && i.tags.findIndex(tag => tag.startsWith(BundleIdPreName)) !== -1));
|
|
295
|
+
const list = this.filterByCategoryList(this.sortProduct(unBundledProducts, template.sortProducts), template.printOnlyCertainCategoriesList, template.printOnlyCertainCategories, template.printOnlyCertainProductsList, template.printOnlyCertainProducts);
|
|
296
|
+
list.forEach((row) => {
|
|
217
297
|
let cat;
|
|
218
298
|
if (!template.showCategoryTitle || !row.categoryTitle || row.categoryTitle.trim().length === 0)
|
|
219
299
|
cat = "";
|
|
@@ -335,6 +415,7 @@ class SimplePreviewController {
|
|
|
335
415
|
return content;
|
|
336
416
|
}
|
|
337
417
|
printLargeProducts(template, detail) {
|
|
418
|
+
var _a, _b, _c;
|
|
338
419
|
let content = this.createDivContainer(template);
|
|
339
420
|
const largeFontSize = template.printer === 5 ? 22 : parseInt((template.fontSize + 10) + "");
|
|
340
421
|
content += `<table style="width: 100%; border-collapse: collapse;">
|
|
@@ -347,16 +428,95 @@ class SimplePreviewController {
|
|
|
347
428
|
</thead>
|
|
348
429
|
<tbody>
|
|
349
430
|
`;
|
|
350
|
-
detail.products.
|
|
431
|
+
const bundledProducts = detail.products.filter(i => Array.isArray(i.tags) && i.tags.findIndex(tag => tag.startsWith(BundleIdPreName)) !== -1);
|
|
432
|
+
if (bundledProducts.length > 0) {
|
|
433
|
+
const bundleGroups = [];
|
|
434
|
+
bundledProducts.forEach(pro => {
|
|
435
|
+
var _a;
|
|
436
|
+
const tag = (_a = pro.tags) === null || _a === void 0 ? void 0 : _a.find(i => i.startsWith(BundleGroupPreName));
|
|
437
|
+
if (tag) {
|
|
438
|
+
const bundleGroup = (tag + '').split(BundleGroupPreName)[1];
|
|
439
|
+
if (!bundleGroups.includes(bundleGroup)) {
|
|
440
|
+
bundleGroups.push(bundleGroup);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
const bundles = detail.order.items.filter(i => i.type === EnumFeeType.BundleProduct);
|
|
445
|
+
for (let ind = 0; ind < bundleGroups.length; ind++) {
|
|
446
|
+
const group = bundleGroups[ind] + '';
|
|
447
|
+
const groupTag = BundleGroupPreName + group;
|
|
448
|
+
const list = bundledProducts.filter(pro => Array.isArray(pro.tags) && pro.tags.includes(groupTag));
|
|
449
|
+
if (list.length > 0) {
|
|
450
|
+
const firstItem = list[0];
|
|
451
|
+
const firstItemRatio = +(((_a = firstItem.tags) === null || _a === void 0 ? void 0 : _a.find(i => i.startsWith(BundleProductQuantityPreName))) + '').split(BundleProductQuantityPreName)[1];
|
|
452
|
+
const bundleQuantity = firstItem.quantity / firstItemRatio;
|
|
453
|
+
const bundle = bundles.find(i => { var _a; return ((_a = i.metadata.find(j => j.text === "BundleGroup")) === null || _a === void 0 ? void 0 : _a.value) === group; });
|
|
454
|
+
if (bundle) {
|
|
455
|
+
const sharp = ` ${bundleQuantity}×`;
|
|
456
|
+
const sumBundleDiscount = bundle.amount; // bundleQuantity * bundle.discountAmount;
|
|
457
|
+
const _total = MoneyController.sumField(list, 'totalAmount');
|
|
458
|
+
// let _lastTotal = _total - sumBundleDiscount;
|
|
459
|
+
let _lastTotal = _total - sumBundleDiscount;
|
|
460
|
+
if (_lastTotal < 0) {
|
|
461
|
+
_lastTotal = 0;
|
|
462
|
+
}
|
|
463
|
+
const price = template.showPrices ? MoneyController.format(_lastTotal, detail.company.currencySymbol) : '';
|
|
464
|
+
let bundleText = bundle.text;
|
|
465
|
+
bundleText = ((_b = bundleText === null || bundleText === void 0 ? void 0 : bundleText.replace(sharp, '')) === null || _b === void 0 ? void 0 : _b.trim()) + "";
|
|
466
|
+
content += `<tr>
|
|
467
|
+
<td style="font-size:${largeFontSize}px; min-width:40px; width: 40px; text-align: left;">${sharp}</td>
|
|
468
|
+
<td style="font-size:${largeFontSize}px; flex: 1; width: 100%; text-align: left; font-weight: bold;">${bundleText}</td>
|
|
469
|
+
<td style="font-size:${largeFontSize}px; max-width: 90px; text-align: right;">${price}</td>
|
|
470
|
+
</tr>`;
|
|
471
|
+
for (let index = 0; index < list.length; index++) {
|
|
472
|
+
const row = list[index];
|
|
473
|
+
const sharp = `${row.quantity}× `;
|
|
474
|
+
let product = (template.showProductKitchenName && row.kitchenReceiptName !== '' && row.kitchenReceiptName !== null) ? row.kitchenReceiptName : row.title;
|
|
475
|
+
product = sharp + ((_c = product === null || product === void 0 ? void 0 : product.replace(sharp, '')) === null || _c === void 0 ? void 0 : _c.trim()) + "";
|
|
476
|
+
// content += `<tr>
|
|
477
|
+
// <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
|
|
478
|
+
// <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: left; column-span: 2;">${product}</td>
|
|
479
|
+
// </tr>`;
|
|
480
|
+
content += `<tr>
|
|
481
|
+
<td style="font-size:${largeFontSize}px; min-width:40px; width: 40px; text-align: left;"> </td>
|
|
482
|
+
<td style="font-size:${largeFontSize}px; flex: 1; width: 100%; text-align: left; column-span: 2;">${product}</td>
|
|
483
|
+
</tr>`;
|
|
484
|
+
if (row.extrasNames) {
|
|
485
|
+
const extList = row.extras
|
|
486
|
+
.filter(item => !item.doNotPrintOnReceipt)
|
|
487
|
+
.map(item => PrintToolController.extraItemToText(item, template.skipWholePizzaToppingText))
|
|
488
|
+
.filter(i => i.length > 0);
|
|
489
|
+
for (let ind = 0; ind < extList.length; ind++) {
|
|
490
|
+
content += `<tr>
|
|
491
|
+
<td style=" min-width:40px; width: 40px;"> </td>
|
|
492
|
+
<td style="font-size:${largeFontSize}px; flex: 1; width: 100%; text-align: left;column-span: 2; padding-left: 24px;">${extList[ind]}</td>
|
|
493
|
+
</tr>`;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
const note = PrintToolController.productNote(row);
|
|
497
|
+
if (note !== '') {
|
|
498
|
+
content += `<tr>
|
|
499
|
+
<td style=" min-width:40px; width: 40px;"> </td>
|
|
500
|
+
<td style="font-size:${largeFontSize}px; flex: 1; width: 100%; text-align: left;column-span: 2; padding-left: 24px;">${note}</td>
|
|
501
|
+
</tr>`;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
const unBundledProducts = detail.products.filter(i => !(Array.isArray(i.tags) && i.tags.findIndex(tag => tag.startsWith(BundleIdPreName)) !== -1));
|
|
509
|
+
const list = this.filterByCategoryList(this.sortProduct(unBundledProducts, template.sortProducts), template.printOnlyCertainCategoriesList, template.printOnlyCertainCategories, template.printOnlyCertainProductsList, template.printOnlyCertainProducts);
|
|
510
|
+
list.forEach((row) => {
|
|
351
511
|
const productName = (template.showCategoryTitle ? `[${row.categoryTitle}] ` : "") + ((template.showProductKitchenName && row.kitchenReceiptName !== null) ? row.kitchenReceiptName : row.title);
|
|
352
512
|
const amount = template.showPrices ? MoneyController.format(row.totalAmount, detail.company.currencySymbol) : "";
|
|
353
513
|
content += `<tr>
|
|
354
|
-
<td style="font-size:${largeFontSize}px; min-width:40px; width: 40px; text-align: left;">${row.quantity}
|
|
514
|
+
<td style="font-size:${largeFontSize}px; min-width:40px; width: 40px; text-align: left;">${row.quantity}×</td>
|
|
355
515
|
<td style="font-size:${largeFontSize}px; flex: 1; width: 100%; text-align: left; font-weight: bold;">${productName}</td>
|
|
356
516
|
<td style="font-size:${largeFontSize}px; max-width: 90px; text-align: right;">${amount}</td>
|
|
357
517
|
</tr>`;
|
|
358
518
|
row.extras.filter(i => !i.doNotPrintOnReceipt).forEach(element => {
|
|
359
|
-
const extraText = this.pizzaSideText(element.pizzaSide, template.skipWholePizzaToppingText) + element.quantity + "
|
|
519
|
+
const extraText = this.pizzaSideText(element.pizzaSide, template.skipWholePizzaToppingText) + element.quantity + "× " + element.extraItemTitle;
|
|
360
520
|
const extraAmount = template.showPrices ? MoneyController.format(element.totalAmount, detail.company.currencySymbol) : "";
|
|
361
521
|
content += `<tr>
|
|
362
522
|
<td style="font-size:${largeFontSize}px; min-width:40px; width: 40px; text-align: left;"> </td>
|
package/dist/statics.d.ts
CHANGED
|
@@ -50,3 +50,9 @@ export declare const Formats: {
|
|
|
50
50
|
printedAt: string;
|
|
51
51
|
};
|
|
52
52
|
export declare const printPoweredBy = "Powered by Meemup.com";
|
|
53
|
+
export declare const SeatTagPreName = "Seat #";
|
|
54
|
+
export declare const BundleGroupPreName = "BG #";
|
|
55
|
+
export declare const BundleIdPreName = "BI #";
|
|
56
|
+
export declare const BundleProductQuantityPreName = "BQ #";
|
|
57
|
+
export declare const BundleFeeKey = "BundleProduct";
|
|
58
|
+
export declare const OpenItemText = "Open item";
|
package/dist/statics.js
CHANGED
|
@@ -52,3 +52,9 @@ export const Formats = {
|
|
|
52
52
|
printedAt: 'YYYY-MM-DD HH:mm A',
|
|
53
53
|
};
|
|
54
54
|
export const printPoweredBy = 'Powered by Meemup.com';
|
|
55
|
+
export const SeatTagPreName = 'Seat #';
|
|
56
|
+
export const BundleGroupPreName = 'BG #';
|
|
57
|
+
export const BundleIdPreName = 'BI #';
|
|
58
|
+
export const BundleProductQuantityPreName = 'BQ #';
|
|
59
|
+
export const BundleFeeKey = 'BundleProduct';
|
|
60
|
+
export const OpenItemText = "Open item";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "meemup-library",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.34",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"remove:one": "rimraf dist",
|
|
12
12
|
"remove:two": "rimraf ./src/dist",
|
|
13
13
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
14
|
-
"commit": "git add . && git commit -m \"version.1.5.
|
|
14
|
+
"commit": "git add . && git commit -m \"version.1.5.34\" && git push origin "
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
17
|
"/dist"
|