meemup-library 2.0.1 → 2.0.3

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.
@@ -745,7 +745,7 @@ class _PreviewContentController {
745
745
  content += `<p style="display:block; font-size: ${template.fontSize}px; text-align: left;">Reg. date &nbsp;&nbsp; ${dayjs(detail.order.registrationDate).format(Formats.displayDateTime)}</p>`;
746
746
  content += `<p style="display:block; font-size: ${template.fontSize}px; text-align: left;">Order &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; REF:${detail.order.id} , #${detail.order.orderNumber}</p>`;
747
747
  content += `<div style="display:flex; flex-direction : row; justify-content: space-between; align-items :center; ">
748
- <p style="font-size: ${template.fontSize * 2}px; text-align: left;">Total, ${afterTotal}</p>
748
+ <p style="font-size: ${template.fontSize * 2}px; text-align: left;">Total:${afterTotal}</p>
749
749
  <p style="font-size: ${template.fontSize * 2}px; text-align: right;">${total}</p>
750
750
  </div>`;
751
751
  content += `<div style="display:flex; flex-direction : row; justify-content:center; align-items:center; gap : 8px; margin-top:16px; margin-bottom: 16px;">
@@ -1,12 +1,17 @@
1
1
  import IOrderDetailProductsExtra from '../interfaces/print/IOrderDetailProductsExtra';
2
2
  import IOrderDetailProduct from '../interfaces/print/IOrderDetailProduct';
3
3
  declare class _PrintToolController {
4
- extraItemToText(item: IOrderDetailProductsExtra, ignoreWholeText?: boolean, showPrices?: boolean): string;
4
+ static instance: _PrintToolController;
5
+ private constructor();
6
+ static getInstance(): _PrintToolController;
7
+ extraItemToText(item: IOrderDetailProductsExtra, ignoreWholeText?: boolean, showPrice?: boolean): string;
5
8
  productNote(item: IOrderDetailProduct): string;
6
- orderItemCountText: (products: IOrderDetailProduct[], catList: number[], onlyListCategory: boolean, productList: number[], onlyListProduct: boolean) => string;
9
+ createOrderItemCount: (count: number) => string;
10
+ orderItemCount: (products: IOrderDetailProduct[], catList: number[], onlyListCategory: boolean, productList: number[], onlyListProduct: boolean) => number;
7
11
  filterProductsByCategoryList: (products: IOrderDetailProduct[], catList: number[], onlyListCategory: boolean, productList: number[], onlyListProduct: boolean) => IOrderDetailProduct[];
8
12
  textWithIndent(text: string, indent?: number, lineWidth?: number): string;
9
13
  createBundleLines(bundleTitle: string, price: string, lineWidth?: number): string;
14
+ orderItemCountText: (products: IOrderDetailProduct[], catList: number[], onlyListCategory: boolean, productList: number[], onlyListProduct: boolean) => string;
10
15
  }
11
16
  declare const PrintToolController: _PrintToolController;
12
17
  export default PrintToolController;
@@ -2,9 +2,15 @@ import EnumPizzaSide from '../enums/EnumPizzaSide';
2
2
  import MoneyController from './MoneyController';
3
3
  class _PrintToolController {
4
4
  constructor() {
5
- this.orderItemCountText = (products, catList, onlyListCategory, productList, onlyListProduct) => {
6
- const list = this.filterProductsByCategoryList(products, catList, onlyListCategory, productList, onlyListProduct);
7
- return `${MoneyController.sum(list.map(row => row.quantity))} ITEM`;
5
+ this.createOrderItemCount = (count) => {
6
+ if (count <= 1) {
7
+ return `${count} ITEM`;
8
+ }
9
+ return `${count} ITEMS`;
10
+ };
11
+ this.orderItemCount = (products, catList, onlyListCategory, productList, onlyListProduct) => {
12
+ let list = this.filterProductsByCategoryList(products, catList, onlyListCategory, productList, onlyListProduct);
13
+ return MoneyController.sum(list.map(row => row.quantity));
8
14
  };
9
15
  this.filterProductsByCategoryList = (products, catList, onlyListCategory, productList, onlyListProduct) => {
10
16
  if (!onlyListCategory && !onlyListProduct) {
@@ -34,9 +40,19 @@ class _PrintToolController {
34
40
  }
35
41
  return new_product;
36
42
  };
43
+ this.orderItemCountText = (products, catList, onlyListCategory, productList, onlyListProduct) => {
44
+ const list = this.filterProductsByCategoryList(products, catList, onlyListCategory, productList, onlyListProduct);
45
+ return `${MoneyController.sum(list.map(row => row.quantity))} ITEM`;
46
+ };
47
+ }
48
+ static getInstance() {
49
+ if (!_PrintToolController.instance) {
50
+ _PrintToolController.instance = new _PrintToolController();
51
+ }
52
+ return _PrintToolController.instance;
37
53
  }
38
- extraItemToText(item, ignoreWholeText = false, showPrices = true) {
39
- const parts = [];
54
+ extraItemToText(item, ignoreWholeText = false, showPrice = true) {
55
+ let parts = [];
40
56
  switch (item.pizzaSide) {
41
57
  case EnumPizzaSide.all:
42
58
  if (!ignoreWholeText) {
@@ -57,7 +73,7 @@ class _PrintToolController {
57
73
  if (item.extraItemOptionId !== null && item.extraItemOptionId !== -1) {
58
74
  parts.push(`[${item.extraItemOptionTitle.trim()}] `);
59
75
  }
60
- if (showPrices && item.totalAmount !== 0) {
76
+ if (showPrice && item.totalAmount !== 0) {
61
77
  parts.push(`(${MoneyController.format(item.totalAmount, '')})`);
62
78
  }
63
79
  return parts.join(' ').trim();
@@ -72,7 +88,7 @@ class _PrintToolController {
72
88
  function splitString(str, chunkSize) {
73
89
  return Array.from({ length: Math.ceil(str.length / chunkSize) }, (_, i) => str.slice(i * chunkSize, (i + 1) * chunkSize));
74
90
  }
75
- const lineCharLength = lineWidth - indent;
91
+ let lineCharLength = lineWidth - indent;
76
92
  let parts = splitString(text, lineCharLength);
77
93
  const indentStr = ' '.repeat(indent);
78
94
  parts = parts.map(i => indentStr + i);
@@ -82,10 +98,10 @@ class _PrintToolController {
82
98
  function splitString(str, chunkSize) {
83
99
  return Array.from({ length: Math.ceil(str.length / chunkSize) }, (_, i) => str.slice(i * chunkSize, (i + 1) * chunkSize));
84
100
  }
85
- const lineCharLength = lineWidth - (price.length) - 1;
86
- const parts = splitString(bundleTitle, lineCharLength);
101
+ let lineCharLength = lineWidth - price.length - 1;
102
+ let parts = splitString(bundleTitle, lineCharLength);
87
103
  if (parts.length >= 1) {
88
- while ((parts[0].length + price.length + 1) < lineWidth) {
104
+ while (parts[0].length + price.length + 1 < lineWidth) {
89
105
  parts[0] = parts[0] + ' ';
90
106
  }
91
107
  parts[0] = parts[0] + ' ' + price;
@@ -95,5 +111,5 @@ class _PrintToolController {
95
111
  return parts.join('\n') + '\n';
96
112
  }
97
113
  }
98
- const PrintToolController = new _PrintToolController();
114
+ const PrintToolController = _PrintToolController.getInstance();
99
115
  export default PrintToolController;
@@ -163,7 +163,7 @@ class SimplePreviewController {
163
163
  const list = this.filterByCategoryList(this.sortProduct(detail.products, template.sortProducts), template.printOnlyCertainCategoriesList, template.printOnlyCertainCategories, template.printOnlyCertainProductsList, template.printOnlyCertainProducts);
164
164
  const count = MoneyController.sum(list.map(i => i.quantity));
165
165
  return `${this.createDivContainer(template)}
166
- <p style="display: block; font-size: ${template.fontSize + 10}px; text-align: left; margin-top : 8px;">${count} ITEM</p>
166
+ <p style="display: block; font-size: ${template.fontSize + 10}px; text-align: left; margin-top : 8px;">${count <= 1 ? `${count} ITEM` : `${count} ITEMS`}</p>
167
167
  </div>`;
168
168
  }
169
169
  printTextBeforeProducts(template) {
@@ -410,13 +410,14 @@ class SimplePreviewController {
410
410
  if ((template.printProductsBySeat && detail.order.orderType === EnumOrderType.dining && detail.order.tableId !== null && seats.length > 0) || (detail.order.orderType === EnumOrderType.dining && detail.order.tableId !== null && seats.length > 0)) {
411
411
  return this.printProductInDineIn(template, detail);
412
412
  }
413
+ const count = PrintToolController.orderItemCount(this.sortProduct(detail.products, template.sortProducts), template.printOnlyCertainCategoriesList, template.printOnlyCertainCategories, template.printOnlyCertainProductsList, template.printOnlyCertainProducts);
413
414
  let flag = true;
414
415
  let content = `${this.createDivContainer(template)}
415
416
  <table style="width: 100%; border-collapse: collapse;">
416
417
  <thead style="border-bottom: 1px solid #000000;">
417
418
  <tr style="${isLarge ? '' : 'height: 28px;'}">
418
419
  <th style="font-size:${template.fontSize}px;min-width:40px; width: 40px; text-align: left; font-weight: bold;">#</th>
419
- <th style="font-size:${template.fontSize}px;flex: 1; width: 100%; text-align: left; font-weight: bold; ">Items</th>
420
+ <th style="font-size:${template.fontSize}px;flex: 1; width: 100%; text-align: left; font-weight: bold; ">${count <= 1 ? "Item" : "Items"}</th>
420
421
  <th style="font-size:${template.fontSize}px;max-width: 90px; text-align: right; font-weight: bold;">Price</th>
421
422
  </tr>
422
423
  </thead>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meemup-library",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
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.2.0.1\" && git push origin "
14
+ "commit": "git add . && git commit -m \"version.2.0.3\" && git push origin "
15
15
  },
16
16
  "files": [
17
17
  "/dist"