meemup-library 1.6.6 → 1.6.8

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.
@@ -1,6 +1,6 @@
1
+ import IAccount from "../interfaces/IAccount";
1
2
  import IPrintTemplate from "../interfaces/IPrintTemplate";
2
3
  import IOrderDetailOrder from "../interfaces/print/IOrderDetailOrder";
3
- import IAccount from "../interfaces/IAccount";
4
4
  import IOrderDetails from "../interfaces/print/IOrderDetails";
5
5
  declare class SimplePreviewController {
6
6
  printPreOrderText(template: IPrintTemplate): string;
@@ -14,6 +14,7 @@ declare class SimplePreviewController {
14
14
  printCustomerInformation(template: IPrintTemplate, detail: IOrderDetails): string;
15
15
  printProductCount(template: IPrintTemplate, detail: IOrderDetails): string;
16
16
  printTextBeforeProducts(template: IPrintTemplate): string;
17
+ printProductInDineIn(template: IPrintTemplate, detail: IOrderDetails): string;
17
18
  printProducts(template: IPrintTemplate, detail: IOrderDetails): string;
18
19
  printLargeProducts(template: IPrintTemplate, detail: IOrderDetails): string;
19
20
  printCustomerRemark(template: IPrintTemplate, detail: IOrderDetails): string;
@@ -1,16 +1,19 @@
1
- import PrintToolController from "./PrintToolController.js";
2
1
  import EnumFeeType from "../enums/EnumFeeType.js";
3
- import PhoneController from "./PhoneController";
4
- import EnumPaymentType from "../enums/EnumPaymentType";
5
- import MoneyController from "./MoneyController";
6
- import EnumShowCustomer from "../enums/EnumShowCustomer";
2
+ import EnumOrderDateTimePrintModeType from "../enums/EnumOrderDateTimePrintModeType";
7
3
  import EnumOrderType from "../enums/EnumOrderType";
8
- import EnumPizzaSide from "../enums/EnumPizzaSide";
9
4
  import EnumPaymentState from "../enums/EnumPaymentState";
10
- import OrderToolController from "./OrderToolController";
11
- import EnumOrderDateTimePrintModeType from "../enums/EnumOrderDateTimePrintModeType";
12
- import { BundleGroupPreName, BundleIdPreName, BundleProductQuantityPreName, Formats, printPoweredBy } from "../statics";
5
+ import EnumPaymentType from "../enums/EnumPaymentType";
6
+ import EnumPizzaSide from "../enums/EnumPizzaSide";
7
+ import EnumPointOfSaleOrderItemSharingType from "../enums/EnumPointOfSaleOrderItemSharingType.js";
8
+ import EnumPrintLayout from "../enums/EnumPrintLayout.js";
9
+ import EnumShowCustomer from "../enums/EnumShowCustomer";
10
+ import { BundleGroupPreName, BundleProductQuantityPreName, Formats, printPoweredBy } from "../statics";
13
11
  import dayjs from "../utils/dayjs";
12
+ import MoneyController from "./MoneyController";
13
+ import OrderToolController from "./OrderToolController";
14
+ import PhoneController from "./PhoneController";
15
+ import PrintToolController from "./PrintToolController.js";
16
+ import TagToolController from "./tag-tool-controller.js";
14
17
  class SimplePreviewController {
15
18
  constructor() {
16
19
  this.filterByCategoryList = (products, catList, onlyListCategory, productList, onlyListProduct) => {
@@ -227,11 +230,97 @@ class SimplePreviewController {
227
230
  content += `</div>`;
228
231
  return content;
229
232
  }
233
+ printProductInDineIn(template, detail) {
234
+ var _a;
235
+ const TagController = TagToolController.getInstance();
236
+ let flag = true;
237
+ const fontSize = template.layout === EnumPrintLayout.LARGE ? (template.printer === 5 ? 22 : parseInt((template.fontSize + 10) + "")) : template.fontSize;
238
+ const seats = TagController.allSeatInOrderDetail(detail.products);
239
+ let content = this.createDivContainer(template);
240
+ const list = this.filterByCategoryList(this.sortProduct(detail.products, template.sortProducts), template.printOnlyCertainCategoriesList, template.printOnlyCertainCategories, template.printOnlyCertainProductsList, template.printOnlyCertainProducts);
241
+ if (list.length > 0) {
242
+ flag = false;
243
+ }
244
+ if (flag)
245
+ return "";
246
+ for (let index = 0; index < seats.length; index++) {
247
+ const seatId = seats[index];
248
+ //
249
+ content += `<div style="margin-botttom:8px; font-size:${fontSize * 1.2}px; font-weight:bold; text-align:left; background-color:black; color:white; padding:4px 8px;">
250
+ ${TagController.createSeatLabel(seatId)}
251
+ </div>`;
252
+ // 2. Iterate over the array using a standard 'for' loop
253
+ for (let i = 0; i < list.length; i++) {
254
+ const row = detail.products[i]; // Get the current product (IOrderDetailProduct)
255
+ const productSeats = TagController.tagsToOrderItemSeats(row.tags || []);
256
+ const productSeatIdList = TagController.tagsToOrderItemSeats(row.tags || []).map(i => i.seatId);
257
+ const seat = productSeats.find(i => i.seatId === seatId);
258
+ const tagSharingType = TagController.findTagSharingType(row.tags);
259
+ const sharingType = TagController.tagToSharingType(tagSharingType);
260
+ if (productSeatIdList.includes(seatId)) {
261
+ let sharp = `${row.quantity}×`;
262
+ let quantity = row.quantity;
263
+ switch (sharingType) {
264
+ case EnumPointOfSaleOrderItemSharingType.Single:
265
+ sharp = `${(seat === null || seat === void 0 ? void 0 : seat.ratio) || 1}×`;
266
+ quantity = (seat === null || seat === void 0 ? void 0 : seat.ratio) || 1;
267
+ break;
268
+ case EnumPointOfSaleOrderItemSharingType.EqualSplit:
269
+ sharp = `1/${productSeats.length}`;
270
+ quantity = +((((seat === null || seat === void 0 ? void 0 : seat.ratio) || 1) / MoneyController.sumField(productSeats, "ratio")).toFixed(2));
271
+ break;
272
+ case EnumPointOfSaleOrderItemSharingType.Shared:
273
+ sharp = `${(seat === null || seat === void 0 ? void 0 : seat.ratio) || 1}/${MoneyController.sumField(productSeats, "ratio")}`;
274
+ quantity = +((((seat === null || seat === void 0 ? void 0 : seat.ratio) || 1) / MoneyController.sumField(productSeats, "ratio")).toFixed(2));
275
+ break;
276
+ default:
277
+ break;
278
+ }
279
+ let price = template.showPrices ? `${MoneyController.format(quantity * row.price, detail.company.currencySymbol)}` : '';
280
+ let productName = (template.showProductKitchenName && row.kitchenReceiptName !== '' && row.kitchenReceiptName !== null ? row.kitchenReceiptName : row.productName).trim();
281
+ productName = ((_a = productName === null || productName === void 0 ? void 0 : productName.replace(sharp, '')) === null || _a === void 0 ? void 0 : _a.trim()) + '';
282
+ content += `<div style="display:flex; flex-direction:row; align-items:center; justify-content: flex-start; gap: 8px;">
283
+ <span style="font-size:${fontSize}px; min-width:40px; width: 40px; text-align: left;">${sharp}</span>
284
+ <span style="font-size:${fontSize}px; flex: 1; width: 100%; text-align: left; font-weight: bold;">${productName}</span>
285
+ <span style="font-size:${fontSize}px; max-width: 90px; text-align: right;">${price}</span>
286
+ </div>`;
287
+ // -------------------------
288
+ if (row.extrasNames) {
289
+ const extList = row.extras
290
+ .filter(item => !item.doNotPrintOnReceipt)
291
+ .map(item => PrintToolController.extraItemToText(item, template.skipWholePizzaToppingText, template.showPrices))
292
+ .filter(i => i.length > 0);
293
+ for (let ind = 0; ind < extList.length; ind++) {
294
+ content += `<div style="display:flex; flex-direction:row; align-items:center; justify-content: flex-start; gap: 8px;">
295
+ <span style="font-size:${fontSize}px; min-width:40px; width: 40px; text-align: left;"></span>
296
+ <span style="font-size:${fontSize}px; flex: 1; width: 100%; text-align: left; column-span: 2; padding-left: 24px;">${extList[ind]}</span>
297
+ </div>`;
298
+ }
299
+ }
300
+ const note = PrintToolController.productNote(row);
301
+ if (note !== '') {
302
+ content += `<div style="display:flex; flex-direction:row; align-items:center; justify-content: flex-start; gap: 8px;">
303
+ <span style="font-size:${fontSize}px; min-width:40px; width: 40px; text-align: left;"></span>
304
+ <span style="font-size:${fontSize}px; font-weight: bold; flex: 1; width: 100%; text-align: left; column-span: 2; padding-left: 24px;">${note}</span>
305
+ </div>`;
306
+ }
307
+ }
308
+ }
309
+ content += this.printSolidLine();
310
+ }
311
+ return content;
312
+ }
230
313
  printProducts(template, detail) {
231
314
  var _a, _b, _c;
315
+ const TagController = TagToolController.getInstance();
232
316
  let flag = true;
233
- let content = this.createDivContainer(template);
234
- content += `<table style="width: 100%; border-collapse: collapse;">
317
+ const seats = TagController.allSeatInOrderDetail(detail.products);
318
+ if (detail.order.orderType === EnumOrderType.dining && detail.order.tableId !== null && seats.length > 0) {
319
+ return this.printProductInDineIn(template, detail);
320
+ }
321
+ else {
322
+ let content = this.createDivContainer(template);
323
+ content += `<table style="width: 100%; border-collapse: collapse;">
235
324
  <thead style="border-bottom: 1px solid #000000;">
236
325
  <tr style="height: 28px;">
237
326
  <th style="font-size:${template.fontSize}px;min-width:40px; width: 40px; text-align: left; font-weight: bold;">#</th>
@@ -241,129 +330,129 @@ class SimplePreviewController {
241
330
  </thead>
242
331
  <tbody>
243
332
  `;
244
- const bundledProducts = detail.products.filter(i => Array.isArray(i.tags) && i.tags.findIndex(tag => tag.startsWith(BundleIdPreName)) !== -1);
245
- if (bundledProducts.length > 0) {
246
- flag = false;
247
- const bundleGroups = [];
248
- bundledProducts.forEach(pro => {
249
- var _a;
250
- const tag = (_a = pro.tags) === null || _a === void 0 ? void 0 : _a.find(i => i.startsWith(BundleGroupPreName));
251
- if (tag) {
252
- const bundleGroup = (tag + '').split(BundleGroupPreName)[1];
253
- if (!bundleGroups.includes(bundleGroup)) {
254
- bundleGroups.push(bundleGroup);
255
- }
256
- }
257
- });
258
- const bundles = detail.order.items.filter(i => i.type === EnumFeeType.BundleProduct);
259
- for (let ind = 0; ind < bundleGroups.length; ind++) {
260
- const group = bundleGroups[ind] + '';
261
- const groupTag = BundleGroupPreName + group;
262
- const list = bundledProducts.filter(pro => Array.isArray(pro.tags) && pro.tags.includes(groupTag));
263
- if (list.length > 0) {
264
- const firstItem = list[0];
265
- // const bundleGroup: string = (firstItem.tags?.find(i => i.startsWith(BundleGroupPreName)) + '').split(BundleGroupPreName)[1];
266
- // const bundleId: number = +(firstItem.tags?.find(i => i.startsWith(BundleIdPreName)) + '').split(BundleIdPreName)[1];
267
- const firstItemRatio = +(((_a = firstItem.tags) === null || _a === void 0 ? void 0 : _a.find(i => i.startsWith(BundleProductQuantityPreName))) + '').split(BundleProductQuantityPreName)[1];
268
- const bundleQuantity = firstItem.quantity / firstItemRatio;
269
- 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; });
270
- if (bundle) {
271
- const sharp = ` ${bundleQuantity}×`;
272
- const sumBundleDiscount = bundle.amount; // bundleQuantity * bundle.discountAmount;
273
- const _total = MoneyController.sumField(list, 'totalAmount');
274
- // let _lastTotal = _total - sumBundleDiscount;
275
- let _lastTotal = _total - sumBundleDiscount;
276
- if (_lastTotal < 0) {
277
- _lastTotal = 0;
333
+ let bundledProducts = detail.products.filter(i => TagController.findTagBundleId(i.tags) !== undefined);
334
+ if (bundledProducts.length > 0) {
335
+ flag = false;
336
+ const bundleGroups = [];
337
+ bundledProducts.forEach(pro => {
338
+ var _a;
339
+ const tag = (_a = pro.tags) === null || _a === void 0 ? void 0 : _a.find(i => i.startsWith(BundleGroupPreName));
340
+ if (tag) {
341
+ const bundleGroup = (tag + '').split(BundleGroupPreName)[1];
342
+ if (!bundleGroups.includes(bundleGroup)) {
343
+ bundleGroups.push(bundleGroup);
278
344
  }
279
- const price = template.showPrices ? MoneyController.format(_lastTotal, detail.company.currencySymbol) : '';
280
- let bundleText = bundle.text;
281
- bundleText = ((_b = bundleText === null || bundleText === void 0 ? void 0 : bundleText.replace(sharp, '')) === null || _b === void 0 ? void 0 : _b.trim()) + "";
282
- content += `<tr style="height: 28px;">
345
+ }
346
+ });
347
+ const bundles = detail.order.items.filter(i => i.type === EnumFeeType.BundleProduct);
348
+ for (let ind = 0; ind < bundleGroups.length; ind++) {
349
+ const group = bundleGroups[ind] + '';
350
+ const groupTag = BundleGroupPreName + group;
351
+ const list = bundledProducts.filter(pro => Array.isArray(pro.tags) && pro.tags.includes(groupTag));
352
+ if (list.length > 0) {
353
+ const firstItem = list[0];
354
+ // const bundleGroup: string = (firstItem.tags?.find(i => i.startsWith(BundleGroupPreName)) + '').split(BundleGroupPreName)[1];
355
+ // const bundleId: number = +(firstItem.tags?.find(i => i.startsWith(BundleIdPreName)) + '').split(BundleIdPreName)[1];
356
+ const firstItemRatio = +(((_a = firstItem.tags) === null || _a === void 0 ? void 0 : _a.find(i => i.startsWith(BundleProductQuantityPreName))) + '').split(BundleProductQuantityPreName)[1];
357
+ const bundleQuantity = firstItem.quantity / firstItemRatio;
358
+ 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; });
359
+ if (bundle) {
360
+ const sharp = ` ${bundleQuantity}×`;
361
+ const sumBundleDiscount = bundle.amount; // bundleQuantity * bundle.discountAmount;
362
+ const _total = MoneyController.sumField(list, 'totalAmount');
363
+ // let _lastTotal = _total - sumBundleDiscount;
364
+ let _lastTotal = _total - sumBundleDiscount;
365
+ if (_lastTotal < 0) {
366
+ _lastTotal = 0;
367
+ }
368
+ const price = template.showPrices ? MoneyController.format(_lastTotal, detail.company.currencySymbol) : '';
369
+ let bundleText = bundle.text;
370
+ bundleText = ((_b = bundleText === null || bundleText === void 0 ? void 0 : bundleText.replace(sharp, '')) === null || _b === void 0 ? void 0 : _b.trim()) + "";
371
+ content += `<tr style="height: 28px;">
283
372
  <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;">${sharp}</td>
284
373
  <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: left; font-weight: bold;">${bundleText}</td>
285
374
  <td style="font-size:${template.fontSize}px; max-width: 90px; text-align: right;">${price}</td>
286
375
  </tr>`;
287
- for (let index = 0; index < list.length; index++) {
288
- const row = list[index];
289
- const sharp = `${row.quantity}× `;
290
- let product = (template.showProductKitchenName && typeof row.kitchenReceiptName === "string" && row.kitchenReceiptName.trim().length > 0) ? row.kitchenReceiptName : row.title;
291
- product = sharp + ((_c = product === null || product === void 0 ? void 0 : product.replace(sharp, '')) === null || _c === void 0 ? void 0 : _c.trim()) + "";
292
- content += `<tr>
376
+ for (let index = 0; index < list.length; index++) {
377
+ const row = list[index];
378
+ const sharp = `${row.quantity}× `;
379
+ let product = (template.showProductKitchenName && typeof row.kitchenReceiptName === "string" && row.kitchenReceiptName.trim().length > 0) ? row.kitchenReceiptName : row.title;
380
+ product = sharp + ((_c = product === null || product === void 0 ? void 0 : product.replace(sharp, '')) === null || _c === void 0 ? void 0 : _c.trim()) + "";
381
+ content += `<tr>
293
382
  <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
294
383
  <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: left; column-span: 2;">${product}</td>
295
384
  </tr>`;
296
- if (row.extrasNames) {
297
- const extList = row.extras
298
- .filter(item => !item.doNotPrintOnReceipt)
299
- .map(item => PrintToolController.extraItemToText(item, template.skipWholePizzaToppingText, template.showPrices))
300
- .filter(i => i.length > 0);
301
- for (let ind = 0; ind < extList.length; ind++) {
302
- content += `<tr>
385
+ if (row.extrasNames) {
386
+ const extList = row.extras
387
+ .filter(item => !item.doNotPrintOnReceipt)
388
+ .map(item => PrintToolController.extraItemToText(item, template.skipWholePizzaToppingText, template.showPrices))
389
+ .filter(i => i.length > 0);
390
+ for (let ind = 0; ind < extList.length; ind++) {
391
+ content += `<tr>
303
392
  <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
304
393
  <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: left; column-span: 2; padding-left: 24px;">${extList[ind]}</td>
305
394
  </tr>`;
395
+ }
306
396
  }
307
- }
308
- const note = PrintToolController.productNote(row);
309
- if (note !== '') {
310
- content += `<tr>
397
+ const note = PrintToolController.productNote(row);
398
+ if (note !== '') {
399
+ content += `<tr>
311
400
  <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
312
401
  <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>
313
402
  </tr>`;
403
+ }
314
404
  }
315
405
  }
316
406
  }
317
407
  }
318
408
  }
319
- }
320
- const unBundledProducts = detail.products.filter(i => !(Array.isArray(i.tags) && i.tags.findIndex(tag => tag.startsWith(BundleIdPreName)) !== -1));
321
- const list = this.filterByCategoryList(this.sortProduct(unBundledProducts, template.sortProducts), template.printOnlyCertainCategoriesList, template.printOnlyCertainCategories, template.printOnlyCertainProductsList, template.printOnlyCertainProducts);
322
- if (list.length > 0) {
323
- flag = false;
324
- }
325
- if (flag)
326
- return "";
327
- list.forEach((row) => {
328
- let cat;
329
- if (!template.showCategoryTitle || !row.categoryTitle || row.categoryTitle.trim().length === 0)
330
- cat = "";
331
- else
332
- cat = `[${row.categoryTitle.trim()}] `;
333
- const productName = cat + ((template.showProductKitchenName && typeof row.kitchenReceiptName === "string" && row.kitchenReceiptName.trim().length > 0) ? row.kitchenReceiptName : row.productName).trim();
334
- const amount = template.showPrices ? MoneyController.format(row.totalAmount, detail.company.currencySymbol) : "";
335
- content += `<tr style="height: 28px;">
409
+ let unBundledProducts = detail.products.filter(i => TagController.findTagBundleId(i.tags) === undefined);
410
+ const list = this.filterByCategoryList(this.sortProduct(unBundledProducts, template.sortProducts), template.printOnlyCertainCategoriesList, template.printOnlyCertainCategories, template.printOnlyCertainProductsList, template.printOnlyCertainProducts);
411
+ if (list.length > 0) {
412
+ flag = false;
413
+ }
414
+ if (flag)
415
+ return "";
416
+ list.forEach((row) => {
417
+ let cat;
418
+ if (!template.showCategoryTitle || !row.categoryTitle || row.categoryTitle.trim().length === 0)
419
+ cat = "";
420
+ else
421
+ cat = `[${row.categoryTitle.trim()}] `;
422
+ const productName = cat + ((template.showProductKitchenName && typeof row.kitchenReceiptName === "string" && row.kitchenReceiptName.trim().length > 0) ? row.kitchenReceiptName : row.productName).trim();
423
+ const amount = template.showPrices ? MoneyController.format(row.totalAmount, detail.company.currencySymbol) : "";
424
+ content += `<tr style="height: 28px;">
336
425
  <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;">${row.quantity}X</td>
337
426
  <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: left; font-weight: bold;">${productName}</td>
338
427
  <td style="font-size:${template.fontSize}px; max-width: 90px; text-align: right;">${amount}</td>
339
428
  </tr>`;
340
- row.extras.filter(i => !i.doNotPrintOnReceipt).forEach(element => {
341
- const side = this.pizzaSideText(element.pizzaSide, template.skipWholePizzaToppingText);
342
- let extraText = "";
343
- if (side !== "")
344
- extraText += side;
345
- if (element.quantity > 1)
346
- extraText += element.quantity + "x ";
347
- extraText += element.extraItemTitle;
348
- extraText = extraText.trim();
349
- const extraAmount = template.showPrices ? MoneyController.format(element.totalAmount, detail.company.currencySymbol) : "";
350
- content += `<tr>
429
+ row.extras.filter(i => !i.doNotPrintOnReceipt).forEach(element => {
430
+ const side = this.pizzaSideText(element.pizzaSide, template.skipWholePizzaToppingText);
431
+ let extraText = "";
432
+ if (side !== "")
433
+ extraText += side;
434
+ if (element.quantity > 1)
435
+ extraText += element.quantity + "x ";
436
+ extraText += element.extraItemTitle;
437
+ extraText = extraText.trim();
438
+ const extraAmount = template.showPrices ? MoneyController.format(element.totalAmount, detail.company.currencySymbol) : "";
439
+ content += `<tr>
351
440
  <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
352
441
  <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: left;">${extraText}</td>
353
442
  <td style="font-size:${template.fontSize}px; max-width: 90px; text-align: right;">${extraAmount}</td>
354
443
  </tr>`;
355
- });
356
- if (row.note !== null && row.note.trim().length > 0) {
357
- content += `<tr>
444
+ });
445
+ if (row.note !== null && row.note.trim().length > 0) {
446
+ content += `<tr>
358
447
  <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;">Note:</td>
359
448
  <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: left;font-weight: bold;">${row.note}</td>
360
449
  <td style="font-size:${template.fontSize}px; max-width: 90px; text-align: right;"></td>
361
450
  </tr>`;
362
- }
363
- });
364
- if (template.showPrices) {
365
- //order amount
366
- content += `<tr style=" border-top: 1px dashed #000000; padding: 4px 0;">
451
+ }
452
+ });
453
+ if (template.showPrices) {
454
+ //order amount
455
+ content += `<tr style=" border-top: 1px dashed #000000; padding: 4px 0;">
367
456
  <td style="font-size:${template.fontSize}px; width: 40px; text-align: left;"></td>
368
457
  <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right;padding-right: 8px;">
369
458
  Order Amount:
@@ -372,9 +461,9 @@ class SimplePreviewController {
372
461
  ${MoneyController.format(detail.order.orderAmount, detail.company.currencySymbol)}
373
462
  </td>
374
463
  </tr>`;
375
- if (detail.order.orderType === EnumOrderType.delivery && detail.order.deliveryCost > 0) {
376
- //delivery amount
377
- content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
464
+ if (detail.order.orderType === EnumOrderType.delivery && detail.order.deliveryCost > 0) {
465
+ //delivery amount
466
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
378
467
  <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
379
468
  <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right;padding-right: 8px;">
380
469
  Delivery costs:
@@ -383,10 +472,10 @@ class SimplePreviewController {
383
472
  ${MoneyController.format(detail.order.deliveryCost, detail.company.currencySymbol)}
384
473
  </td>
385
474
  </tr>`;
386
- }
387
- if (detail.order.discountAmount > 0) {
388
- //discount amount
389
- content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
475
+ }
476
+ if (detail.order.discountAmount > 0) {
477
+ //discount amount
478
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
390
479
  <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
391
480
  <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right;padding-right: 8px;">
392
481
  Discount:
@@ -395,9 +484,9 @@ class SimplePreviewController {
395
484
  ${MoneyController.format(detail.order.discountAmount, detail.company.currencySymbol)}
396
485
  </td>
397
486
  </tr>`;
398
- }
399
- //subtotal amount
400
- content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
487
+ }
488
+ //subtotal amount
489
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
401
490
  <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
402
491
  <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right;padding-right: 8px;">
403
492
  Subtotal:
@@ -406,9 +495,9 @@ class SimplePreviewController {
406
495
  ${MoneyController.format(detail.order.subtotalAmount, detail.company.currencySymbol)}
407
496
  </td>
408
497
  </tr>`;
409
- if (detail.order.hstAmount > 0) {
410
- //hst and service fee and company fee amount
411
- content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
498
+ if (detail.order.hstAmount > 0) {
499
+ //hst and service fee and company fee amount
500
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
412
501
  <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
413
502
  <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right; padding-right: 8px;">
414
503
  HST(${MoneyController.format(detail.order.hstPercentage, "%")}):
@@ -417,10 +506,10 @@ class SimplePreviewController {
417
506
  ${MoneyController.format(detail.order.hstAmount, detail.company.currencySymbol)}
418
507
  </td>
419
508
  </tr>`;
420
- }
421
- if (detail.order.tipAmount > 0) {
422
- //tip amount
423
- content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
509
+ }
510
+ if (detail.order.tipAmount > 0) {
511
+ //tip amount
512
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
424
513
  <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
425
514
  <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right; padding-right: 8px;">
426
515
  Tip:
@@ -429,10 +518,10 @@ class SimplePreviewController {
429
518
  ${MoneyController.format(detail.order.tipAmount, detail.company.currencySymbol)}
430
519
  </td>
431
520
  </tr>`;
432
- }
433
- if (detail.order.thirdPartyDriverTipAmount > 0) {
434
- //tip amount
435
- content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
521
+ }
522
+ if (detail.order.thirdPartyDriverTipAmount > 0) {
523
+ //tip amount
524
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
436
525
  <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
437
526
  <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right; padding-right: 8px;">
438
527
  Driver tip:
@@ -441,12 +530,12 @@ class SimplePreviewController {
441
530
  ${MoneyController.format(detail.order.thirdPartyDriverTipAmount, detail.company.currencySymbol)}
442
531
  </td>
443
532
  </tr>`;
533
+ }
444
534
  }
445
- }
446
- content += `</tbody></table>`;
447
- if (template.showPrices) {
448
- //total amount
449
- content += `<div style="display: flex; flex-direction: row; align-items: center; background-color: black; padding: 4px;">
535
+ content += `</tbody></table>`;
536
+ if (template.showPrices) {
537
+ //total amount
538
+ content += `<div style="display: flex; flex-direction: row; align-items: center; background-color: black; padding: 4px;">
450
539
  <div style="font-size:${template.fontSize + 6}px; flex: 1; text-align: right; padding-right: 8px; background-color: transparent; color: white;">
451
540
  ${detail.order.paymentState !== EnumPaymentState.Paid ? "Total & NOT PAID" : "Total"}:
452
541
  </div>
@@ -454,16 +543,23 @@ class SimplePreviewController {
454
543
  ${MoneyController.format(detail.order.totalAmount, detail.company.currencySymbol)}
455
544
  </div>
456
545
  </div>`;
546
+ }
547
+ content += `</div>`;
548
+ return content;
457
549
  }
458
- content += `</div>`;
459
- return content;
460
550
  }
461
551
  printLargeProducts(template, detail) {
462
552
  var _a, _b, _c;
553
+ const TagController = TagToolController.getInstance();
463
554
  let flag = true;
464
- let content = this.createDivContainer(template);
465
- const largeFontSize = template.printer === 5 ? 22 : parseInt((template.fontSize + 10) + "");
466
- content += `<table style="width: 100%; border-collapse: collapse;">
555
+ const seats = TagController.allSeatInOrderDetail(detail.products);
556
+ if (detail.order.orderType === EnumOrderType.dining && detail.order.tableId !== null && seats.length > 0) {
557
+ return this.printProductInDineIn(template, detail);
558
+ }
559
+ else {
560
+ let content = this.createDivContainer(template);
561
+ const largeFontSize = template.printer === 5 ? 22 : parseInt((template.fontSize + 10) + "");
562
+ content += `<table style="width: 100%; border-collapse: collapse;">
467
563
  <thead style="border-bottom: 1px solid #000000;">
468
564
  <tr>
469
565
  <th style="font-size:${template.fontSize}px;min-width:40px; width: 40px; text-align: left; font-weight: bold;">#</th>
@@ -473,115 +569,115 @@ class SimplePreviewController {
473
569
  </thead>
474
570
  <tbody>
475
571
  `;
476
- const bundledProducts = detail.products.filter(i => Array.isArray(i.tags) && i.tags.findIndex(tag => tag.startsWith(BundleIdPreName)) !== -1);
477
- if (bundledProducts.length > 0) {
478
- flag = false;
479
- const bundleGroups = [];
480
- bundledProducts.forEach(pro => {
481
- var _a;
482
- const tag = (_a = pro.tags) === null || _a === void 0 ? void 0 : _a.find(i => i.startsWith(BundleGroupPreName));
483
- if (tag) {
484
- const bundleGroup = (tag + '').split(BundleGroupPreName)[1];
485
- if (!bundleGroups.includes(bundleGroup)) {
486
- bundleGroups.push(bundleGroup);
487
- }
488
- }
489
- });
490
- const bundles = detail.order.items.filter(i => i.type === EnumFeeType.BundleProduct);
491
- for (let ind = 0; ind < bundleGroups.length; ind++) {
492
- const group = bundleGroups[ind] + '';
493
- const groupTag = BundleGroupPreName + group;
494
- const list = bundledProducts.filter(pro => Array.isArray(pro.tags) && pro.tags.includes(groupTag));
495
- if (list.length > 0) {
496
- const firstItem = list[0];
497
- const firstItemRatio = +(((_a = firstItem.tags) === null || _a === void 0 ? void 0 : _a.find(i => i.startsWith(BundleProductQuantityPreName))) + '').split(BundleProductQuantityPreName)[1];
498
- const bundleQuantity = firstItem.quantity / firstItemRatio;
499
- 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; });
500
- if (bundle) {
501
- const sharp = ` ${bundleQuantity}×`;
502
- const sumBundleDiscount = bundle.amount; // bundleQuantity * bundle.discountAmount;
503
- const _total = MoneyController.sumField(list, 'totalAmount');
504
- // let _lastTotal = _total - sumBundleDiscount;
505
- let _lastTotal = _total - sumBundleDiscount;
506
- if (_lastTotal < 0) {
507
- _lastTotal = 0;
572
+ let bundledProducts = detail.products.filter(i => TagController.findTagBundleId(i.tags) !== undefined);
573
+ if (bundledProducts.length > 0) {
574
+ flag = false;
575
+ const bundleGroups = [];
576
+ bundledProducts.forEach(pro => {
577
+ var _a;
578
+ const tag = (_a = pro.tags) === null || _a === void 0 ? void 0 : _a.find(i => i.startsWith(BundleGroupPreName));
579
+ if (tag) {
580
+ const bundleGroup = (tag + '').split(BundleGroupPreName)[1];
581
+ if (!bundleGroups.includes(bundleGroup)) {
582
+ bundleGroups.push(bundleGroup);
508
583
  }
509
- const price = template.showPrices ? MoneyController.format(_lastTotal, detail.company.currencySymbol) : '';
510
- let bundleText = bundle.text;
511
- bundleText = ((_b = bundleText === null || bundleText === void 0 ? void 0 : bundleText.replace(sharp, '')) === null || _b === void 0 ? void 0 : _b.trim()) + "";
512
- content += `<tr>
584
+ }
585
+ });
586
+ const bundles = detail.order.items.filter(i => i.type === EnumFeeType.BundleProduct);
587
+ for (let ind = 0; ind < bundleGroups.length; ind++) {
588
+ const group = bundleGroups[ind] + '';
589
+ const groupTag = BundleGroupPreName + group;
590
+ const list = bundledProducts.filter(pro => Array.isArray(pro.tags) && pro.tags.includes(groupTag));
591
+ if (list.length > 0) {
592
+ const firstItem = list[0];
593
+ const firstItemRatio = +(((_a = firstItem.tags) === null || _a === void 0 ? void 0 : _a.find(i => i.startsWith(BundleProductQuantityPreName))) + '').split(BundleProductQuantityPreName)[1];
594
+ const bundleQuantity = firstItem.quantity / firstItemRatio;
595
+ 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; });
596
+ if (bundle) {
597
+ const sharp = ` ${bundleQuantity}×`;
598
+ const sumBundleDiscount = bundle.amount; // bundleQuantity * bundle.discountAmount;
599
+ const _total = MoneyController.sumField(list, 'totalAmount');
600
+ // let _lastTotal = _total - sumBundleDiscount;
601
+ let _lastTotal = _total - sumBundleDiscount;
602
+ if (_lastTotal < 0) {
603
+ _lastTotal = 0;
604
+ }
605
+ const price = template.showPrices ? MoneyController.format(_lastTotal, detail.company.currencySymbol) : '';
606
+ let bundleText = bundle.text;
607
+ bundleText = ((_b = bundleText === null || bundleText === void 0 ? void 0 : bundleText.replace(sharp, '')) === null || _b === void 0 ? void 0 : _b.trim()) + "";
608
+ content += `<tr>
513
609
  <td style="font-size:${largeFontSize}px; min-width:40px; width: 40px; text-align: left;">${sharp}</td>
514
610
  <td style="font-size:${largeFontSize}px; flex: 1; width: 100%; text-align: left; font-weight: bold;">${bundleText}</td>
515
611
  <td style="font-size:${largeFontSize}px; max-width: 90px; text-align: right;">${price}</td>
516
612
  </tr>`;
517
- for (let index = 0; index < list.length; index++) {
518
- const row = list[index];
519
- const sharp = `${row.quantity}× `;
520
- let product = (template.showProductKitchenName && row.kitchenReceiptName !== '' && row.kitchenReceiptName !== null) ? row.kitchenReceiptName : row.title;
521
- product = sharp + ((_c = product === null || product === void 0 ? void 0 : product.replace(sharp, '')) === null || _c === void 0 ? void 0 : _c.trim()) + "";
522
- content += `<tr>
613
+ for (let index = 0; index < list.length; index++) {
614
+ const row = list[index];
615
+ const sharp = `${row.quantity}× `;
616
+ let product = (template.showProductKitchenName && row.kitchenReceiptName !== '' && row.kitchenReceiptName !== null) ? row.kitchenReceiptName : row.title;
617
+ product = sharp + ((_c = product === null || product === void 0 ? void 0 : product.replace(sharp, '')) === null || _c === void 0 ? void 0 : _c.trim()) + "";
618
+ content += `<tr>
523
619
  <td style="font-size:${largeFontSize}px; min-width:40px; width: 40px; text-align: left;">&ensp;</td>
524
620
  <td style="font-size:${largeFontSize}px; flex: 1; width: 100%; text-align: left; column-span: 2;">${product}</td>
525
621
  </tr>`;
526
- if (row.extrasNames) {
527
- const extList = row.extras
528
- .filter(item => !item.doNotPrintOnReceipt)
529
- .map(item => PrintToolController.extraItemToText(item, template.skipWholePizzaToppingText, template.showPrices))
530
- .filter(i => i.length > 0);
531
- for (let ind = 0; ind < extList.length; ind++) {
532
- content += `<tr>
622
+ if (row.extrasNames) {
623
+ const extList = row.extras
624
+ .filter(item => !item.doNotPrintOnReceipt)
625
+ .map(item => PrintToolController.extraItemToText(item, template.skipWholePizzaToppingText, template.showPrices))
626
+ .filter(i => i.length > 0);
627
+ for (let ind = 0; ind < extList.length; ind++) {
628
+ content += `<tr>
533
629
  <td style=" min-width:40px; width: 40px;">&ensp;</td>
534
630
  <td style="font-size:${largeFontSize}px; flex: 1; width: 100%; text-align: left;column-span: 2; padding-left: 24px;">${extList[ind]}</td>
535
631
  </tr>`;
632
+ }
536
633
  }
537
- }
538
- const note = PrintToolController.productNote(row);
539
- if (note !== '') {
540
- content += `<tr>
634
+ const note = PrintToolController.productNote(row);
635
+ if (note !== '') {
636
+ content += `<tr>
541
637
  <td style=" min-width:40px; width: 40px;">&ensp;</td>
542
638
  <td style="font-size:${largeFontSize}px; flex: 1; width: 100%; text-align: left;column-span: 2; padding-left: 24px;">${note}</td>
543
639
  </tr>`;
640
+ }
544
641
  }
545
642
  }
546
643
  }
547
644
  }
548
645
  }
549
- }
550
- const unBundledProducts = detail.products.filter(i => !(Array.isArray(i.tags) && i.tags.findIndex(tag => tag.startsWith(BundleIdPreName)) !== -1));
551
- const list = this.filterByCategoryList(this.sortProduct(unBundledProducts, template.sortProducts), template.printOnlyCertainCategoriesList, template.printOnlyCertainCategories, template.printOnlyCertainProductsList, template.printOnlyCertainProducts);
552
- if (list.length > 0) {
553
- flag = false;
554
- }
555
- if (flag)
556
- return "";
557
- list.forEach((row) => {
558
- const productName = (template.showCategoryTitle ? `[${row.categoryTitle}] ` : "") + ((template.showProductKitchenName && typeof row.kitchenReceiptName === "string" && row.kitchenReceiptName.trim().length > 0) ? row.kitchenReceiptName : row.title).trim();
559
- const amount = template.showPrices ? MoneyController.format(row.totalAmount, detail.company.currencySymbol) : "";
560
- content += `<tr>
646
+ let unBundledProducts = detail.products.filter(i => TagController.findTagBundleId(i.tags) === undefined);
647
+ const list = this.filterByCategoryList(this.sortProduct(unBundledProducts, template.sortProducts), template.printOnlyCertainCategoriesList, template.printOnlyCertainCategories, template.printOnlyCertainProductsList, template.printOnlyCertainProducts);
648
+ if (list.length > 0) {
649
+ flag = false;
650
+ }
651
+ if (flag)
652
+ return "";
653
+ list.forEach((row) => {
654
+ const productName = (template.showCategoryTitle ? `[${row.categoryTitle}] ` : "") + ((template.showProductKitchenName && typeof row.kitchenReceiptName === "string" && row.kitchenReceiptName.trim().length > 0) ? row.kitchenReceiptName : row.title).trim();
655
+ const amount = template.showPrices ? MoneyController.format(row.totalAmount, detail.company.currencySymbol) : "";
656
+ content += `<tr>
561
657
  <td style="font-size:${largeFontSize}px; min-width:40px; width: 40px; text-align: left;">${row.quantity}×</td>
562
658
  <td style="font-size:${largeFontSize}px; flex: 1; width: 100%; text-align: left; font-weight: bold;">${productName}</td>
563
659
  <td style="font-size:${largeFontSize}px; max-width: 90px; text-align: right;">${amount}</td>
564
660
  </tr>`;
565
- row.extras.filter(i => !i.doNotPrintOnReceipt).forEach(element => {
566
- const extraText = this.pizzaSideText(element.pizzaSide, template.skipWholePizzaToppingText) + element.quantity + "× " + element.extraItemTitle;
567
- const extraAmount = template.showPrices ? MoneyController.format(element.totalAmount, detail.company.currencySymbol) : "";
568
- content += `<tr>
661
+ row.extras.filter(i => !i.doNotPrintOnReceipt).forEach(element => {
662
+ const extraText = this.pizzaSideText(element.pizzaSide, template.skipWholePizzaToppingText) + element.quantity + "× " + element.extraItemTitle;
663
+ const extraAmount = template.showPrices ? MoneyController.format(element.totalAmount, detail.company.currencySymbol) : "";
664
+ content += `<tr>
569
665
  <td style="font-size:${largeFontSize}px; min-width:40px; width: 40px; text-align: left;">&ensp;</td>
570
666
  <td style="font-size:${largeFontSize}px; flex: 1; width: 100%; text-align: left;">${extraText}</td>
571
667
  <td style="font-size:${largeFontSize}px; max-width: 90px; text-align: right;">${extraAmount}</td>
572
668
  </tr>`;
573
- });
574
- if (row.note !== null && row.note.trim().length > 0) {
575
- content += `<tr>
669
+ });
670
+ if (row.note !== null && row.note.trim().length > 0) {
671
+ content += `<tr>
576
672
  <td style="font-size:${largeFontSize}px; min-width:40px; width: 40px; text-align: left;">Note:</td>
577
673
  <td style="font-size:${largeFontSize}px; flex: 1; width: 100%; text-align: left;font-weight: bold;">${row.note}</td>
578
674
  <td style="font-size:${largeFontSize}px; max-width: 90px; text-align: right;"></td>
579
675
  </tr>`;
580
- }
581
- });
582
- if (template.showPrices) {
583
- //order amount
584
- content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
676
+ }
677
+ });
678
+ if (template.showPrices) {
679
+ //order amount
680
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
585
681
  <td style="font-size:${template.fontSize}px; width: 40px; text-align: left;"></td>
586
682
  <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right;padding-right: 8px;">
587
683
  Order Amount:
@@ -590,9 +686,9 @@ class SimplePreviewController {
590
686
  ${MoneyController.format(detail.order.orderAmount, detail.company.currencySymbol)}
591
687
  </td>
592
688
  </tr>`;
593
- if (detail.order.orderType === EnumOrderType.delivery && detail.order.deliveryCost > 0) {
594
- //delivery amount
595
- content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
689
+ if (detail.order.orderType === EnumOrderType.delivery && detail.order.deliveryCost > 0) {
690
+ //delivery amount
691
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
596
692
  <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
597
693
  <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right;padding-right: 8px;">
598
694
  Delivery costs:
@@ -601,10 +697,10 @@ class SimplePreviewController {
601
697
  ${MoneyController.format(detail.order.deliveryCost, detail.company.currencySymbol)}
602
698
  </td>
603
699
  </tr>`;
604
- }
605
- if (detail.order.discountAmount > 0) {
606
- //discount amount
607
- content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
700
+ }
701
+ if (detail.order.discountAmount > 0) {
702
+ //discount amount
703
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
608
704
  <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
609
705
  <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right;padding-right: 8px;">
610
706
  Discount:
@@ -613,9 +709,9 @@ class SimplePreviewController {
613
709
  ${MoneyController.format(detail.order.discountAmount, detail.company.currencySymbol)}
614
710
  </td>
615
711
  </tr>`;
616
- }
617
- //subtotal amount
618
- content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
712
+ }
713
+ //subtotal amount
714
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
619
715
  <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
620
716
  <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right;padding-right: 8px;">
621
717
  Subtotal:
@@ -624,9 +720,9 @@ class SimplePreviewController {
624
720
  ${MoneyController.format(detail.order.subtotalAmount, detail.company.currencySymbol)}
625
721
  </td>
626
722
  </tr>`;
627
- if (detail.order.hstAmount > 0) {
628
- //hst and service fee and company fee amount
629
- content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
723
+ if (detail.order.hstAmount > 0) {
724
+ //hst and service fee and company fee amount
725
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
630
726
  <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
631
727
  <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right; padding-right: 8px;">
632
728
  HST(${MoneyController.format(detail.order.hstPercentage, "%")}):
@@ -635,10 +731,10 @@ class SimplePreviewController {
635
731
  ${MoneyController.format(detail.order.hstAmount, detail.company.currencySymbol)}
636
732
  </td>
637
733
  </tr>`;
638
- }
639
- if (detail.order.tipAmount > 0) {
640
- //tip amount
641
- content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
734
+ }
735
+ if (detail.order.tipAmount > 0) {
736
+ //tip amount
737
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
642
738
  <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
643
739
  <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right; padding-right: 8px;">
644
740
  Tip:
@@ -647,10 +743,10 @@ class SimplePreviewController {
647
743
  ${MoneyController.format(detail.order.tipAmount, detail.company.currencySymbol)}
648
744
  </td>
649
745
  </tr>`;
650
- }
651
- if (detail.order.thirdPartyDriverTipAmount > 0) {
652
- //tip amount
653
- content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
746
+ }
747
+ if (detail.order.thirdPartyDriverTipAmount > 0) {
748
+ //tip amount
749
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
654
750
  <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
655
751
  <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right; padding-right: 8px;">
656
752
  Driver tip:
@@ -659,12 +755,12 @@ class SimplePreviewController {
659
755
  ${MoneyController.format(detail.order.thirdPartyDriverTipAmount, detail.company.currencySymbol)}
660
756
  </td>
661
757
  </tr>`;
758
+ }
662
759
  }
663
- }
664
- content += `</tbody></table>`;
665
- if (template.showPrices) {
666
- //total amount
667
- content += `<div style="display: flex; flex-direction: row; align-items: center; border-top: 1px dashed #000000; margin: 4px 0;">
760
+ content += `</tbody></table>`;
761
+ if (template.showPrices) {
762
+ //total amount
763
+ content += `<div style="display: flex; flex-direction: row; align-items: center; border-top: 1px dashed #000000; margin: 4px 0;">
668
764
  <div style="font-size:${template.fontSize + 6}px; flex: 1; text-align: right; padding-right: 8px;">
669
765
  ${detail.order.paymentState !== EnumPaymentState.Paid ? "Total & Still to pay" : "Total"}:
670
766
  </div>
@@ -672,10 +768,11 @@ class SimplePreviewController {
672
768
  ${MoneyController.format(detail.order.totalAmount, detail.company.currencySymbol)}
673
769
  </div>
674
770
  </div>`;
771
+ }
772
+ content += this.printSolidLine();
773
+ content += `</div>`;
774
+ return content;
675
775
  }
676
- content += this.printSolidLine();
677
- content += `</div>`;
678
- return content;
679
776
  }
680
777
  printCustomerRemark(template, detail) {
681
778
  if (detail.order.remarks === null || detail.order.remarks.trim().length === 0)
@@ -0,0 +1,42 @@
1
+ import EnumPointOfSaleOrderItemSharingType from "../enums/EnumPointOfSaleOrderItemSharingType";
2
+ import IPointOfSaleOrderItem from "../interfaces/pos/IPointOfSaleOrderItem";
3
+ import PointOfSaleOrderItemSeat from "../interfaces/pos/point-of-sale-order-item-seat";
4
+ import IOrderDetailProduct from "../interfaces/print/IOrderDetailProduct";
5
+ declare class TagToolController {
6
+ static SeatTagPreName: string;
7
+ static SharingTypeTagPreName: string;
8
+ static BundleGroupPreName: string;
9
+ static BundleIdPreName: string;
10
+ static BundleProductQuantityPreName: string;
11
+ static BundleFeeKey: string;
12
+ private static instance;
13
+ private constructor();
14
+ static getInstance(): TagToolController;
15
+ get BundleFeeKey(): string;
16
+ orderItemSeatsToTags(seats: PointOfSaleOrderItemSeat[]): string[];
17
+ tagsToOrderItemSeats(tags: string[] | null): PointOfSaleOrderItemSeat[];
18
+ sharingTypeToTag(value: EnumPointOfSaleOrderItemSharingType): string;
19
+ findTagSharingType(tags: string[] | undefined | null): string | undefined;
20
+ findTagBundleGroup(tags: string[] | undefined | null): string | undefined;
21
+ findTagBundleId(tags: string[] | undefined | null): string | undefined;
22
+ findTagBundleQuantity(tags: string[] | undefined | null): string | undefined;
23
+ bundleGroup(tag: string | undefined | null): string | undefined;
24
+ bundleId(tag: string | undefined | null): number | undefined;
25
+ bundleQuantity(tag: string | undefined | null): number | undefined;
26
+ createBundleGroupTag(group: string): string;
27
+ createBundleIdTag(bundleId: string | number): string;
28
+ createBundleRatioTag(ratio: string | number): string;
29
+ tagToSharingType(value: string | undefined): EnumPointOfSaleOrderItemSharingType;
30
+ seatToTag(seat: PointOfSaleOrderItemSeat): string;
31
+ seatToTagForDisplay(seat: PointOfSaleOrderItemSeat, shareType: EnumPointOfSaleOrderItemSharingType): string;
32
+ tagToSeat(tag: string): PointOfSaleOrderItemSeat;
33
+ allSeatInOrder(products: IPointOfSaleOrderItem[]): number[];
34
+ allSeatInOrderDetail(products: IOrderDetailProduct[]): number[];
35
+ allSeats(tags: string[] | undefined | null): string[];
36
+ seatNumber(tag: string, init?: number): number;
37
+ allTagsWithoutSeats(tags: string[] | null | undefined): string[];
38
+ allTagsWithoutSeatsAndSharingType(tags: string[] | null | undefined): string[];
39
+ allTagsWithoutBundles(tags: string[] | null | undefined): string[];
40
+ createSeatLabel(num: number): string;
41
+ }
42
+ export default TagToolController;
@@ -0,0 +1,173 @@
1
+ import EnumPointOfSaleOrderItemSharingType from "../enums/EnumPointOfSaleOrderItemSharingType";
2
+ class TagToolController {
3
+ constructor() {
4
+ }
5
+ static getInstance() {
6
+ if (!TagToolController.instance) {
7
+ TagToolController.instance = new TagToolController();
8
+ }
9
+ return TagToolController.instance;
10
+ }
11
+ get BundleFeeKey() {
12
+ return TagToolController.BundleFeeKey;
13
+ }
14
+ orderItemSeatsToTags(seats) {
15
+ try {
16
+ return (seats === null || seats === void 0 ? void 0 : seats.map(i => this.seatToTag(i))) || [];
17
+ }
18
+ catch (e) {
19
+ console.log("orderItemSeatsToTags : ", e);
20
+ return [];
21
+ }
22
+ }
23
+ tagsToOrderItemSeats(tags) {
24
+ try {
25
+ if (!tags)
26
+ return [];
27
+ const validTags = tags.filter(i => i.startsWith(TagToolController.SeatTagPreName));
28
+ return validTags.map(i => this.tagToSeat(i));
29
+ }
30
+ catch (e) {
31
+ console.log("tagsToOrderItemSeats : ", e);
32
+ return [];
33
+ }
34
+ }
35
+ sharingTypeToTag(value) {
36
+ return `${TagToolController.SharingTypeTagPreName}${value}`;
37
+ }
38
+ findTagSharingType(tags) {
39
+ return (tags || []).find(i => i.startsWith(TagToolController.SharingTypeTagPreName));
40
+ }
41
+ findTagBundleGroup(tags) {
42
+ return (tags || []).find(i => i.startsWith(TagToolController.BundleGroupPreName));
43
+ }
44
+ findTagBundleId(tags) {
45
+ return (tags || []).find(i => i.startsWith(TagToolController.BundleIdPreName));
46
+ }
47
+ findTagBundleQuantity(tags) {
48
+ return (tags || []).find(i => i.startsWith(TagToolController.BundleProductQuantityPreName));
49
+ }
50
+ bundleGroup(tag) {
51
+ if (!tag)
52
+ return undefined;
53
+ try {
54
+ return tag.split(TagToolController.BundleGroupPreName)[1];
55
+ }
56
+ catch (e) {
57
+ return undefined;
58
+ }
59
+ }
60
+ bundleId(tag) {
61
+ if (!tag)
62
+ return undefined;
63
+ try {
64
+ return +(tag.split(TagToolController.BundleIdPreName)[1]);
65
+ }
66
+ catch (e) {
67
+ return undefined;
68
+ }
69
+ }
70
+ bundleQuantity(tag) {
71
+ if (!tag)
72
+ return undefined;
73
+ try {
74
+ return +(tag.split(TagToolController.BundleProductQuantityPreName)[1]);
75
+ }
76
+ catch (e) {
77
+ return undefined;
78
+ }
79
+ }
80
+ createBundleGroupTag(group) {
81
+ return TagToolController.BundleGroupPreName + group;
82
+ }
83
+ createBundleIdTag(bundleId) {
84
+ return TagToolController.BundleIdPreName + bundleId;
85
+ }
86
+ createBundleRatioTag(ratio) {
87
+ return TagToolController.BundleProductQuantityPreName + ratio;
88
+ }
89
+ tagToSharingType(value) {
90
+ if (!value)
91
+ return EnumPointOfSaleOrderItemSharingType.None;
92
+ if (value.startsWith(TagToolController.SharingTypeTagPreName)) {
93
+ const [_preTagName, sharingTypeStr] = value.split(TagToolController.SharingTypeTagPreName);
94
+ if (!isNaN(+sharingTypeStr)) {
95
+ return +sharingTypeStr;
96
+ }
97
+ }
98
+ return EnumPointOfSaleOrderItemSharingType.None;
99
+ }
100
+ seatToTag(seat) {
101
+ return `${TagToolController.SeatTagPreName}${seat.seatId} - ${seat.ratio} - ${seat.isPaid ? "1" : "0"}`;
102
+ }
103
+ seatToTagForDisplay(seat, shareType) {
104
+ switch (shareType) {
105
+ case EnumPointOfSaleOrderItemSharingType.EqualSplit:
106
+ return `Seat #${seat.seatId} ${seat.isPaid ? "PAID" : ""}`.trim();
107
+ case EnumPointOfSaleOrderItemSharingType.Single:
108
+ return `Seat #${seat.seatId} ${seat.ratio}x ${seat.isPaid ? "PAID" : ""}`.trim();
109
+ case EnumPointOfSaleOrderItemSharingType.Shared:
110
+ return `Seat #${seat.seatId} ${seat.ratio}share ${seat.isPaid ? "PAID" : ""}`;
111
+ case EnumPointOfSaleOrderItemSharingType.None:
112
+ return "";
113
+ default:
114
+ return "Unknown share type";
115
+ }
116
+ }
117
+ tagToSeat(tag) {
118
+ const cleanTag = tag.replace(TagToolController.SeatTagPreName, "");
119
+ const [seatIdStr, ratioStr, isPaidStr, transactionIdStr] = cleanTag.split("-");
120
+ return {
121
+ seatId: Number(seatIdStr === null || seatIdStr === void 0 ? void 0 : seatIdStr.trim()), ratio: Number(ratioStr === null || ratioStr === void 0 ? void 0 : ratioStr.trim()), isPaid: isPaidStr === "1", transactionId: isNaN(+transactionIdStr) ? undefined : +transactionIdStr
122
+ };
123
+ }
124
+ allSeatInOrder(products) {
125
+ let list = [];
126
+ products.forEach(product => {
127
+ list.push(...product.seats.map(i => i.seatId));
128
+ });
129
+ return Array.from(new Set(list));
130
+ }
131
+ allSeatInOrderDetail(products) {
132
+ let list = [];
133
+ products.forEach(product => {
134
+ list.push(...this.tagsToOrderItemSeats(product.tags || []).map(i => i.seatId));
135
+ });
136
+ return Array.from(new Set(list));
137
+ }
138
+ allSeats(tags) {
139
+ if (!Array.isArray(tags))
140
+ return [];
141
+ return tags.filter(i => i.startsWith(TagToolController.SeatTagPreName));
142
+ }
143
+ seatNumber(tag, init = 1) {
144
+ try {
145
+ return +tag.split(TagToolController.SeatTagPreName)[1];
146
+ }
147
+ catch (e) {
148
+ console.log(e);
149
+ return init;
150
+ }
151
+ }
152
+ allTagsWithoutSeats(tags) {
153
+ if (!Array.isArray(tags))
154
+ return [];
155
+ return tags.filter(i => !i.startsWith(TagToolController.SeatTagPreName));
156
+ }
157
+ allTagsWithoutSeatsAndSharingType(tags) {
158
+ return this.allTagsWithoutSeats(tags).filter(i => !i.startsWith(TagToolController.SharingTypeTagPreName));
159
+ }
160
+ allTagsWithoutBundles(tags) {
161
+ return this.allTagsWithoutSeats(tags).filter(i => !i.startsWith(TagToolController.SharingTypeTagPreName));
162
+ }
163
+ createSeatLabel(num) {
164
+ return `${TagToolController.SeatTagPreName}${num}`;
165
+ }
166
+ }
167
+ TagToolController.SeatTagPreName = 'Seat #';
168
+ TagToolController.SharingTypeTagPreName = 'SharingType #';
169
+ TagToolController.BundleGroupPreName = 'BG #';
170
+ TagToolController.BundleIdPreName = 'BI #';
171
+ TagToolController.BundleProductQuantityPreName = 'BQ #';
172
+ TagToolController.BundleFeeKey = 'BundleProduct';
173
+ export default TagToolController;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meemup-library",
3
- "version": "1.6.6",
3
+ "version": "1.6.8",
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.6.6\" && git push origin "
14
+ "commit": "git add . && git commit -m \"version.1.6.8\" && git push origin "
15
15
  },
16
16
  "files": [
17
17
  "/dist"