meemup-library 1.5.32 → 1.5.33

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.
@@ -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;
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.32",
3
+ "version": "1.5.33",
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.32\" && git push origin "
14
+ "commit": "git add . && git commit -m \"version.1.5.33\" && git push origin "
15
15
  },
16
16
  "files": [
17
17
  "/dist"