meemup-library 1.3.66 → 1.3.68

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,19 @@
1
+ import IPrintTemplate from "../interfaces/IPrintTemplate";
2
+ import IOrderDetailOrder from "../interfaces/print/IOrderDetailOrder";
3
+ import IOrderDetails from "../interfaces/print/IOrderDetails";
4
+ import IOrderDetailProduct from "../interfaces/print/IOrderDetailProduct";
5
+ declare class LabelPreviewController {
6
+ calculatePaperSize: (paper: number, width: string | number) => string;
7
+ createLabelContainer(template: IPrintTemplate): string;
8
+ printSummary(template: IPrintTemplate, order: IOrderDetailOrder): string;
9
+ printCustomerInformation(template: IPrintTemplate, detail: IOrderDetails): string;
10
+ printCategoryTitle(template: IPrintTemplate, row: IOrderDetailProduct): string;
11
+ printProductTitle(template: IPrintTemplate, row: IOrderDetailProduct): string;
12
+ printExtrasNames(template: IPrintTemplate, row: IOrderDetailProduct, currencySymbol: string): string;
13
+ printProductNote(template: IPrintTemplate, row: IOrderDetailProduct): string;
14
+ printDashLine(): string;
15
+ private pizzaSideText;
16
+ private createDivContainer;
17
+ }
18
+ declare const controller: LabelPreviewController;
19
+ export default controller;
@@ -0,0 +1,155 @@
1
+ import moment from "moment";
2
+ import EnumShowCustomer from "../enums/EnumShowCustomer";
3
+ import EnumOrderType from "../enums/EnumOrderType";
4
+ import MoneyController from "../controllers/MoneyController";
5
+ import EnumPizzaSide from "../enums/EnumPizzaSide";
6
+ import EnumOrderDateTimePrintModeType from "../enums/EnumOrderDateTimePrintModeType";
7
+ import PhoneController from "../controllers/PhoneController";
8
+ class LabelPreviewController {
9
+ constructor() {
10
+ this.calculatePaperSize = (paper, width) => {
11
+ switch (paper) {
12
+ case 1:
13
+ return width + "mm";
14
+ case 2:
15
+ return "210mm";
16
+ case 3:
17
+ return "148mm";
18
+ case 4:
19
+ return "105mm";
20
+ default:
21
+ return width + "mm";
22
+ }
23
+ };
24
+ }
25
+ createLabelContainer(template) {
26
+ const { paddingBottom, paddingTop, font, paper, width } = template;
27
+ const fontFamily = (font === "Font A" || font === "Font B") ? "arial" : font;
28
+ let label = `<div style="padding:${paddingTop + "mm"} 0 ${paddingBottom + "mm"} 0; font-family:${fontFamily}; font-weight : normal; width: ${this.calculatePaperSize(paper, width)};">`;
29
+ return label;
30
+ }
31
+ printSummary(template, order) {
32
+ if (!template.orderSummary)
33
+ return "";
34
+ let content = this.createDivContainer(template);
35
+ content += `<div style="display:grid; grid-template-columns: repeat(1 , 1fr);">`;
36
+ let summary = `<strong style="font-size: ${template.fontSize}px; text-align: center;">#${order.orderNumber}&emsp;${order.orderTypeString}</strong>`;
37
+ content += summary;
38
+ // if (template.orderDesiredDateTimeVisibility) {
39
+ //
40
+ // content += `<p style="display:block; font-size: ${template.fontSize}px; text-align: center;">${moment(order.desiredDate).format("LLLL")}</p>`;
41
+ //
42
+ // }
43
+ if (template.orderDesiredDateTimeVisibility) {
44
+ let formated = "";
45
+ switch (template.orderDateTimeMode) {
46
+ case EnumOrderDateTimePrintModeType.RegistrationDate:
47
+ formated = moment(order.registrationDate).format(template.orderDateTimeFormat); // order.registrationDate;
48
+ break;
49
+ case EnumOrderDateTimePrintModeType.ReadyTime:
50
+ formated = moment(order.orderReadyTime).format(template.orderDateTimeFormat);
51
+ break;
52
+ case EnumOrderDateTimePrintModeType.WishTime:
53
+ formated = moment(order.desiredDate).format(template.orderDateTimeFormat); // order.desiredDate;
54
+ break;
55
+ case EnumOrderDateTimePrintModeType.PreparationStartTime:
56
+ formated = moment(order.orderPreparationStartTime).format(template.orderDateTimeFormat);
57
+ break;
58
+ default:
59
+ formated = moment(order.desiredDate).format(template.orderDateTimeFormat); // order.desiredDate;
60
+ break;
61
+ }
62
+ content += `<strong style="display:block; font-size: ${template.fontSize}px; text-align: center;">${formated}</strong>`;
63
+ }
64
+ content += `</div>`;
65
+ content += `</div>`;
66
+ return content;
67
+ }
68
+ printCustomerInformation(template, detail) {
69
+ if (template.showCustomerInfo === EnumShowCustomer.NO)
70
+ return "";
71
+ if (template.showCustomerInfo === EnumShowCustomer.YES_WHEN_DELIVERY_ORDER && detail.order.orderType !== EnumOrderType.delivery)
72
+ return "";
73
+ let content = this.createDivContainer(template);
74
+ content += this.printDashLine();
75
+ if (template.printCustomerDetailsInLarge) {
76
+ let largeFontSize = template.printer === 5 ? 22 : parseInt((template.fontSize + 10) + "");
77
+ content += `<p style="display : block; font-size: ${largeFontSize}px; text-align: left;">Customer information</p>`;
78
+ content += `<strong style="display:block; font-size: ${largeFontSize}px;">${detail.customer.fullName}</strong>`;
79
+ content += `<strong style="display:block; font-size: ${largeFontSize}px;">${PhoneController.toDisplay(detail.customer.phoneNumber)}</strong>`;
80
+ // content += `<p style="display:block; font-size: ${template.fontSize}px;">${detail.customer.email}</p>`;
81
+ content += `<strong style="display:block; font-size: ${largeFontSize}px;">${detail.customer.address}</strong>`;
82
+ }
83
+ else {
84
+ content += `<p style="display : block; font-size: ${template.fontSize}px; text-align: left;">Customer information</p>`;
85
+ content += `<strong style="display:block; font-size: ${template.fontSize}px;">${detail.customer.fullName}</strong>`;
86
+ content += `<strong style="display:block; font-size: ${template.fontSize}px;">${PhoneController.toDisplay(detail.customer.phoneNumber)}</strong>`;
87
+ // content += `<p style="display:block; font-size: ${template.fontSize}px;">${detail.customer.email}</p>`;
88
+ content += `<strong style="display:block; font-size: ${template.fontSize}px;">${detail.customer.address}</strong>`;
89
+ }
90
+ content += `</div>`;
91
+ return content;
92
+ }
93
+ printCategoryTitle(template, row) {
94
+ var _a;
95
+ if (!template.showCategoryTitle || ((_a = row.categoryTitle) === null || _a === void 0 ? void 0 : _a.trim()) === "")
96
+ return "";
97
+ let content = this.createDivContainer(template);
98
+ content += `<p style="display:block; font-size: ${template.fontSize}px;">[${row.categoryTitle}]</p>`;
99
+ content += `</div>`;
100
+ return content;
101
+ }
102
+ printProductTitle(template, row) {
103
+ let content = this.createDivContainer(template);
104
+ let largeFontSize = template.printer === 5 ? "22px" : parseInt((template.fontSize + 10) + "") + "px";
105
+ if (template.showProductKitchenName)
106
+ content += `<strong style="display:block; font-size: ${largeFontSize};">${row.kitchenReceiptName}</strong>`;
107
+ else
108
+ content += `<strong style="display:block; font-size: ${largeFontSize};">${row.title}</strong>`;
109
+ content += `</div>`;
110
+ return content;
111
+ }
112
+ printExtrasNames(template, row, currencySymbol) {
113
+ if (row.extras.length === 0)
114
+ return "";
115
+ let content = this.createDivContainer(template);
116
+ row.extras.forEach(element => {
117
+ let extraText = this.pizzaSideText(element.pizzaSide) + element.quantity + "X " + element.extraItemTitle;
118
+ let extraAmount = template.showPrices ? MoneyController.format(element.totalAmount, currencySymbol) : "";
119
+ content += `<div style="display: flex; flex-direction: row; justify-content: flex-start; padding-left: 16px">
120
+ <p style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: left;">${extraText}</p>
121
+ <p style="font-size:${template.fontSize}px; max-width: 90px; text-align: right;">${extraAmount}</p>
122
+ </div>`;
123
+ });
124
+ content += `</div>`;
125
+ return content;
126
+ }
127
+ printProductNote(template, row) {
128
+ if (row.note === null || row.note.trim() === "")
129
+ return "";
130
+ let content = this.createDivContainer(template);
131
+ content += ` <strong style="font-size:${template.fontSize}px; max-width: 90px; text-align: right;">${row.note}</strong>`;
132
+ content += `</div>`;
133
+ return content;
134
+ }
135
+ printDashLine() {
136
+ return `<div style="display: block; border-top: 1px dashed #000000; margin: 4px 0;"></div>`;
137
+ }
138
+ pizzaSideText(value) {
139
+ switch (value) {
140
+ case EnumPizzaSide.left:
141
+ return "[LEFT] ";
142
+ case EnumPizzaSide.right:
143
+ return "[RIGHT] ";
144
+ case EnumPizzaSide.all:
145
+ return "[WHOLE] ";
146
+ default:
147
+ return "";
148
+ }
149
+ }
150
+ createDivContainer(template) {
151
+ return `<div style="display: block; padding-left: ${template.paddingLeft}mm; padding-right: ${template.paddingRight}mm;" >`;
152
+ }
153
+ }
154
+ const controller = new LabelPreviewController();
155
+ export default controller;
@@ -0,0 +1,19 @@
1
+ import IAccount from "../interfaces/IAccount";
2
+ import IPrintTemplate from "../interfaces/IPrintTemplate";
3
+ import IOrderDetails from "../interfaces/print/IOrderDetails";
4
+ import IOrderDetailProduct from "../interfaces/print/IOrderDetailProduct";
5
+ declare const _default: {
6
+ calculatePaperSize: (paper: number, width: string | number) => string;
7
+ sortProduct: (products: IOrderDetailProduct[], sortType: number) => IOrderDetailProduct[];
8
+ filterByCategoryList: (products: IOrderDetailProduct[], catList: number[], onlyListCategory: boolean, productList: number[], onlyListProduct: boolean) => IOrderDetailProduct[];
9
+ convertTimeStringToDateByT(data?: Date | string | null): Date | string | null;
10
+ formatAMPMDate(date: Date | string | null): string;
11
+ formatDateTime(dateTime: string, mode?: string): string;
12
+ simpleLayout(account: IAccount, detail: IOrderDetails, template: IPrintTemplate): string;
13
+ largeLayout(account: IAccount, detail: IOrderDetails, template: IPrintTemplate): string;
14
+ labelLayout(detail: IOrderDetails, template: IPrintTemplate): string;
15
+ paymentFailed(detail: IOrderDetails, currency: string): string;
16
+ packageLabel(detail: IOrderDetails, template: IPrintTemplate): string;
17
+ preview(account: IAccount, detail: IOrderDetails, template: IPrintTemplate): string;
18
+ };
19
+ export default _default;
@@ -0,0 +1,313 @@
1
+ import EnumPrintLayout from "../enums/EnumPrintLayout";
2
+ import SimplePreviewController from "./SimplePreviewController";
3
+ import LabelPreviewController from "./LabelPreviewController";
4
+ import EnumOrderSummaryPrintPlacementType from "../enums/EnumOrderSummaryPrintPlacementType";
5
+ export default new class PreviewContentController {
6
+ constructor() {
7
+ this.calculatePaperSize = (paper, width) => {
8
+ switch (paper) {
9
+ case 1:
10
+ return width + "mm";
11
+ case 2:
12
+ return "210mm";
13
+ case 3:
14
+ return "148mm";
15
+ case 4:
16
+ return "105mm";
17
+ default:
18
+ return width + "mm";
19
+ }
20
+ };
21
+ this.sortProduct = (products, sortType) => {
22
+ const new_product = [];
23
+ if (sortType === 1) {
24
+ return products;
25
+ }
26
+ else if (sortType === 2) {
27
+ products.sort((a, b) => {
28
+ let nameA = a.title.toUpperCase(); // ignore upper and lowercase
29
+ let nameB = b.title.toUpperCase(); // ignore upper and lowercase
30
+ if (nameA < nameB) {
31
+ return -1;
32
+ }
33
+ if (nameA > nameB) {
34
+ return 1;
35
+ }
36
+ // names must be equal
37
+ return 0;
38
+ }).forEach((row) => new_product.push(row));
39
+ }
40
+ else if (sortType === 3) {
41
+ products.sort(function (a, b) {
42
+ let nameA = a.title.toUpperCase(); // ignore upper and lowercase
43
+ let nameB = b.title.toUpperCase(); // ignore upper and lowercase
44
+ if (nameA > nameB) {
45
+ return -1;
46
+ }
47
+ if (nameA < nameB) {
48
+ return 1;
49
+ }
50
+ // names must be equal
51
+ return 0;
52
+ }).forEach((row) => new_product.push(row));
53
+ }
54
+ else if (sortType === 4) {
55
+ products.sort((a, b) => a.totalAmount > b.totalAmount ? 1 : -1).forEach((row) => new_product.push(row));
56
+ }
57
+ else if (sortType === 5) {
58
+ products.sort((a, b) => a.totalAmount < b.totalAmount ? 1 : -1).forEach((row) => new_product.push(row));
59
+ }
60
+ return new_product;
61
+ };
62
+ this.filterByCategoryList = (products, catList, onlyListCategory, productList, onlyListProduct) => {
63
+ if (!onlyListCategory && !onlyListProduct) {
64
+ return products;
65
+ }
66
+ const new_product = [];
67
+ if (onlyListCategory && !onlyListProduct) {
68
+ products.filter(x => catList.find(element => element === x.categoryId)).forEach((row) => new_product.push(row));
69
+ }
70
+ else if (!onlyListCategory && onlyListProduct) {
71
+ products.filter(x => productList.find(element => element === x.productId)).forEach((row) => new_product.push(row));
72
+ }
73
+ else {
74
+ const arr = [];
75
+ products.filter(x => catList.find(element => element === x.categoryId)).forEach((row) => arr.push(row));
76
+ arr.filter(x => productList.find(element => element === x.productId)).forEach((row) => {
77
+ new_product.push(row);
78
+ });
79
+ }
80
+ return new_product;
81
+ };
82
+ }
83
+ convertTimeStringToDateByT(data = null) {
84
+ if (data instanceof Date) {
85
+ return data;
86
+ }
87
+ else if (typeof data === "string" && data.length > 0) {
88
+ try {
89
+ const time_ = data.split("T");
90
+ const parts = time_[1].split(":");
91
+ let dd = new Date();
92
+ dd.setHours(isNaN(Number(parts[0])) ? 0 : Number(parts[0]));
93
+ dd.setMinutes(isNaN(Number(parts[1])) ? 0 : Number(parts[1]));
94
+ dd.setSeconds(isNaN(Number(parts[2])) ? 0 : Number(parts[2]));
95
+ return dd;
96
+ }
97
+ catch (e) {
98
+ return null;
99
+ }
100
+ }
101
+ else {
102
+ return null;
103
+ }
104
+ }
105
+ formatAMPMDate(date) {
106
+ let datetime = this.convertTimeStringToDateByT(date);
107
+ if (datetime instanceof Date) {
108
+ let hours = datetime.getHours();
109
+ let minutes = datetime.getMinutes();
110
+ let ampm = hours >= 12 ? "PM" : "AM";
111
+ hours = hours % 12;
112
+ hours = hours ? hours : 12;
113
+ minutes = minutes < 10 ? "0" + minutes : minutes;
114
+ return (hours < 10 ? "0" + hours : hours) + ":" + minutes + " " + ampm;
115
+ }
116
+ else {
117
+ return "";
118
+ }
119
+ }
120
+ formatDateTime(dateTime, mode = "full") {
121
+ try {
122
+ let dt = Date.parse(dateTime);
123
+ let time_ = this.formatAMPMDate(dateTime);
124
+ if (mode !== "full") {
125
+ return time_;
126
+ }
127
+ return (new Intl.DateTimeFormat("en-GB", {
128
+ weekday: "short",
129
+ year: "2-digit",
130
+ month: "short",
131
+ day: "2-digit"
132
+ // hour: "2-digit",
133
+ // minute: "2-digit"
134
+ }).format(dt ? dt : Date.now()) +
135
+ " " +
136
+ time_);
137
+ }
138
+ catch (e) {
139
+ return dateTime;
140
+ }
141
+ }
142
+ simpleLayout(account, detail, template) {
143
+ const { order, } = detail;
144
+ const { font, width, paper, paddingTop, paddingBottom, orderSummaryPrintPlacement } = template;
145
+ const fontFamily = (font === "Font A" || font === "Font B") ? "arial" : font;
146
+ let content = `<div style="font-family : ${fontFamily}; font-weight : normal; padding : ${paddingTop}px 0 ${paddingBottom}px 0; width: ${this.calculatePaperSize(paper, width)};"> `;
147
+ if (orderSummaryPrintPlacement === EnumOrderSummaryPrintPlacementType.BeforePageHeader) {
148
+ content += SimplePreviewController.printSummary(template, order);
149
+ }
150
+ content += SimplePreviewController.printTitle(template);
151
+ if (orderSummaryPrintPlacement === EnumOrderSummaryPrintPlacementType.AfterPageHeader) {
152
+ content += SimplePreviewController.printSummary(template, order);
153
+ }
154
+ content += SimplePreviewController.printLogo(template, detail, account);
155
+ content += SimplePreviewController.printCompanyNameAndAddress(template, detail);
156
+ if (orderSummaryPrintPlacement === EnumOrderSummaryPrintPlacementType.AfterCompanyInformation) {
157
+ content += SimplePreviewController.printSummary(template, order);
158
+ }
159
+ content += SimplePreviewController.printTextAfterCompanyAddress(template);
160
+ // content += SimplePreviewController.printDash();
161
+ content += SimplePreviewController.printShowPayment(template, detail);
162
+ content += SimplePreviewController.printOrderInformation(template, detail);
163
+ content += SimplePreviewController.printCustomerInformation(template, detail);
164
+ content += SimplePreviewController.printProductCount(template, detail);
165
+ content += SimplePreviewController.printTextBeforeProducts(template);
166
+ content += SimplePreviewController.printProducts(template, detail);
167
+ content += SimplePreviewController.printCustomerRemark(template, detail);
168
+ content += SimplePreviewController.printDeliveryInstructionsRemarks(template, detail);
169
+ content += SimplePreviewController.printCustomerSignature(template, detail);
170
+ content += SimplePreviewController.printPromotionNote(template);
171
+ content += SimplePreviewController.printMetaData(template, detail);
172
+ content += SimplePreviewController.printSplitPayments(template, detail);
173
+ content += SimplePreviewController.printQrCode(template, detail);
174
+ content += SimplePreviewController.printTextEnd(template);
175
+ content += SimplePreviewController.printFooter(template, detail);
176
+ content += `</div>`;
177
+ return (`<div style="display: flex;"><div style="width : auto;">${content}</div></div>`);
178
+ }
179
+ largeLayout(account, detail, template) {
180
+ const { order, } = detail;
181
+ const { font, width, paper, paddingTop, paddingBottom, orderSummaryPrintPlacement } = template;
182
+ const fontFamily = (font === "Font A" || font === "Font B") ? "arial" : font;
183
+ let content = `<div style="font-family : ${fontFamily}; font-weight : normal; padding : ${paddingTop}px 0 ${paddingBottom}px 0; width: ${this.calculatePaperSize(paper, width)};"> `;
184
+ if (orderSummaryPrintPlacement === EnumOrderSummaryPrintPlacementType.BeforePageHeader) {
185
+ content += SimplePreviewController.printSummary(template, order);
186
+ }
187
+ content += SimplePreviewController.printTitle(template);
188
+ if (orderSummaryPrintPlacement === EnumOrderSummaryPrintPlacementType.AfterPageHeader) {
189
+ content += SimplePreviewController.printSummary(template, order);
190
+ }
191
+ content += SimplePreviewController.printLogo(template, detail, account);
192
+ content += SimplePreviewController.printCompanyNameAndAddress(template, detail);
193
+ if (orderSummaryPrintPlacement === EnumOrderSummaryPrintPlacementType.AfterCompanyInformation) {
194
+ content += SimplePreviewController.printSummary(template, order);
195
+ }
196
+ content += SimplePreviewController.printTextAfterCompanyAddress(template);
197
+ content += SimplePreviewController.printShowPayment(template, detail);
198
+ content += SimplePreviewController.printOrderInformation(template, detail);
199
+ content += SimplePreviewController.printCustomerInformation(template, detail);
200
+ content += SimplePreviewController.printProductCount(template, detail);
201
+ content += SimplePreviewController.printTextBeforeProducts(template);
202
+ content += SimplePreviewController.printLargeProducts(template, detail);
203
+ content += SimplePreviewController.printCustomerRemark(template, detail);
204
+ content += SimplePreviewController.printDeliveryInstructionsRemarks(template, detail);
205
+ content += SimplePreviewController.printCustomerSignature(template, detail);
206
+ content += SimplePreviewController.printPromotionNote(template);
207
+ content += SimplePreviewController.printMetaData(template, detail);
208
+ content += SimplePreviewController.printSplitPayments(template, detail);
209
+ content += SimplePreviewController.printQrCode(template, detail);
210
+ content += SimplePreviewController.printTextEnd(template);
211
+ content += SimplePreviewController.printFooter(template, detail);
212
+ content += `</div>`;
213
+ return (`<div style="display: flex;"><div style="width : auto;">${content}</div></div>`);
214
+ }
215
+ labelLayout(detail, template) {
216
+ const { products } = detail;
217
+ const { width, paper } = template;
218
+ let content = `<div style="font-weight:normal; margin:0; padding:0; width:${this.calculatePaperSize(paper, width)};"> `;
219
+ products.forEach((row) => {
220
+ let productLabel = LabelPreviewController.createLabelContainer(template);
221
+ productLabel += LabelPreviewController.printSummary(template, detail.order);
222
+ productLabel += LabelPreviewController.printCustomerInformation(template, detail);
223
+ productLabel += LabelPreviewController.printDashLine();
224
+ productLabel += LabelPreviewController.printCategoryTitle(template, row);
225
+ productLabel += LabelPreviewController.printProductTitle(template, row);
226
+ productLabel += LabelPreviewController.printExtrasNames(template, row, detail.company.currencySymbol);
227
+ productLabel += LabelPreviewController.printProductNote(template, row);
228
+ productLabel += `</div><div style="clear: both; page-break-after: always; border-bottom : 2px double red; margin-top : 16px"></div>`;
229
+ let data = "";
230
+ for (let index = 0; index < row.quantity; index++)
231
+ data += productLabel;
232
+ content += data;
233
+ });
234
+ content += `</div>`;
235
+ return (`<div style="display: flex;"><div style="width : auto;">${content}</div></div>`);
236
+ }
237
+ paymentFailed(detail, currency) {
238
+ var _a, _b, _c;
239
+ return `<div style="padding-top: 16px; padding-bottom: 16px;">
240
+ <div style="display: flex; flex-direction: row; align-items: center; justify-content: center;">
241
+ <img alt="" src="https://beta.meemup.com/api/shop/logo/${detail.company.id}"
242
+ style="width: 100px; min-width: 100px; max-width: 100px; aspect-ratio: auto;">
243
+ </div>
244
+ <div
245
+ style="display: flex; flex-direction: row; align-items: center; justify-content: space-between; margin-left: 10%; margin-right: 10%; margin-top: 16px; padding-left: 16px; padding-right: 16px;">
246
+ <strong style="font-size: 18px;">AMOUNT</strong>
247
+ <strong style="font-size: 18px;">${currency} ${detail.order.totalAmount}</strong>
248
+ </div>
249
+ <div
250
+ style="display: flex; flex-direction: row; align-items: center; justify-content: center; border-bottom: 2px solid black; margin-left: 10%; margin-right: 10%; padding: 16px;">
251
+ <strong style="font-size: 18px; padding-right: 16px;"></strong>
252
+ <strong style="font-size: 18px;">#0</strong>
253
+ </div>
254
+ <div
255
+ style="display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 16px 10%; border-bottom: 2px solid black;">
256
+ <strong style="font-size: 18px;">${(_a = detail.paymentInfo) === null || _a === void 0 ? void 0 : _a.state}</strong>
257
+ <p style="font-size: 12px; font-weight: bold; margin-top: 8px; padding-bottom: 16px;">${(_b = detail.paymentInfo) === null || _b === void 0 ? void 0 : _b.message}</p>
258
+ </div>
259
+ <div style="margin-left: 16px; margin-right: 16px;">
260
+ ${(_c = detail.paymentInfo) === null || _c === void 0 ? void 0 : _c.metadata.map(i => (`<div style="display: flex; flex-direction: row; align-items: center; justify-content: flex-start; margin-bottom: 8px;">
261
+ <strong style="font-size: 12px; margin-right: 16px;">${i.text}</strong>
262
+ <strong style="font-size: 12px;">${i.value}</strong>
263
+ </div>`))}
264
+
265
+ </div>
266
+ </div>`;
267
+ }
268
+ packageLabel(detail, template) {
269
+ const { font, fontSize, width, paper } = template;
270
+ const mediumFontSize = (fontSize * 1.5).toFixed(0);
271
+ const largeFontSize = (fontSize * 2.5).toFixed(0);
272
+ return `<div style="font-family : ${font}; font-size: ${fontSize + "px"};font-weight : normal; padding : 10px; border: 1px solid black; width: ${this.calculatePaperSize(paper, width)};">
273
+ <div
274
+ style="display: flex; flex-direction: row; align-items: center; justify-content: space-between; border-bottom: 1px solid black;">
275
+ <strong style="font-size: ${mediumFontSize + "px"};">${detail.order.orderTypeString}</strong>
276
+ <strong style="font-size: ${mediumFontSize + "px"};">#${detail.order.orderNumber}</strong>
277
+ </div>
278
+ <div style="border-bottom: 1px solid black; padding: 8px 0;">
279
+ ${detail.products.map((i) => (`<div style="padding : 2px 0;">${i.title}</div>`)).join("")}
280
+ </div>
281
+ <div
282
+ style="margin-top: 16px; margin-bottom: 6px; padding-bottom: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-bottom: 1px solid black;">
283
+ <strong style="font-size: ${mediumFontSize + "px"};">${detail.order.orderTypeString}</strong>
284
+ <strong style="font-size: ${largeFontSize + "px"};">${detail.order.orderNumber}</strong>
285
+ <div>${detail.customer.fullName}</div>
286
+ </div>
287
+ <div style="display: flex; flex-direction: column; align-items: center; justify-content: center; margin-left: 10%; margin-right: 10%;">
288
+ <div>${this.formatDateTime(detail.order.desiredDate)}</div>
289
+ <div style="display: flex; flex-direction: row; align-items: center; justify-content: center; margin-top: 16px;">
290
+ <img alt="" src="https://beta.meemup.com/api/ordering/${detail.order.id}/${detail.company.id}/QR"
291
+ style="width: 100px; min-width: 100px; max-width: 100px; aspect-ratio: auto;">
292
+ </div>
293
+ </div>
294
+ </div>`;
295
+ }
296
+ preview(account, detail, template) {
297
+ switch (template.layout) {
298
+ case EnumPrintLayout.SIMPLE:
299
+ return this.simpleLayout(account, detail, template);
300
+ case EnumPrintLayout.LARGE:
301
+ return this.largeLayout(account, detail, template);
302
+ case EnumPrintLayout.LABEL:
303
+ const products = this.filterByCategoryList(this.sortProduct(detail.products, template.sortProducts), template.printOnlyCertainCategoriesList, template.printOnlyCertainCategories, template.printOnlyCertainProductsList, template.printOnlyCertainProducts);
304
+ if (products.length === 0)
305
+ return `<div>no product </div>`;
306
+ return this.labelLayout(detail, template);
307
+ case EnumPrintLayout.PACKAGE_LABEL:
308
+ return this.packageLabel(detail, template);
309
+ default:
310
+ return `<div> template.layout : ${template.layout}</div>`;
311
+ }
312
+ }
313
+ }();
@@ -0,0 +1,35 @@
1
+ import IPrintTemplate from "../interfaces/IPrintTemplate";
2
+ import IOrderDetailOrder from "../interfaces/print/IOrderDetailOrder";
3
+ import IAccount from "../interfaces/IAccount";
4
+ import IOrderDetails from "../interfaces/print/IOrderDetails";
5
+ declare class SimplePreviewController {
6
+ printTitle(template: IPrintTemplate): string;
7
+ printSummary(template: IPrintTemplate, order: IOrderDetailOrder): string;
8
+ printLogo(template: IPrintTemplate, detail: IOrderDetails, account: IAccount): string;
9
+ printCompanyNameAndAddress(template: IPrintTemplate, detail: IOrderDetails): string;
10
+ printTextAfterCompanyAddress(template: IPrintTemplate): string;
11
+ printShowPayment(template: IPrintTemplate, detail: IOrderDetails): string;
12
+ printOrderInformation(template: IPrintTemplate, detail: IOrderDetails): string;
13
+ printCustomerInformation(template: IPrintTemplate, detail: IOrderDetails): string;
14
+ printProductCount(template: IPrintTemplate, detail: IOrderDetails): string;
15
+ printTextBeforeProducts(template: IPrintTemplate): string;
16
+ printProducts(template: IPrintTemplate, detail: IOrderDetails): string;
17
+ printLargeProducts(template: IPrintTemplate, detail: IOrderDetails): string;
18
+ printCustomerRemark(template: IPrintTemplate, detail: IOrderDetails): string;
19
+ printDeliveryInstructionsRemarks(template: IPrintTemplate, detail: IOrderDetails): string;
20
+ printCustomerSignature(template: IPrintTemplate, detail: IOrderDetails): string;
21
+ printPromotionNote(template: IPrintTemplate): string;
22
+ printMetaData(template: IPrintTemplate, detail: IOrderDetails): string;
23
+ printSplitPayments(template: IPrintTemplate, detail: IOrderDetails): string;
24
+ printQrCode(template: IPrintTemplate, detail: IOrderDetails): string;
25
+ printTextEnd(template: IPrintTemplate): string;
26
+ printFooter(template: IPrintTemplate, detail: IOrderDetails): string;
27
+ printDashLine(): string;
28
+ printSolidLine(): string;
29
+ private createDivContainer;
30
+ private filterByCategoryList;
31
+ private sortProduct;
32
+ private pizzaSideText;
33
+ }
34
+ declare const controller: SimplePreviewController;
35
+ export default controller;
@@ -0,0 +1,592 @@
1
+ import moment from "moment";
2
+ import PhoneController from "./PhoneController";
3
+ import EnumPaymentType from "../enums/EnumPaymentType";
4
+ import MoneyController from "./MoneyController";
5
+ import EnumShowCustomer from "../enums/EnumShowCustomer";
6
+ import EnumOrderType from "../enums/EnumOrderType";
7
+ import EnumPizzaSide from "../enums/EnumPizzaSide";
8
+ import EnumPaymentState from "../enums/EnumPaymentState";
9
+ import OrderToolController from "./OrderToolController";
10
+ import EnumOrderDateTimePrintModeType from "../enums/EnumOrderDateTimePrintModeType";
11
+ class SimplePreviewController {
12
+ constructor() {
13
+ this.filterByCategoryList = (products, catList, onlyListCategory, productList, onlyListProduct) => {
14
+ if (!onlyListCategory && !onlyListProduct) {
15
+ return products;
16
+ }
17
+ const new_product = [];
18
+ if (onlyListCategory && !onlyListProduct) {
19
+ products.filter(x => catList.find(element => element === x.categoryId)).forEach((row) => new_product.push(row));
20
+ }
21
+ else if (!onlyListCategory && onlyListProduct) {
22
+ products.filter(x => productList.find(element => element === x.productId)).forEach((row) => new_product.push(row));
23
+ }
24
+ else {
25
+ const arr = [];
26
+ products.filter(x => catList.find(element => element === x.categoryId)).forEach((row) => arr.push(row));
27
+ arr.filter(x => productList.find(element => element === x.productId)).forEach((row) => {
28
+ new_product.push(row);
29
+ });
30
+ }
31
+ return new_product;
32
+ };
33
+ }
34
+ printTitle(template) {
35
+ if (template.headerOfPrintText === null)
36
+ return "";
37
+ // if (template.headerOfPrintText.trim() === "") return "";
38
+ let align = template.headerOfPrintIsCenter ? "center" : "left";
39
+ let content = this.createDivContainer(template);
40
+ let text = template.headerOfPrintText.replace(/ /g, '&nbsp;').replace(/(?:\r\n|\r|\n)/g, '<br>');
41
+ content += `<p style="text-align: ${align}; font-size: ${template.fontSize}px;">${text}</p>`;
42
+ content += `</div>`;
43
+ return content;
44
+ }
45
+ printSummary(template, order) {
46
+ var _a;
47
+ if (!template.orderSummary)
48
+ return "";
49
+ // let largeFontSize = parseInt((template.fontSize + 10) + "") + "px";
50
+ let largeFontSize = template.printer === 5 ? "22px" : parseInt((template.fontSize + 10) + "") + "px";
51
+ let content = this.createDivContainer(template);
52
+ content += `<div style="display:grid; grid-template-columns: repeat(1 , 1fr);">`;
53
+ let summary = `<strong style="font-size: ${largeFontSize}; text-align: center;">#${order.orderNumber}&emsp;${order.orderTypeString}</strong>`;
54
+ content += summary;
55
+ if (template.orderDesiredDateTimeVisibility) {
56
+ let formated = "";
57
+ let dateFormat = template.orderDateTimeFormat.replace("tt", "A");
58
+ switch (template.orderDateTimeMode) {
59
+ case EnumOrderDateTimePrintModeType.RegistrationDate:
60
+ formated = "Reg. " + moment(order.registrationDate).format(dateFormat); // order.registrationDate;
61
+ break;
62
+ case EnumOrderDateTimePrintModeType.ReadyTime:
63
+ formated = "Rdy. " + moment(order.orderReadyTime).format(dateFormat);
64
+ break;
65
+ case EnumOrderDateTimePrintModeType.WishTime:
66
+ formated = "Eat. " + moment(order.desiredDate).format(dateFormat); // order.desiredDate;
67
+ break;
68
+ case EnumOrderDateTimePrintModeType.PreparationStartTime:
69
+ formated = "Pre. " + moment(order.orderPreparationStartTime).format(dateFormat);
70
+ break;
71
+ default:
72
+ formated = "Eat. " + moment(order.desiredDate).format(dateFormat); // order.desiredDate;
73
+ break;
74
+ }
75
+ content += `<strong style="display:block; font-size: ${largeFontSize}; text-align: center;">${formated}</strong>`;
76
+ }
77
+ if (typeof order.estimatedTime === "string" && order.estimatedTime.length > 0)
78
+ content += `<strong style="display: block; font-size: ${largeFontSize}; text-align:center;">Est. Time ${(_a = order.estimatedTime) === null || _a === void 0 ? void 0 : _a.substring(0, 5)}</strong>`;
79
+ content += `</div>`;
80
+ content += `</div>`;
81
+ return content;
82
+ }
83
+ printLogo(template, detail, account) {
84
+ if (!template.logoAvailable || template.logoUrl === null || template.logoUrl === "")
85
+ return "";
86
+ const url = `${account.rootUrl}${detail.company.id}/${template.logoUrl}`;
87
+ let content = this.createDivContainer(template);
88
+ let size = template.width - (template.paddingRight + template.paddingLeft);
89
+ size *= 0.7;
90
+ size = parseInt(size + "");
91
+ if (template.logoCenter)
92
+ content += `<img alt="" style=" display : block; aspect-ratio: auto; margin :auto; width: ${size}mm; max-height : ${size}mm;" src="${url}" />`;
93
+ else
94
+ content += `<img alt="" style=" display : block; margin :0; width: ${size}mm; max-height : ${size}mm;" src="${url}" />`;
95
+ content += `</div>`;
96
+ return content;
97
+ }
98
+ printCompanyNameAndAddress(template, detail) {
99
+ if (!template.nameAddressShow)
100
+ return "";
101
+ let content = this.createDivContainer(template);
102
+ let textAlign = template.nameAddressCenter ? "center" : "left";
103
+ content += `<p style="display:block; font-size: ${template.fontSize}px; text-align: ${textAlign};">${detail.company.title}</p>`;
104
+ content += `<p style="display:block; font-size: ${template.fontSize}px; text-align: ${textAlign};">${detail.company.address}</p>`;
105
+ content += `<p style="display:block; font-size: ${template.fontSize}px; text-align: ${textAlign};">${PhoneController.toDisplay(detail.company.phone)}</p>`;
106
+ content += `</div>`;
107
+ return content;
108
+ }
109
+ printTextAfterCompanyAddress(template) {
110
+ if (template.textAfterAddress === "")
111
+ return ""; // this.printDashLine();
112
+ let text = template.textAfterAddress.replace(/ /g, '&nbsp;').replace(/(?:\r\n|\r|\n)/g, '<br>');
113
+ let align = template.textAfterAddressCenter ? "center" : "left";
114
+ let content = this.createDivContainer(template);
115
+ content += `<p style="display: block; font-size: ${template.fontSize}px; text-align: ${align};">${text}</p>`;
116
+ content += `</div>`;
117
+ return content;
118
+ }
119
+ printShowPayment(template, detail) {
120
+ if (!template.showPrices)
121
+ return "";
122
+ let content = this.createDivContainer(template);
123
+ content += this.printDashLine();
124
+ content += `<p style="display : block; font-size: ${template.fontSize}px; text-align: left;">Payment information</p>`;
125
+ content += `<strong style="font-size: ${template.fontSize * 1.6};">${detail.order.paymentTypeString + (detail.order.paymentType === EnumPaymentType.cash ? `: ${MoneyController.format(detail.order.totalAmount, detail.company.currencySymbol)} ` : " ") + " - " + detail.order.paymentStateString}</strong>`;
126
+ if (detail.order.paymentType === EnumPaymentType.online)
127
+ content += `<p style="display:block;">Credit Card: **** **** **** ${detail.order.lastFourDigits}</p>`;
128
+ content += `</div>`;
129
+ return content;
130
+ }
131
+ printOrderInformation(template, detail) {
132
+ var _a;
133
+ if (!template.orderInfo)
134
+ return "";
135
+ let content = this.createDivContainer(template);
136
+ content += this.printDashLine();
137
+ content += `<p style="display:block; font-size: ${template.fontSize}px; text-align: left;">Order number:&emsp;${detail.order.orderNumber}</p>`;
138
+ content += `<p style="display:block; font-size: ${template.fontSize}px; text-align: left;">${detail.order.orderTypeString}:&emsp;on ${moment(detail.order.desiredDate).format("hh:mm A")}</p>`;
139
+ if (typeof detail.order.estimatedTime === "string" && detail.order.estimatedTime.length > 0)
140
+ content += `<p style="display: block; font-size: ${template.fontSize}px; text-align:left;">Est. Time:&nbsp;&ensp;&emsp;${(_a = detail.order.estimatedTime) === null || _a === void 0 ? void 0 : _a.substring(0, 5)}</p>`;
141
+ content += `<p style="display: block; font-size: ${template.fontSize}px; text-align:left;">Reg. Time:&nbsp;&ensp;&emsp;${moment(detail.order.registrationDate).format("YYYY-MM-DD hh:mm A")}</p>`;
142
+ content += `</div>`;
143
+ return content;
144
+ }
145
+ printCustomerInformation(template, detail) {
146
+ if (template.showCustomerInfo === EnumShowCustomer.NO)
147
+ return "";
148
+ if (template.showCustomerInfo === EnumShowCustomer.YES_WHEN_DELIVERY_ORDER && detail.order.orderType !== EnumOrderType.delivery)
149
+ return "";
150
+ let content = this.createDivContainer(template);
151
+ content += this.printDashLine();
152
+ if (template.printCustomerDetailsInLarge) {
153
+ let largeFontSize = template.printer === 5 ? 22 : parseInt((template.fontSize + 10) + "");
154
+ content += `<p style="display : block; font-size: ${largeFontSize}px; text-align: left;">Customer information</p>`;
155
+ content += `<strong style="display:block; font-size: ${largeFontSize}px;">${detail.customer.fullName}</strong>`;
156
+ content += `<strong style="display:block; font-size: ${largeFontSize}px;">${PhoneController.toDisplay(detail.customer.phoneNumber)}</strong>`;
157
+ // content += `<p style="display:block; font-size: ${template.fontSize}px;">${detail.customer.email}</p>`;
158
+ content += `<strong style="display:block; font-size: ${largeFontSize}px;">${detail.customer.address}</strong>`;
159
+ }
160
+ else {
161
+ content += `<p style="display : block; font-size: ${template.fontSize}px; text-align: left;">Customer information</p>`;
162
+ content += `<strong style="display:block; font-size: ${template.fontSize}px;">${detail.customer.fullName}</strong>`;
163
+ content += `<strong style="display:block; font-size: ${template.fontSize}px;">${PhoneController.toDisplay(detail.customer.phoneNumber)}</strong>`;
164
+ // content += `<p style="display:block; font-size: ${template.fontSize}px;">${detail.customer.email}</p>`;
165
+ content += `<strong style="display:block; font-size: ${template.fontSize}px;">${detail.customer.address}</strong>`;
166
+ }
167
+ content += `</div>`;
168
+ return content;
169
+ }
170
+ printProductCount(template, detail) {
171
+ let list = this.filterByCategoryList(this.sortProduct(detail.products, template.sortProducts), template.printOnlyCertainCategoriesList, template.printOnlyCertainCategories, template.printOnlyCertainProductsList, template.printOnlyCertainProducts);
172
+ let count = MoneyController.sum(list.map(i => i.quantity));
173
+ let content = this.createDivContainer(template);
174
+ content += `<p style="display: block; font-size: ${template.fontSize + 10}px; text-align: left;">${count} ITEM</p>`;
175
+ content += `</div>`;
176
+ return content;
177
+ }
178
+ printTextBeforeProducts(template) {
179
+ if (template.textBeforeProducts === "")
180
+ return this.printDashLine();
181
+ let text = template.textBeforeProducts.replace(/ /g, '&nbsp;').replace(/(?:\r\n|\r|\n)/g, '<br>');
182
+ let align = template.textBeforeProductsCenter ? "center" : "left";
183
+ let content = this.createDivContainer(template);
184
+ content += this.printSolidLine();
185
+ content += `<p style="display: block; font-size: ${template.fontSize}px; text-align: ${align};">${text}</p>`;
186
+ content += this.printSolidLine();
187
+ content += `</div>`;
188
+ return content;
189
+ }
190
+ printProducts(template, detail) {
191
+ let content = this.createDivContainer(template);
192
+ content += `<table style="width: 100%; border-collapse: collapse;">
193
+ <thead style="border-bottom: 1px solid #000000;">
194
+ <tr>
195
+ <th style="font-size:${template.fontSize}px;min-width:40px; width: 40px; text-align: left; font-weight: bold;">#</th>
196
+ <th style="font-size:${template.fontSize}px;flex: 1; width: 100%; text-align: left; font-weight: bold;">Product</th>
197
+ <th style="font-size:${template.fontSize}px;max-width: 90px; text-align: right; font-weight: bold;">Price</th>
198
+ </tr>
199
+ </thead>
200
+ <tbody>
201
+ `;
202
+ detail.products.forEach((row) => {
203
+ let productName = (template.showCategoryTitle ? `[${row.categoryTitle}] ` : "") + ((template.showProductKitchenName && row.kitchenReceiptName.trim().length > 0) ? row.kitchenReceiptName : row.title);
204
+ let amount = template.showPrices ? MoneyController.format(row.totalAmount, detail.company.currencySymbol) : "";
205
+ content += `<tr>
206
+ <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;">${row.quantity}X</td>
207
+ <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: left; font-weight: bold;">${productName}</td>
208
+ <td style="font-size:${template.fontSize}px; max-width: 90px; text-align: right;">${amount}</td>
209
+ </tr>`;
210
+ row.extras.forEach(element => {
211
+ let extraText = this.pizzaSideText(element.pizzaSide) + element.quantity + "X " + element.extraItemTitle;
212
+ let extraAmount = template.showPrices ? MoneyController.format(element.totalAmount, detail.company.currencySymbol) : "";
213
+ content += `<tr>
214
+ <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
215
+ <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: left;">${extraText}</td>
216
+ <td style="font-size:${template.fontSize}px; max-width: 90px; text-align: right;">${extraAmount}</td>
217
+ </tr>`;
218
+ });
219
+ if (row.note !== null && row.note.trim().length > 0) {
220
+ content += `<tr>
221
+ <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;">Note:</td>
222
+ <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: left;font-weight: bold;">${row.note}</td>
223
+ <td style="font-size:${template.fontSize}px; max-width: 90px; text-align: right;"></td>
224
+ </tr>`;
225
+ }
226
+ });
227
+ if (template.showPrices) {
228
+ //order amount
229
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
230
+ <td style="font-size:${template.fontSize}px; width: 40px; text-align: left;"></td>
231
+ <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right;padding-right: 8px;">
232
+ Order Amount:
233
+ </td>
234
+ <td style="font-size:${template.fontSize}px; width: 90px; text-align: right;">
235
+ ${MoneyController.format(detail.order.orderAmount, detail.company.currencySymbol)}
236
+ </td>
237
+ </tr>`;
238
+ if (detail.order.orderType === EnumOrderType.delivery && detail.order.deliveryCost > 0) {
239
+ //delivery amount
240
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
241
+ <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
242
+ <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right;padding-right: 8px;">
243
+ Delivery costs:
244
+ </td>
245
+ <td style="font-size:${template.fontSize}px; width: 90px; text-align: right;">
246
+ ${MoneyController.format(detail.order.deliveryCost, detail.company.currencySymbol)}
247
+ </td>
248
+ </tr>`;
249
+ }
250
+ if (detail.order.discountAmount > 0) {
251
+ //discount amount
252
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
253
+ <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
254
+ <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right;padding-right: 8px;">
255
+ Discount:
256
+ </td>
257
+ <td style="font-size:${template.fontSize}px; width: 90px; text-align: right;">
258
+ ${MoneyController.format(detail.order.discountAmount, detail.company.currencySymbol)}
259
+ </td>
260
+ </tr>`;
261
+ }
262
+ //subtotal amount
263
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
264
+ <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
265
+ <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right;padding-right: 8px;">
266
+ Subtotal:
267
+ </td>
268
+ <td style="font-size:${template.fontSize}px; width: 90px; text-align: right;">
269
+ ${MoneyController.format(detail.order.subtotalAmount, detail.company.currencySymbol)}
270
+ </td>
271
+ </tr>`;
272
+ if (detail.order.hstAmount > 0 && detail.order.serviceFee < 1) {
273
+ //hst and service fee and company fee amount
274
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
275
+ <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
276
+ <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right; padding-right: 8px;">
277
+ HST(${MoneyController.format(detail.order.hstPercentage, "%")}):
278
+ </td>
279
+ <td style="font-size:${template.fontSize + "px"}; width: 90px; text-align: right;">
280
+ ${MoneyController.format(detail.order.hstAmount, detail.company.currencySymbol)}
281
+ </td>
282
+ </tr>`;
283
+ }
284
+ if (detail.order.tipAmount > 0) {
285
+ //tip amount
286
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
287
+ <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
288
+ <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right; padding-right: 8px;">
289
+ Tip:
290
+ </td>
291
+ <td style="font-size:${template.fontSize}px; width: 90px; text-align: right;">
292
+ ${MoneyController.format(detail.order.tipAmount, detail.company.currencySymbol)}
293
+ </td>
294
+ </tr>`;
295
+ }
296
+ }
297
+ content += `</tbody></table>`;
298
+ //total amount
299
+ content += `<div style="display: flex; flex-direction: row; align-items: center; border-top: 1px dashed #000000; margin: 4px 0;">
300
+ <div style="font-size:${template.fontSize + 6}px; flex: 1; text-align: right; padding-right: 8px;">
301
+ ${detail.order.paymentState !== EnumPaymentState.PAID ? "Total & Still to pay" : "Total"}:
302
+ </div>
303
+ <div style="font-size:${(template.fontSize + 10) + "px"}; width: 90px; text-align: right;">
304
+ ${MoneyController.format(detail.order.totalAmount, detail.company.currencySymbol)}
305
+ </div>
306
+ </div>`;
307
+ content += this.printSolidLine();
308
+ content += `</div>`;
309
+ return content;
310
+ }
311
+ printLargeProducts(template, detail) {
312
+ let content = this.createDivContainer(template);
313
+ let largeFontSize = template.printer === 5 ? 22 : parseInt((template.fontSize + 10) + "");
314
+ content += `<table style="width: 100%; border-collapse: collapse;">
315
+ <thead style="border-bottom: 1px solid #000000;">
316
+ <tr>
317
+ <th style="font-size:${template.fontSize}px;min-width:40px; width: 40px; text-align: left; font-weight: bold;">#</th>
318
+ <th style="font-size:${template.fontSize}px;flex: 1; width: 100%; text-align: left; font-weight: bold;">Product</th>
319
+ <th style="font-size:${template.fontSize}px;max-width: 90px; text-align: right; font-weight: bold;">Price</th>
320
+ </tr>
321
+ </thead>
322
+ <tbody>
323
+ `;
324
+ detail.products.forEach((row) => {
325
+ let productName = (template.showCategoryTitle ? `[${row.categoryTitle}] ` : "") + ((template.showProductKitchenName && row.kitchenReceiptName.trim().length > 0) ? row.kitchenReceiptName : row.title);
326
+ let amount = template.showPrices ? MoneyController.format(row.totalAmount, detail.company.currencySymbol) : "";
327
+ content += `<tr>
328
+ <td style="font-size:${largeFontSize}px; min-width:40px; width: 40px; text-align: left;">${row.quantity}X</td>
329
+ <td style="font-size:${largeFontSize}px; flex: 1; width: 100%; text-align: left; font-weight: bold;">${productName}</td>
330
+ <td style="font-size:${largeFontSize}px; max-width: 90px; text-align: right;">${amount}</td>
331
+ </tr>`;
332
+ row.extras.forEach(element => {
333
+ let extraText = this.pizzaSideText(element.pizzaSide) + element.quantity + "X " + element.extraItemTitle;
334
+ let extraAmount = template.showPrices ? MoneyController.format(element.totalAmount, detail.company.currencySymbol) : "";
335
+ content += `<tr>
336
+ <td style="font-size:${largeFontSize}px; min-width:40px; width: 40px; text-align: left;">&ensp;</td>
337
+ <td style="font-size:${largeFontSize}px; flex: 1; width: 100%; text-align: left;">${extraText}</td>
338
+ <td style="font-size:${largeFontSize}px; max-width: 90px; text-align: right;">${extraAmount}</td>
339
+ </tr>`;
340
+ });
341
+ if (row.note !== null && row.note.trim().length > 0) {
342
+ content += `<tr>
343
+ <td style="font-size:${largeFontSize}px; min-width:40px; width: 40px; text-align: left;">Note:</td>
344
+ <td style="font-size:${largeFontSize}px; flex: 1; width: 100%; text-align: left;font-weight: bold;">${row.note}</td>
345
+ <td style="font-size:${largeFontSize}px; max-width: 90px; text-align: right;"></td>
346
+ </tr>`;
347
+ }
348
+ });
349
+ if (template.showPrices) {
350
+ //order amount
351
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
352
+ <td style="font-size:${template.fontSize}px; width: 40px; text-align: left;"></td>
353
+ <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right;padding-right: 8px;">
354
+ Order Amount:
355
+ </td>
356
+ <td style="font-size:${template.fontSize}px; width: 90px; text-align: right;">
357
+ ${MoneyController.format(detail.order.orderAmount, detail.company.currencySymbol)}
358
+ </td>
359
+ </tr>`;
360
+ if (detail.order.orderType === EnumOrderType.delivery && detail.order.deliveryCost > 0) {
361
+ //delivery amount
362
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
363
+ <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
364
+ <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right;padding-right: 8px;">
365
+ Delivery costs:
366
+ </td>
367
+ <td style="font-size:${template.fontSize}px; width: 90px; text-align: right;">
368
+ ${MoneyController.format(detail.order.deliveryCost, detail.company.currencySymbol)}
369
+ </td>
370
+ </tr>`;
371
+ }
372
+ if (detail.order.discountAmount > 0) {
373
+ //discount amount
374
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
375
+ <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
376
+ <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right;padding-right: 8px;">
377
+ Discount:
378
+ </td>
379
+ <td style="font-size:${template.fontSize}px; width: 90px; text-align: right;">
380
+ ${MoneyController.format(detail.order.discountAmount, detail.company.currencySymbol)}
381
+ </td>
382
+ </tr>`;
383
+ }
384
+ //subtotal amount
385
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
386
+ <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
387
+ <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right;padding-right: 8px;">
388
+ Subtotal:
389
+ </td>
390
+ <td style="font-size:${template.fontSize}px; width: 90px; text-align: right;">
391
+ ${MoneyController.format(detail.order.subtotalAmount, detail.company.currencySymbol)}
392
+ </td>
393
+ </tr>`;
394
+ if (detail.order.hstAmount > 0 && detail.order.serviceFee < 1) {
395
+ //hst and service fee and company fee amount
396
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
397
+ <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
398
+ <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right; padding-right: 8px;">
399
+ HST(${MoneyController.format(detail.order.hstPercentage, "%")}):
400
+ </td>
401
+ <td style="font-size:${template.fontSize + "px"}; width: 90px; text-align: right;">
402
+ ${MoneyController.format(detail.order.hstAmount, detail.company.currencySymbol)}
403
+ </td>
404
+ </tr>`;
405
+ }
406
+ if (detail.order.tipAmount > 0) {
407
+ //tip amount
408
+ content += `<tr style=" border-top: 1px dashed #000000; margin: 4px 0;">
409
+ <td style="font-size:${template.fontSize}px; min-width:40px; width: 40px; text-align: left;"></td>
410
+ <td style="font-size:${template.fontSize}px; flex: 1; width: 100%; text-align: right; padding-right: 8px;">
411
+ Tip:
412
+ </td>
413
+ <td style="font-size:${template.fontSize}px; width: 90px; text-align: right;">
414
+ ${MoneyController.format(detail.order.tipAmount, detail.company.currencySymbol)}
415
+ </td>
416
+ </tr>`;
417
+ }
418
+ }
419
+ content += `</tbody></table>`;
420
+ //total amount
421
+ content += `<div style="display: flex; flex-direction: row; align-items: center; border-top: 1px dashed #000000; margin: 4px 0;">
422
+ <div style="font-size:${template.fontSize + 6}px; flex: 1; text-align: right; padding-right: 8px;">
423
+ ${detail.order.paymentState !== EnumPaymentState.PAID ? "Total & Still to pay" : "Total"}:
424
+ </div>
425
+ <div style="font-size:${(template.fontSize + 10) + "px"}; width: 90px; text-align: right;">
426
+ ${MoneyController.format(detail.order.totalAmount, detail.company.currencySymbol)}
427
+ </div>
428
+ </div>`;
429
+ content += this.printSolidLine();
430
+ content += `</div>`;
431
+ return content;
432
+ }
433
+ printCustomerRemark(template, detail) {
434
+ if (detail.order.remarks === null || detail.order.remarks.trim().length === 0)
435
+ return "";
436
+ let content = this.createDivContainer(template);
437
+ content += this.printSolidLine();
438
+ content += `<p style="text-align: left; font-size: ${template.fontSize}px;">${detail.order.remarks}</p>`;
439
+ content += `</div>`;
440
+ return content;
441
+ }
442
+ printDeliveryInstructionsRemarks(template, detail) {
443
+ if (detail.order.orderType !== EnumOrderType.delivery || detail.order.deliveryInstructionsRemarks === null || detail.order.deliveryInstructionsRemarks.trim().length === 0)
444
+ return "";
445
+ let content = this.createDivContainer(template);
446
+ content += this.printSolidLine();
447
+ content += `<p style="text-align: left; font-size: ${template.fontSize}px;">${detail.order.deliveryInstructionsRemarks}</p>`;
448
+ content += `</div>`;
449
+ return content;
450
+ }
451
+ printCustomerSignature(template, detail) {
452
+ if (detail.order.paymentType !== EnumPaymentType.online || !template.customerOnlinePaymentAgrementSection)
453
+ return "";
454
+ let content = this.createDivContainer(template);
455
+ content += `<p style="display: block; text-align: center; font-size: ${template.fontSize}px;">CREDIT CARD: **** **** **** ${detail.order.lastFourDigits}</p>`;
456
+ content += `<strong style="display: block; text-align: center; font-size: ${template.fontSize}px;">I agree to pay above total amount according to card issuer agreement</strong>`;
457
+ content += "</br>";
458
+ content += `<p style="display: block; text-align: center; font-size: ${template.fontSize}px;">SIGNATURE</p>`;
459
+ content += "</br>";
460
+ content += `</div>`;
461
+ return content;
462
+ }
463
+ printPromotionNote(template) {
464
+ if (template.promotionId === null || template.promotionCodeNote === null || template.promotionCodeNote === undefined || template.promotionCodeNote.trim().length === 0)
465
+ return "";
466
+ let content = this.createDivContainer(template);
467
+ content += this.printSolidLine();
468
+ content += `<p style="text-align: left; font-size: ${template.fontSize}px; margin-bottom: 10px;">${template.promotionCodeNote}</p>`;
469
+ content += `</div>`;
470
+ return content;
471
+ }
472
+ printMetaData(template, detail) {
473
+ var _a, _b, _c;
474
+ if (detail.paymentInfo !== null && detail.order.paymentType === EnumPaymentType.terminal && Array.isArray((_a = detail.paymentInfo) === null || _a === void 0 ? void 0 : _a.metadata) && ((_c = (_b = detail.paymentInfo) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.length) > 0) {
475
+ let content = this.createDivContainer(template);
476
+ content += this.printSolidLine();
477
+ detail.paymentInfo.metadata.forEach(item => {
478
+ content += `<p style="display: block; text-align: left; font-size: ${template.fontSize}px;">${item.text}: ${item.value}</p>`;
479
+ });
480
+ content += `</div>`;
481
+ return content;
482
+ }
483
+ return "";
484
+ }
485
+ printSplitPayments(template, detail) {
486
+ if (Array.isArray(detail.paymentTransactions) && detail.paymentTransactions.length > 0) {
487
+ let content = this.createDivContainer(template);
488
+ content += this.printSolidLine();
489
+ detail.paymentTransactions.forEach(item => {
490
+ content += `<p style="display: block; text-align: left; font-size: ${template.fontSize}px;">${OrderToolController.getPaymentTypeText(item.paymentType, detail.order.orderType)}: ${MoneyController.format(item.amount, detail.company.currencySymbol)}</p>`;
491
+ });
492
+ content += `</div>`;
493
+ return content;
494
+ }
495
+ return "";
496
+ }
497
+ printQrCode(template, detail) {
498
+ if (!template.qrCodeOrderDetails || detail.order.qrCodeDetailUrl.trim() === "")
499
+ return "";
500
+ let content = this.createDivContainer(template);
501
+ // content += this.printSolidLine();
502
+ content += `<div style="display : flex; justify-content: center; align-items: center;">
503
+ <img alt="" style="width: 100px; height: 100px; margin: auto;" src="${detail.order.qrCodeDetailUrl}" />
504
+ </div>`;
505
+ // content += this.printSolidLine();
506
+ content += `</div>`;
507
+ return content;
508
+ }
509
+ printTextEnd(template) {
510
+ if (template.textEnd === "")
511
+ return "";
512
+ let text = template.textEnd.replace(/ /g, '&nbsp;').replace(/(?:\r\n|\r|\n)/g, '<br>');
513
+ let align = template.textEndCenter ? "center" : "left";
514
+ let content = this.createDivContainer(template);
515
+ content += `<p style="display: block; font-size: ${template.fontSize}px; text-align: ${align};">${text}</p>`;
516
+ content += `</div>`;
517
+ return content;
518
+ }
519
+ printFooter(template, detail) {
520
+ let content = this.createDivContainer(template);
521
+ content += `<p style="display: block; font-size: ${template.fontSize}px; text-align: center;">FS.${detail.company.id}.${detail.order.id}.${template.id}</p>`;
522
+ content += `<p style="display: block; font-size: ${template.fontSize}px; text-align: center;">Printed on ${new Date().toDateString()} ${new Date().toTimeString().substring(0, 8)}</p>`;
523
+ content += `<strong style="display: block; font-size: ${template.fontSize}px; text-align: center;">Powered by Meemup.com</strong>`;
524
+ content += `</div>`;
525
+ return content;
526
+ }
527
+ printDashLine() {
528
+ return `<div style="display: block; border-top: 1px dashed #000000; margin: 4px 0;"></div>`;
529
+ }
530
+ printSolidLine() {
531
+ return `<div style="display: block; border-top: 1px solid #000000; margin: 4px 0;"></div>`;
532
+ }
533
+ createDivContainer(template) {
534
+ return `<div style="display: block; padding-left: ${template.paddingLeft}mm; padding-right: ${template.paddingRight}mm;" >`;
535
+ }
536
+ sortProduct(products, sortType) {
537
+ const new_product = [];
538
+ if (sortType === 1) {
539
+ return products;
540
+ }
541
+ else if (sortType === 2) {
542
+ products.sort((a, b) => {
543
+ let nameA = a.title.toUpperCase(); // ignore upper and lowercase
544
+ let nameB = b.title.toUpperCase(); // ignore upper and lowercase
545
+ if (nameA < nameB) {
546
+ return -1;
547
+ }
548
+ if (nameA > nameB) {
549
+ return 1;
550
+ }
551
+ // names must be equal
552
+ return 0;
553
+ }).forEach((row) => new_product.push(row));
554
+ }
555
+ else if (sortType === 3) {
556
+ products.sort(function (a, b) {
557
+ let nameA = a.title.toUpperCase(); // ignore upper and lowercase
558
+ let nameB = b.title.toUpperCase(); // ignore upper and lowercase
559
+ if (nameA > nameB) {
560
+ return -1;
561
+ }
562
+ if (nameA < nameB) {
563
+ return 1;
564
+ }
565
+ // names must be equal
566
+ return 0;
567
+ }).forEach((row) => new_product.push(row));
568
+ }
569
+ else if (sortType === 4) {
570
+ products.sort((a, b) => a.totalAmount > b.totalAmount ? 1 : -1).forEach((row) => new_product.push(row));
571
+ }
572
+ else if (sortType === 5) {
573
+ products.sort((a, b) => a.totalAmount < b.totalAmount ? 1 : -1).forEach((row) => new_product.push(row));
574
+ }
575
+ return new_product;
576
+ }
577
+ ;
578
+ pizzaSideText(value) {
579
+ switch (value) {
580
+ case EnumPizzaSide.left:
581
+ return "[LEFT] ";
582
+ case EnumPizzaSide.right:
583
+ return "[RIGHT] ";
584
+ case EnumPizzaSide.all:
585
+ return "[WHOLE] ";
586
+ default:
587
+ return "";
588
+ }
589
+ }
590
+ }
591
+ const controller = new SimplePreviewController();
592
+ export default controller;
@@ -1,6 +1,8 @@
1
1
  import IOrderDetailCustomerComment from "./IOrderDetailCustomerComment";
2
2
  interface IOrderDetailCustomer {
3
3
  id: number;
4
+ firstName: string;
5
+ lastName: string;
4
6
  fullName: string;
5
7
  isCompany: boolean;
6
8
  email: string;
@@ -1,5 +1,7 @@
1
1
  export const initOrderDetailCustomer = {
2
2
  id: -1,
3
+ firstName: "",
4
+ lastName: "",
3
5
  fullName: "",
4
6
  isCompany: false,
5
7
  email: "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meemup-library",
3
- "version": "1.3.66",
3
+ "version": "1.3.68",
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.3.66 \" && git push origin "
14
+ "commit": "git add . && git commit -m \"version.1.3.68 \" && git push origin "
15
15
  },
16
16
  "files": [
17
17
  "/dist"
@@ -23,5 +23,7 @@
23
23
  "rimraf": "^6.0.1",
24
24
  "typescript": "^5.7.2"
25
25
  },
26
- "dependencies": {}
26
+ "dependencies": {
27
+ "moment": "^2.30.1"
28
+ }
27
29
  }