meemup-library 1.9.0 → 1.9.1

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.
@@ -12,7 +12,6 @@ import IPointOfSaleSetting from "../interfaces/pos/IPointOfSaleSetting";
12
12
  import IPointOfSaleActionFormCashDrawer from "../interfaces/pos/IPointOfSaleActionFormCashDrawer";
13
13
  import IPointOfSaleApiClosingWorkDay from "../interfaces/pos/IPointOfSaleApiClosingWorkDay";
14
14
  import IReservationTableRow from "../interfaces/reservation/IReservationTableRow";
15
- import IPointOfSalePrintAction from "../interfaces/pos/IPointOfSalePrintAction";
16
15
  declare class _PreviewContentController {
17
16
  createReservationMarkup(reservation: IReservationTableRow | undefined, template: IPrintTemplate): string;
18
17
  calculatePaperSize: (paper: number, width: string | number) => string;
@@ -21,14 +20,13 @@ declare class _PreviewContentController {
21
20
  convertTimeStringToDateByT(data?: Date | string | null): Date | string | null;
22
21
  formatAMPMDate(date: Date | string | null): string;
23
22
  formatDateTime(dateTime: string, mode?: string): string;
24
- private buildLayout;
25
- simpleLayout(account: IAccount, detail: IOrderDetails, template: IPrintTemplate, task: IPointOfSalePrintAction): string;
26
- largeLayout(account: IAccount, detail: IOrderDetails, template: IPrintTemplate, task: IPointOfSalePrintAction): string;
23
+ simpleLayout(account: IAccount, detail: IOrderDetails, template: IPrintTemplate): string;
24
+ largeLayout(account: IAccount, detail: IOrderDetails, template: IPrintTemplate): string;
27
25
  labelLayout(detail: IOrderDetails, template: IPrintTemplate): string;
28
26
  paymentFailed(detail: IOrderDetails, currency: string): string;
29
27
  packageLabel(detail: IOrderDetails, template: IPrintTemplate): string;
30
- preview(account: IAccount, detail: IOrderDetails, template: IPrintTemplate, task: IPointOfSalePrintAction): string;
31
- previewForPos(account: IAccount, detail: IOrderDetails, template: IPrintTemplate, task: IPointOfSalePrintAction): string;
28
+ preview(account: IAccount, detail: IOrderDetails, template: IPrintTemplate): string;
29
+ previewForPos(account: IAccount, detail: IOrderDetails, template: IPrintTemplate): string;
32
30
  createPrintFromTurnoverDetail(data: ITurnover, currency: string, printParts: IPointOfSalePrintParts): Promise<string>;
33
31
  createCashDrawerPaidInOutMarkup(device: IPointOfSaleActionFormCashDrawer, setting: IPointOfSaleSetting, member: IPointOfSaleTeamMember): Promise<string>;
34
32
  openCashDrawerMarkup(label?: string): Promise<string>;
@@ -36,6 +34,7 @@ declare class _PreviewContentController {
36
34
  createClosingWorkDay(data: IPointOfSaleApiClosingWorkDay, companyTitle: string): Promise<string>;
37
35
  createCashDrawerReport(device: IPointOfSaleCashDrawer, form: IPointOfSaleCashDrawerReportForm, records: IPointOfSaleCashDrawerReportRecord[], company: string, currency: string, member: IPointOfSaleTeamMember, formatDate: (value: string) => string): Promise<string>;
38
36
  createPaymentInfoReceipt(detail: IOrderDetails, template: IPrintTemplate): string;
37
+ private buildLayout;
39
38
  }
40
39
  declare const PreviewContentController: _PreviewContentController;
41
40
  export default PreviewContentController;
@@ -195,78 +195,11 @@ class _PreviewContentController {
195
195
  return dateTime;
196
196
  }
197
197
  }
198
- buildLayout(account, detail, template, task, isLargeLayout = false) {
199
- const { order } = detail;
200
- const { font, width, paper, paddingTop, paddingBottom, orderSummaryPrintPlacement } = template;
201
- const fontFamily = (font === "Font A" || font === "Font B")
202
- ? "arial"
203
- : font;
204
- let content = `
205
- <div
206
- style="
207
- font-family:${fontFamily};
208
- font-weight:normal;
209
- padding:${paddingTop}px 0 ${paddingBottom}px 0;
210
- width:${this.calculatePaperSize(paper, width)};
211
- "
212
- >
213
- `;
214
- if (!order.asSoonAsPossible) {
215
- content += SimplePreviewController.printPreOrderText(template);
216
- }
217
- if (orderSummaryPrintPlacement ===
218
- EnumOrderSummaryPrintPlacementType.BeforePageHeader) {
219
- content += SimplePreviewController.printSummary(template, order);
220
- }
221
- content += SimplePreviewController.printTitle(template);
222
- if (orderSummaryPrintPlacement ===
223
- EnumOrderSummaryPrintPlacementType.AfterPageHeader) {
224
- content += SimplePreviewController.printSummary(template, order);
225
- }
226
- content += SimplePreviewController.printLogo(template, detail, account);
227
- content += SimplePreviewController.printCompanyNameAndAddress(template, detail);
228
- if (orderSummaryPrintPlacement ===
229
- EnumOrderSummaryPrintPlacementType.AfterCompanyInformation) {
230
- content += SimplePreviewController.printSummary(template, order);
231
- }
232
- content += SimplePreviewController.printTextAfterCompanyAddress(template);
233
- content += SimplePreviewController.printShowPayment(template, detail);
234
- content += SimplePreviewController.printOrderInformation(template, detail);
235
- content += SimplePreviewController.printCustomerInformation(template, detail);
236
- content += SimplePreviewController.printProductCount(template, detail, task);
237
- content += SimplePreviewController.printTextBeforeProducts(template);
238
- const productsContent = isLargeLayout
239
- ? SimplePreviewController.printLargeProducts(template, detail)
240
- : SimplePreviewController.printProducts(template, detail);
241
- if (productsContent !== "") {
242
- content += productsContent;
243
- }
244
- else {
245
- return "";
246
- }
247
- content += SimplePreviewController.printCustomerRemark(template, detail);
248
- content += SimplePreviewController.printDeliveryInstructionsRemarks(template, detail);
249
- content += SimplePreviewController.printCustomerSignature(template, detail);
250
- content += SimplePreviewController.printPromotionNote(template);
251
- content += SimplePreviewController.printMetaData(template, detail);
252
- content += SimplePreviewController.printSplitPayments(template, detail);
253
- content += SimplePreviewController.printQrCode(template, detail);
254
- content += SimplePreviewController.printTextEnd(template);
255
- content += SimplePreviewController.printFooter(template, detail);
256
- content += `</div>`;
257
- return `
258
- <div style="display:flex;">
259
- <div style="width:auto;">
260
- ${content}
261
- </div>
262
- </div>
263
- `;
198
+ simpleLayout(account, detail, template) {
199
+ return this.buildLayout(account, detail, template);
264
200
  }
265
- simpleLayout(account, detail, template, task) {
266
- return this.buildLayout(account, detail, template, task, false);
267
- }
268
- largeLayout(account, detail, template, task) {
269
- return this.buildLayout(account, detail, template, task, true);
201
+ largeLayout(account, detail, template) {
202
+ return this.buildLayout(account, detail, template);
270
203
  }
271
204
  labelLayout(detail, template) {
272
205
  const { products } = detail;
@@ -349,34 +282,35 @@ class _PreviewContentController {
349
282
  </div>
350
283
  </div>`;
351
284
  }
352
- preview(account, detail, template, task) {
285
+ preview(account, detail, template) {
353
286
  switch (template.layout) {
354
287
  case EnumPrintLayout.SIMPLE:
355
- return this.simpleLayout(account, detail, template, task);
288
+ return this.simpleLayout(account, detail, template);
356
289
  case EnumPrintLayout.LARGE:
357
- return this.largeLayout(account, detail, template, task);
358
- case EnumPrintLayout.LABEL:
290
+ return this.largeLayout(account, detail, template);
291
+ case EnumPrintLayout.LABEL: {
359
292
  const products = this.filterByCategoryList(this.sortProduct(detail.products, template.sortProducts), template.printOnlyCertainCategoriesList, template.printOnlyCertainCategories, template.printOnlyCertainProductsList, template.printOnlyCertainProducts);
360
293
  if (products.length === 0) {
361
294
  return `<div>no product </div>`;
362
295
  }
363
296
  return this.labelLayout(detail, template);
297
+ }
364
298
  case EnumPrintLayout.PACKAGE_LABEL:
365
299
  return this.packageLabel(detail, template);
366
300
  default:
367
301
  return `<div> template.layout : ${template.layout}</div>`;
368
302
  }
369
303
  }
370
- previewForPos(account, detail, template, task) {
304
+ previewForPos(account, detail, template) {
371
305
  let content;
372
306
  switch (template.layout) {
373
307
  case EnumPrintLayout.SIMPLE:
374
- content = this.simpleLayout(account, detail, template, task);
308
+ content = this.simpleLayout(account, detail, template);
375
309
  break;
376
310
  case EnumPrintLayout.LARGE:
377
- content = this.largeLayout(account, detail, template, task);
311
+ content = this.largeLayout(account, detail, template);
378
312
  break;
379
- case EnumPrintLayout.LABEL:
313
+ case EnumPrintLayout.LABEL: {
380
314
  const products = this.filterByCategoryList(this.sortProduct(detail.products, template.sortProducts), template.printOnlyCertainCategoriesList, template.printOnlyCertainCategories, template.printOnlyCertainProductsList, template.printOnlyCertainProducts);
381
315
  if (products.length === 0) {
382
316
  content = `<div>no product </div>`;
@@ -385,6 +319,7 @@ class _PreviewContentController {
385
319
  content = this.labelLayout(detail, template);
386
320
  }
387
321
  break;
322
+ }
388
323
  case EnumPrintLayout.PACKAGE_LABEL:
389
324
  content = this.packageLabel(detail, template);
390
325
  break;
@@ -830,6 +765,76 @@ class _PreviewContentController {
830
765
  content += `</div>`;
831
766
  return (`<div style="display: flex;"><div style="width : auto;">${content}</div></div>`);
832
767
  }
768
+ buildLayout(account, detail, template) {
769
+ const { order } = detail;
770
+ const { font, width, paper, paddingTop, paddingBottom, orderSummaryPrintPlacement } = template;
771
+ const fontFamily = (font === "Font A" || font === "Font B")
772
+ ? "arial"
773
+ : font;
774
+ let content = `
775
+ <div
776
+ style="
777
+ font-family:${fontFamily};
778
+ font-weight:normal;
779
+ padding:${paddingTop}px 0 ${paddingBottom}px 0;
780
+ width:${this.calculatePaperSize(paper, width)};
781
+ "
782
+ >
783
+ `;
784
+ if (!order.asSoonAsPossible) {
785
+ content += SimplePreviewController.printPreOrderText(template);
786
+ }
787
+ if (orderSummaryPrintPlacement ===
788
+ EnumOrderSummaryPrintPlacementType.BeforePageHeader) {
789
+ content += SimplePreviewController.printSummary(template, order);
790
+ }
791
+ content += SimplePreviewController.printTitle(template);
792
+ if (orderSummaryPrintPlacement ===
793
+ EnumOrderSummaryPrintPlacementType.AfterPageHeader) {
794
+ content += SimplePreviewController.printSummary(template, order);
795
+ }
796
+ content += SimplePreviewController.printLogo(template, detail, account);
797
+ content += SimplePreviewController.printCompanyNameAndAddress(template, detail);
798
+ if (orderSummaryPrintPlacement ===
799
+ EnumOrderSummaryPrintPlacementType.AfterCompanyInformation) {
800
+ content += SimplePreviewController.printSummary(template, order);
801
+ }
802
+ content += SimplePreviewController.printTextAfterCompanyAddress(template);
803
+ content += SimplePreviewController.printShowPayment(template, detail);
804
+ content += SimplePreviewController.printOrderInformation(template, detail);
805
+ content += SimplePreviewController.printCustomerInformation(template, detail);
806
+ content += SimplePreviewController.printProductCount(template, detail);
807
+ content += SimplePreviewController.printTextBeforeProducts(template);
808
+ const productsContent = template.layout === EnumPrintLayout.LARGE
809
+ ? SimplePreviewController.printLargeProducts(template, detail)
810
+ : SimplePreviewController.printProducts(template, detail);
811
+ // console.log("-------------------------------------------");
812
+ // console.log("content : \n", content);
813
+ // console.log("productsContent : \n", productsContent);
814
+ if (productsContent !== "") {
815
+ content += productsContent;
816
+ }
817
+ else {
818
+ return "";
819
+ }
820
+ content += SimplePreviewController.printCustomerRemark(template, detail);
821
+ content += SimplePreviewController.printDeliveryInstructionsRemarks(template, detail);
822
+ content += SimplePreviewController.printCustomerSignature(template, detail);
823
+ content += SimplePreviewController.printPromotionNote(template);
824
+ content += SimplePreviewController.printMetaData(template, detail);
825
+ content += SimplePreviewController.printSplitPayments(template, detail);
826
+ content += SimplePreviewController.printQrCode(template, detail);
827
+ content += SimplePreviewController.printTextEnd(template);
828
+ content += SimplePreviewController.printFooter(template, detail);
829
+ content += `</div>`;
830
+ return `
831
+ <div style="display:flex;">
832
+ <div style="width:auto;">
833
+ ${content}
834
+ </div>
835
+ </div>
836
+ `;
837
+ }
833
838
  }
834
839
  const PreviewContentController = new _PreviewContentController();
835
840
  export default PreviewContentController;
@@ -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 class _PreviewContentController {
6
+ declare class _PrintContentController {
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;
@@ -22,5 +22,5 @@ declare class _PreviewContentController {
22
22
  packageLabel(detail: IOrderDetails): string;
23
23
  preview(account: IAccount, detail: IOrderDetails, template: IPrintTemplate, symbol?: string): string;
24
24
  }
25
- declare const PreviewContentController: _PreviewContentController;
26
- export default PreviewContentController;
25
+ declare const PrintContentController: _PrintContentController;
26
+ export default PrintContentController;
@@ -1,5 +1,5 @@
1
1
  import PhoneController from "./PhoneController";
2
- class _PreviewContentController {
2
+ class _PrintContentController {
3
3
  constructor() {
4
4
  this.createAddressText = (customer) => {
5
5
  let text = "";
@@ -56,8 +56,8 @@ class _PreviewContentController {
56
56
  }
57
57
  else if (sortType === 2) {
58
58
  products.sort((a, b) => {
59
- let nameA = a.title.toUpperCase(); // ignore upper and lowercase
60
- let nameB = b.title.toUpperCase(); // ignore upper and lowercase
59
+ const nameA = a.title.toUpperCase(); // ignore upper and lowercase
60
+ const nameB = b.title.toUpperCase(); // ignore upper and lowercase
61
61
  if (nameA < nameB) {
62
62
  return -1;
63
63
  }
@@ -70,8 +70,8 @@ class _PreviewContentController {
70
70
  }
71
71
  else if (sortType === 3) {
72
72
  products.sort(function (a, b) {
73
- let nameA = a.title.toUpperCase(); // ignore upper and lowercase
74
- let nameB = b.title.toUpperCase(); // ignore upper and lowercase
73
+ const nameA = a.title.toUpperCase(); // ignore upper and lowercase
74
+ const nameB = b.title.toUpperCase(); // ignore upper and lowercase
75
75
  if (nameA > nameB) {
76
76
  return -1;
77
77
  }
@@ -124,7 +124,7 @@ class _PreviewContentController {
124
124
  try {
125
125
  const time_ = data.split("T");
126
126
  const parts = time_[1].split(":");
127
- let dd = new Date();
127
+ const dd = new Date();
128
128
  dd.setHours(isNaN(Number(parts[0])) ? 0 : Number(parts[0]));
129
129
  dd.setMinutes(isNaN(Number(parts[1])) ? 0 : Number(parts[1]));
130
130
  dd.setSeconds(isNaN(Number(parts[2])) ? 0 : Number(parts[2]));
@@ -139,11 +139,11 @@ class _PreviewContentController {
139
139
  }
140
140
  }
141
141
  formatAMPMDate(date) {
142
- let datetime = this.convertTimeStringToDateByT(date);
142
+ const datetime = this.convertTimeStringToDateByT(date);
143
143
  if (datetime instanceof Date) {
144
144
  let hours = datetime.getHours();
145
145
  let minutes = datetime.getMinutes();
146
- let ampm = hours >= 12 ? "PM" : "AM";
146
+ const ampm = hours >= 12 ? "PM" : "AM";
147
147
  hours = hours % 12;
148
148
  hours = hours ? hours : 12;
149
149
  minutes = minutes < 10 ? "0" + minutes : minutes;
@@ -155,8 +155,8 @@ class _PreviewContentController {
155
155
  }
156
156
  formatDateTime(dateTime, mode = "full") {
157
157
  try {
158
- let dt = Date.parse(dateTime);
159
- let time_ = this.formatAMPMDate(dateTime);
158
+ const dt = Date.parse(dateTime);
159
+ const time_ = this.formatAMPMDate(dateTime);
160
160
  if (mode !== "full") {
161
161
  return time_;
162
162
  }
@@ -185,7 +185,10 @@ class _PreviewContentController {
185
185
  }
186
186
  }
187
187
  formatDate(date) {
188
- let d = new Date(date), month = "" + (d.getMonth() + 1), day = "" + d.getDate(), year = d.getFullYear();
188
+ const d = new Date(date);
189
+ let month = "" + (d.getMonth() + 1);
190
+ let day = "" + d.getDate();
191
+ const year = d.getFullYear();
189
192
  if (month.length < 2)
190
193
  month = "0" + month;
191
194
  if (day.length < 2)
@@ -503,15 +506,16 @@ class _PreviewContentController {
503
506
  switch (template.layout) {
504
507
  case 2:
505
508
  return this.defaultLayout(account, detail, template, symbol);
506
- case 4:
509
+ case 4: {
507
510
  const products = this.filterByCategoryList(this.sortProduct(detail.products, template.sortProducts), template.printOnlyCertainCategoriesList, template.printOnlyCertainCategories, template.printOnlyCertainProductsList, template.printOnlyCertainProducts);
508
511
  if (products.length === 0)
509
512
  return `<div>no product </div>`;
510
513
  return this.labelLayout(detail, template);
514
+ }
511
515
  default:
512
516
  return `<div> template.layout : ${template.layout}</div>`;
513
517
  }
514
518
  }
515
519
  }
516
- const PreviewContentController = new _PreviewContentController();
517
- export default PreviewContentController;
520
+ const PrintContentController = new _PrintContentController();
521
+ export default PrintContentController;
@@ -3,7 +3,7 @@ import MoneyController from './MoneyController';
3
3
  class _PrintToolController {
4
4
  constructor() {
5
5
  this.orderItemCountText = (products, catList, onlyListCategory, productList, onlyListProduct) => {
6
- let list = this.filterProductsByCategoryList(products, catList, onlyListCategory, productList, onlyListProduct);
6
+ const list = this.filterProductsByCategoryList(products, catList, onlyListCategory, productList, onlyListProduct);
7
7
  return `${MoneyController.sum(list.map(row => row.quantity))} ITEM`;
8
8
  };
9
9
  this.filterProductsByCategoryList = (products, catList, onlyListCategory, productList, onlyListProduct) => {
@@ -36,7 +36,7 @@ class _PrintToolController {
36
36
  };
37
37
  }
38
38
  extraItemToText(item, ignoreWholeText = false, showPrices = true) {
39
- let parts = [];
39
+ const parts = [];
40
40
  switch (item.pizzaSide) {
41
41
  case EnumPizzaSide.all:
42
42
  if (!ignoreWholeText) {
@@ -72,7 +72,7 @@ class _PrintToolController {
72
72
  function splitString(str, chunkSize) {
73
73
  return Array.from({ length: Math.ceil(str.length / chunkSize) }, (_, i) => str.slice(i * chunkSize, (i + 1) * chunkSize));
74
74
  }
75
- let lineCharLength = lineWidth - indent;
75
+ const lineCharLength = lineWidth - indent;
76
76
  let parts = splitString(text, lineCharLength);
77
77
  const indentStr = ' '.repeat(indent);
78
78
  parts = parts.map(i => indentStr + i);
@@ -82,8 +82,8 @@ class _PrintToolController {
82
82
  function splitString(str, chunkSize) {
83
83
  return Array.from({ length: Math.ceil(str.length / chunkSize) }, (_, i) => str.slice(i * chunkSize, (i + 1) * chunkSize));
84
84
  }
85
- let lineCharLength = lineWidth - (price.length) - 1;
86
- let parts = splitString(bundleTitle, lineCharLength);
85
+ const lineCharLength = lineWidth - (price.length) - 1;
86
+ const parts = splitString(bundleTitle, lineCharLength);
87
87
  if (parts.length >= 1) {
88
88
  while ((parts[0].length + price.length + 1) < lineWidth) {
89
89
  parts[0] = parts[0] + ' ';
@@ -1,6 +1,5 @@
1
1
  import IAccount from "../interfaces/IAccount";
2
2
  import IPrintTemplate from "../interfaces/IPrintTemplate";
3
- import IPointOfSalePrintAction from "../interfaces/pos/IPointOfSalePrintAction.js";
4
3
  import IOrderDetailOrder from "../interfaces/print/IOrderDetailOrder";
5
4
  import IOrderDetails from "../interfaces/print/IOrderDetails";
6
5
  declare class SimplePreviewController {
@@ -13,7 +12,7 @@ declare class SimplePreviewController {
13
12
  printShowPayment(template: IPrintTemplate, detail: IOrderDetails): string;
14
13
  printOrderInformation(template: IPrintTemplate, detail: IOrderDetails): string;
15
14
  printCustomerInformation(template: IPrintTemplate, detail: IOrderDetails): string;
16
- printProductCount(template: IPrintTemplate, detail: IOrderDetails, task: IPointOfSalePrintAction): string;
15
+ printProductCount(template: IPrintTemplate, detail: IOrderDetails): string;
17
16
  printTextBeforeProducts(template: IPrintTemplate): string;
18
17
  printProductInDineIn(template: IPrintTemplate, detail: IOrderDetails): string;
19
18
  printProducts(template: IPrintTemplate, detail: IOrderDetails): string;
@@ -40,6 +39,7 @@ declare class SimplePreviewController {
40
39
  printSpace(height: number): string;
41
40
  footer(): string;
42
41
  createDivContainer(template: IPrintTemplate, pt?: number, pb?: number): string;
42
+ private renderProductsTable;
43
43
  private filterByCategoryList;
44
44
  private sortProduct;
45
45
  private pizzaSideText;