seven365-zyprinter 0.5.0 → 1.0.2
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.
- package/README.md +92 -17
- package/dist/docs.json +357 -24
- package/dist/esm/definitions.d.ts +62 -11
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Sources/Plugin/ZywellSDK.swift +420 -48
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,6 +35,7 @@ npx cap sync
|
|
|
35
35
|
* [`printReceipt(...)`](#printreceipt)
|
|
36
36
|
* [`getPrinterStatus(...)`](#getprinterstatus)
|
|
37
37
|
* [Interfaces](#interfaces)
|
|
38
|
+
* [Type Aliases](#type-aliases)
|
|
38
39
|
|
|
39
40
|
</docgen-index>
|
|
40
41
|
|
|
@@ -197,14 +198,46 @@ getPrinterStatus(options: { identifier: string; }) => Promise<{ status: string;
|
|
|
197
198
|
|
|
198
199
|
#### ReceiptTemplate
|
|
199
200
|
|
|
200
|
-
| Prop
|
|
201
|
-
|
|
|
202
|
-
| **`header`**
|
|
203
|
-
| **`
|
|
204
|
-
| **`
|
|
205
|
-
| **`total`**
|
|
206
|
-
| **`
|
|
207
|
-
| **`
|
|
201
|
+
| Prop | Type |
|
|
202
|
+
| ------------------ | ------------------------------------------------------------------------------ |
|
|
203
|
+
| **`header`** | <code><a href="#headerconfig">HeaderConfig</a></code> |
|
|
204
|
+
| **`kitchen`** | <code>KitchenItem[]</code> |
|
|
205
|
+
| **`items`** | <code><a href="#array">Array</a><{ name: string; price: string }></code> |
|
|
206
|
+
| **`total`** | <code>string</code> |
|
|
207
|
+
| **`order_type`** | <code>string</code> |
|
|
208
|
+
| **`table_name`** | <code>string</code> |
|
|
209
|
+
| **`order_number`** | <code>string</code> |
|
|
210
|
+
| **`footer`** | <code><a href="#footerconfig">FooterConfig</a></code> |
|
|
211
|
+
| **`item`** | <code><a href="#itemconfig">ItemConfig</a></code> |
|
|
212
|
+
| **`total_config`** | <code><a href="#totalconfig">TotalConfig</a></code> |
|
|
213
|
+
| **`modifier`** | <code><a href="#modifierconfig">ModifierConfig</a></code> |
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
#### HeaderConfig
|
|
217
|
+
|
|
218
|
+
| Prop | Type |
|
|
219
|
+
| --------------------- | --------------------------------------- |
|
|
220
|
+
| **`restaurant_name`** | <code>string</code> |
|
|
221
|
+
| **`sub_header`** | <code>string</code> |
|
|
222
|
+
| **`prefix`** | <code>string</code> |
|
|
223
|
+
| **`gst_number`** | <code>string</code> |
|
|
224
|
+
| **`address`** | <code>string</code> |
|
|
225
|
+
| **`phone_number`** | <code>string</code> |
|
|
226
|
+
| **`size`** | <code><a href="#tsize">TSize</a></code> |
|
|
227
|
+
| **`bold`** | <code>boolean</code> |
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
#### KitchenItem
|
|
231
|
+
|
|
232
|
+
| Prop | Type |
|
|
233
|
+
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
|
234
|
+
| **`qty`** | <code>number</code> |
|
|
235
|
+
| **`name`** | <code>string</code> |
|
|
236
|
+
| **`menu`** | <code>{ _id?: string; name: string; price?: string; categoryName?: string; printer?: string; }</code> |
|
|
237
|
+
| **`quantity`** | <code>number</code> |
|
|
238
|
+
| **`price`** | <code>number</code> |
|
|
239
|
+
| **`total_price`** | <code>number</code> |
|
|
240
|
+
| **`modifiers`** | <code><a href="#array">Array</a><{ modifier?: string; name: string; qty?: number; quantity?: number; price?: number; }></code> |
|
|
208
241
|
|
|
209
242
|
|
|
210
243
|
#### Array
|
|
@@ -258,16 +291,58 @@ getPrinterStatus(options: { identifier: string; }) => Promise<{ status: string;
|
|
|
258
291
|
| **slice** | (start?: number \| undefined, end?: number \| undefined) => T[] |
|
|
259
292
|
|
|
260
293
|
|
|
261
|
-
####
|
|
294
|
+
#### FooterConfig
|
|
262
295
|
|
|
263
|
-
| Prop
|
|
264
|
-
|
|
|
265
|
-
| **`
|
|
266
|
-
| **`
|
|
267
|
-
| **`
|
|
268
|
-
| **`
|
|
269
|
-
| **`
|
|
270
|
-
|
|
296
|
+
| Prop | Type |
|
|
297
|
+
| ----------------- | --------------------------------------- |
|
|
298
|
+
| **`message`** | <code>string</code> |
|
|
299
|
+
| **`date_format`** | <code>string</code> |
|
|
300
|
+
| **`time_format`** | <code>string</code> |
|
|
301
|
+
| **`size`** | <code><a href="#tsize">TSize</a></code> |
|
|
302
|
+
| **`bold`** | <code>boolean</code> |
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
#### ItemConfig
|
|
306
|
+
|
|
307
|
+
| Prop | Type |
|
|
308
|
+
| ---------- | --------------------------------------- |
|
|
309
|
+
| **`size`** | <code><a href="#tsize">TSize</a></code> |
|
|
310
|
+
| **`bold`** | <code>boolean</code> |
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
#### TotalConfig
|
|
314
|
+
|
|
315
|
+
| Prop | Type |
|
|
316
|
+
| ---------- | --------------------------------------- |
|
|
317
|
+
| **`size`** | <code><a href="#tsize">TSize</a></code> |
|
|
318
|
+
| **`bold`** | <code>boolean</code> |
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
#### ModifierConfig
|
|
322
|
+
|
|
323
|
+
| Prop | Type |
|
|
324
|
+
| ------------ | ----------------------------------------------------------- |
|
|
325
|
+
| **`style`** | <code><a href="#tmodifierstyle">TModifierStyle</a></code> |
|
|
326
|
+
| **`indent`** | <code><a href="#tmodifierindent">TModifierIndent</a></code> |
|
|
327
|
+
| **`size`** | <code><a href="#tsize">TSize</a></code> |
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
### Type Aliases
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
#### TSize
|
|
334
|
+
|
|
335
|
+
<code>'1' | '2' | '3' | '4' | 'normal' | 'large' | 'xlarge'</code>
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
#### TModifierStyle
|
|
339
|
+
|
|
340
|
+
<code>'standard' | 'minimal' | 'bullet' | 'arrow' | 'detailed'</code>
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
#### TModifierIndent
|
|
344
|
+
|
|
345
|
+
<code>'small' | 'medium' | 'large'</code>
|
|
271
346
|
|
|
272
347
|
</docgen-api>
|
|
273
348
|
# seven365-zyprinter-sdk
|
package/dist/docs.json
CHANGED
|
@@ -230,26 +230,28 @@
|
|
|
230
230
|
"name": "header",
|
|
231
231
|
"tags": [],
|
|
232
232
|
"docs": "",
|
|
233
|
-
"complexTypes": [
|
|
234
|
-
|
|
233
|
+
"complexTypes": [
|
|
234
|
+
"HeaderConfig"
|
|
235
|
+
],
|
|
236
|
+
"type": "HeaderConfig"
|
|
235
237
|
},
|
|
236
238
|
{
|
|
237
|
-
"name": "
|
|
239
|
+
"name": "kitchen",
|
|
238
240
|
"tags": [],
|
|
239
241
|
"docs": "",
|
|
240
242
|
"complexTypes": [
|
|
241
|
-
"
|
|
243
|
+
"KitchenItem"
|
|
242
244
|
],
|
|
243
|
-
"type": "
|
|
245
|
+
"type": "KitchenItem[] | undefined"
|
|
244
246
|
},
|
|
245
247
|
{
|
|
246
|
-
"name": "
|
|
248
|
+
"name": "items",
|
|
247
249
|
"tags": [],
|
|
248
250
|
"docs": "",
|
|
249
251
|
"complexTypes": [
|
|
250
252
|
"Array"
|
|
251
253
|
],
|
|
252
|
-
"type": "Array<
|
|
254
|
+
"type": "Array<{ name: string; price: string }>"
|
|
253
255
|
},
|
|
254
256
|
{
|
|
255
257
|
"name": "total",
|
|
@@ -258,21 +260,189 @@
|
|
|
258
260
|
"complexTypes": [],
|
|
259
261
|
"type": "string | undefined"
|
|
260
262
|
},
|
|
263
|
+
{
|
|
264
|
+
"name": "order_type",
|
|
265
|
+
"tags": [],
|
|
266
|
+
"docs": "",
|
|
267
|
+
"complexTypes": [],
|
|
268
|
+
"type": "string | undefined"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
"name": "table_name",
|
|
272
|
+
"tags": [],
|
|
273
|
+
"docs": "",
|
|
274
|
+
"complexTypes": [],
|
|
275
|
+
"type": "string | undefined"
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"name": "order_number",
|
|
279
|
+
"tags": [],
|
|
280
|
+
"docs": "",
|
|
281
|
+
"complexTypes": [],
|
|
282
|
+
"type": "string | undefined"
|
|
283
|
+
},
|
|
261
284
|
{
|
|
262
285
|
"name": "footer",
|
|
263
286
|
"tags": [],
|
|
264
287
|
"docs": "",
|
|
288
|
+
"complexTypes": [
|
|
289
|
+
"FooterConfig"
|
|
290
|
+
],
|
|
291
|
+
"type": "FooterConfig"
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
"name": "item",
|
|
295
|
+
"tags": [],
|
|
296
|
+
"docs": "",
|
|
297
|
+
"complexTypes": [
|
|
298
|
+
"ItemConfig"
|
|
299
|
+
],
|
|
300
|
+
"type": "ItemConfig"
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
"name": "total_config",
|
|
304
|
+
"tags": [],
|
|
305
|
+
"docs": "",
|
|
306
|
+
"complexTypes": [
|
|
307
|
+
"TotalConfig"
|
|
308
|
+
],
|
|
309
|
+
"type": "TotalConfig"
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
"name": "modifier",
|
|
313
|
+
"tags": [],
|
|
314
|
+
"docs": "",
|
|
315
|
+
"complexTypes": [
|
|
316
|
+
"ModifierConfig"
|
|
317
|
+
],
|
|
318
|
+
"type": "ModifierConfig"
|
|
319
|
+
}
|
|
320
|
+
]
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
"name": "HeaderConfig",
|
|
324
|
+
"slug": "headerconfig",
|
|
325
|
+
"docs": "",
|
|
326
|
+
"tags": [],
|
|
327
|
+
"methods": [],
|
|
328
|
+
"properties": [
|
|
329
|
+
{
|
|
330
|
+
"name": "restaurant_name",
|
|
331
|
+
"tags": [],
|
|
332
|
+
"docs": "",
|
|
333
|
+
"complexTypes": [],
|
|
334
|
+
"type": "string | undefined"
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
"name": "sub_header",
|
|
338
|
+
"tags": [],
|
|
339
|
+
"docs": "",
|
|
340
|
+
"complexTypes": [],
|
|
341
|
+
"type": "string | undefined"
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
"name": "prefix",
|
|
345
|
+
"tags": [],
|
|
346
|
+
"docs": "",
|
|
347
|
+
"complexTypes": [],
|
|
348
|
+
"type": "string | undefined"
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
"name": "gst_number",
|
|
352
|
+
"tags": [],
|
|
353
|
+
"docs": "",
|
|
354
|
+
"complexTypes": [],
|
|
355
|
+
"type": "string | undefined"
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
"name": "address",
|
|
359
|
+
"tags": [],
|
|
360
|
+
"docs": "",
|
|
361
|
+
"complexTypes": [],
|
|
362
|
+
"type": "string | undefined"
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"name": "phone_number",
|
|
366
|
+
"tags": [],
|
|
367
|
+
"docs": "",
|
|
265
368
|
"complexTypes": [],
|
|
266
369
|
"type": "string | undefined"
|
|
267
370
|
},
|
|
268
371
|
{
|
|
269
|
-
"name": "
|
|
372
|
+
"name": "size",
|
|
270
373
|
"tags": [],
|
|
271
374
|
"docs": "",
|
|
272
375
|
"complexTypes": [
|
|
273
|
-
"
|
|
376
|
+
"TSize"
|
|
274
377
|
],
|
|
275
|
-
"type": "
|
|
378
|
+
"type": "TSize"
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
"name": "bold",
|
|
382
|
+
"tags": [],
|
|
383
|
+
"docs": "",
|
|
384
|
+
"complexTypes": [],
|
|
385
|
+
"type": "boolean | undefined"
|
|
386
|
+
}
|
|
387
|
+
]
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
"name": "KitchenItem",
|
|
391
|
+
"slug": "kitchenitem",
|
|
392
|
+
"docs": "",
|
|
393
|
+
"tags": [],
|
|
394
|
+
"methods": [],
|
|
395
|
+
"properties": [
|
|
396
|
+
{
|
|
397
|
+
"name": "qty",
|
|
398
|
+
"tags": [],
|
|
399
|
+
"docs": "",
|
|
400
|
+
"complexTypes": [],
|
|
401
|
+
"type": "number | undefined"
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
"name": "name",
|
|
405
|
+
"tags": [],
|
|
406
|
+
"docs": "",
|
|
407
|
+
"complexTypes": [],
|
|
408
|
+
"type": "string | undefined"
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
"name": "menu",
|
|
412
|
+
"tags": [],
|
|
413
|
+
"docs": "",
|
|
414
|
+
"complexTypes": [],
|
|
415
|
+
"type": "{ _id?: string | undefined; name: string; price?: string | undefined; categoryName?: string | undefined; printer?: string | undefined; } | undefined"
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
"name": "quantity",
|
|
419
|
+
"tags": [],
|
|
420
|
+
"docs": "",
|
|
421
|
+
"complexTypes": [],
|
|
422
|
+
"type": "number | undefined"
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
"name": "price",
|
|
426
|
+
"tags": [],
|
|
427
|
+
"docs": "",
|
|
428
|
+
"complexTypes": [],
|
|
429
|
+
"type": "number | undefined"
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
"name": "total_price",
|
|
433
|
+
"tags": [],
|
|
434
|
+
"docs": "",
|
|
435
|
+
"complexTypes": [],
|
|
436
|
+
"type": "number | undefined"
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
"name": "modifiers",
|
|
440
|
+
"tags": [],
|
|
441
|
+
"docs": "",
|
|
442
|
+
"complexTypes": [
|
|
443
|
+
"Array"
|
|
444
|
+
],
|
|
445
|
+
"type": "Array<{ \n modifier?: string;\n name: string; \n qty?: number;\n quantity?: number;\n price?: number;\n }>"
|
|
276
446
|
}
|
|
277
447
|
]
|
|
278
448
|
},
|
|
@@ -1114,58 +1284,221 @@
|
|
|
1114
1284
|
]
|
|
1115
1285
|
},
|
|
1116
1286
|
{
|
|
1117
|
-
"name": "
|
|
1118
|
-
"slug": "
|
|
1287
|
+
"name": "FooterConfig",
|
|
1288
|
+
"slug": "footerconfig",
|
|
1119
1289
|
"docs": "",
|
|
1120
1290
|
"tags": [],
|
|
1121
1291
|
"methods": [],
|
|
1122
1292
|
"properties": [
|
|
1123
1293
|
{
|
|
1124
|
-
"name": "
|
|
1294
|
+
"name": "message",
|
|
1125
1295
|
"tags": [],
|
|
1126
1296
|
"docs": "",
|
|
1127
1297
|
"complexTypes": [],
|
|
1128
|
-
"type": "
|
|
1298
|
+
"type": "string | undefined"
|
|
1129
1299
|
},
|
|
1130
1300
|
{
|
|
1131
|
-
"name": "
|
|
1301
|
+
"name": "date_format",
|
|
1132
1302
|
"tags": [],
|
|
1133
1303
|
"docs": "",
|
|
1134
1304
|
"complexTypes": [],
|
|
1135
|
-
"type": "
|
|
1305
|
+
"type": "string | undefined"
|
|
1136
1306
|
},
|
|
1137
1307
|
{
|
|
1138
|
-
"name": "
|
|
1308
|
+
"name": "time_format",
|
|
1139
1309
|
"tags": [],
|
|
1140
1310
|
"docs": "",
|
|
1141
1311
|
"complexTypes": [],
|
|
1142
|
-
"type": "
|
|
1312
|
+
"type": "string | undefined"
|
|
1313
|
+
},
|
|
1314
|
+
{
|
|
1315
|
+
"name": "size",
|
|
1316
|
+
"tags": [],
|
|
1317
|
+
"docs": "",
|
|
1318
|
+
"complexTypes": [
|
|
1319
|
+
"TSize"
|
|
1320
|
+
],
|
|
1321
|
+
"type": "TSize"
|
|
1143
1322
|
},
|
|
1144
1323
|
{
|
|
1145
|
-
"name": "
|
|
1324
|
+
"name": "bold",
|
|
1146
1325
|
"tags": [],
|
|
1147
1326
|
"docs": "",
|
|
1148
1327
|
"complexTypes": [],
|
|
1149
|
-
"type": "
|
|
1328
|
+
"type": "boolean | undefined"
|
|
1329
|
+
}
|
|
1330
|
+
]
|
|
1331
|
+
},
|
|
1332
|
+
{
|
|
1333
|
+
"name": "ItemConfig",
|
|
1334
|
+
"slug": "itemconfig",
|
|
1335
|
+
"docs": "",
|
|
1336
|
+
"tags": [],
|
|
1337
|
+
"methods": [],
|
|
1338
|
+
"properties": [
|
|
1339
|
+
{
|
|
1340
|
+
"name": "size",
|
|
1341
|
+
"tags": [],
|
|
1342
|
+
"docs": "",
|
|
1343
|
+
"complexTypes": [
|
|
1344
|
+
"TSize"
|
|
1345
|
+
],
|
|
1346
|
+
"type": "TSize"
|
|
1150
1347
|
},
|
|
1151
1348
|
{
|
|
1152
|
-
"name": "
|
|
1349
|
+
"name": "bold",
|
|
1153
1350
|
"tags": [],
|
|
1154
1351
|
"docs": "",
|
|
1155
1352
|
"complexTypes": [],
|
|
1156
1353
|
"type": "boolean | undefined"
|
|
1354
|
+
}
|
|
1355
|
+
]
|
|
1356
|
+
},
|
|
1357
|
+
{
|
|
1358
|
+
"name": "TotalConfig",
|
|
1359
|
+
"slug": "totalconfig",
|
|
1360
|
+
"docs": "",
|
|
1361
|
+
"tags": [],
|
|
1362
|
+
"methods": [],
|
|
1363
|
+
"properties": [
|
|
1364
|
+
{
|
|
1365
|
+
"name": "size",
|
|
1366
|
+
"tags": [],
|
|
1367
|
+
"docs": "",
|
|
1368
|
+
"complexTypes": [
|
|
1369
|
+
"TSize"
|
|
1370
|
+
],
|
|
1371
|
+
"type": "TSize"
|
|
1157
1372
|
},
|
|
1158
1373
|
{
|
|
1159
|
-
"name": "
|
|
1374
|
+
"name": "bold",
|
|
1160
1375
|
"tags": [],
|
|
1161
1376
|
"docs": "",
|
|
1162
1377
|
"complexTypes": [],
|
|
1163
|
-
"type": "
|
|
1378
|
+
"type": "boolean | undefined"
|
|
1379
|
+
}
|
|
1380
|
+
]
|
|
1381
|
+
},
|
|
1382
|
+
{
|
|
1383
|
+
"name": "ModifierConfig",
|
|
1384
|
+
"slug": "modifierconfig",
|
|
1385
|
+
"docs": "",
|
|
1386
|
+
"tags": [],
|
|
1387
|
+
"methods": [],
|
|
1388
|
+
"properties": [
|
|
1389
|
+
{
|
|
1390
|
+
"name": "style",
|
|
1391
|
+
"tags": [],
|
|
1392
|
+
"docs": "",
|
|
1393
|
+
"complexTypes": [
|
|
1394
|
+
"TModifierStyle"
|
|
1395
|
+
],
|
|
1396
|
+
"type": "TModifierStyle"
|
|
1397
|
+
},
|
|
1398
|
+
{
|
|
1399
|
+
"name": "indent",
|
|
1400
|
+
"tags": [],
|
|
1401
|
+
"docs": "",
|
|
1402
|
+
"complexTypes": [
|
|
1403
|
+
"TModifierIndent"
|
|
1404
|
+
],
|
|
1405
|
+
"type": "TModifierIndent"
|
|
1406
|
+
},
|
|
1407
|
+
{
|
|
1408
|
+
"name": "size",
|
|
1409
|
+
"tags": [],
|
|
1410
|
+
"docs": "",
|
|
1411
|
+
"complexTypes": [
|
|
1412
|
+
"TSize"
|
|
1413
|
+
],
|
|
1414
|
+
"type": "TSize"
|
|
1164
1415
|
}
|
|
1165
1416
|
]
|
|
1166
1417
|
}
|
|
1167
1418
|
],
|
|
1168
1419
|
"enums": [],
|
|
1169
|
-
"typeAliases": [
|
|
1420
|
+
"typeAliases": [
|
|
1421
|
+
{
|
|
1422
|
+
"name": "TSize",
|
|
1423
|
+
"slug": "tsize",
|
|
1424
|
+
"docs": "",
|
|
1425
|
+
"types": [
|
|
1426
|
+
{
|
|
1427
|
+
"text": "'1'",
|
|
1428
|
+
"complexTypes": []
|
|
1429
|
+
},
|
|
1430
|
+
{
|
|
1431
|
+
"text": "'2'",
|
|
1432
|
+
"complexTypes": []
|
|
1433
|
+
},
|
|
1434
|
+
{
|
|
1435
|
+
"text": "'3'",
|
|
1436
|
+
"complexTypes": []
|
|
1437
|
+
},
|
|
1438
|
+
{
|
|
1439
|
+
"text": "'4'",
|
|
1440
|
+
"complexTypes": []
|
|
1441
|
+
},
|
|
1442
|
+
{
|
|
1443
|
+
"text": "'normal'",
|
|
1444
|
+
"complexTypes": []
|
|
1445
|
+
},
|
|
1446
|
+
{
|
|
1447
|
+
"text": "'large'",
|
|
1448
|
+
"complexTypes": []
|
|
1449
|
+
},
|
|
1450
|
+
{
|
|
1451
|
+
"text": "'xlarge'",
|
|
1452
|
+
"complexTypes": []
|
|
1453
|
+
}
|
|
1454
|
+
]
|
|
1455
|
+
},
|
|
1456
|
+
{
|
|
1457
|
+
"name": "TModifierStyle",
|
|
1458
|
+
"slug": "tmodifierstyle",
|
|
1459
|
+
"docs": "",
|
|
1460
|
+
"types": [
|
|
1461
|
+
{
|
|
1462
|
+
"text": "'standard'",
|
|
1463
|
+
"complexTypes": []
|
|
1464
|
+
},
|
|
1465
|
+
{
|
|
1466
|
+
"text": "'minimal'",
|
|
1467
|
+
"complexTypes": []
|
|
1468
|
+
},
|
|
1469
|
+
{
|
|
1470
|
+
"text": "'bullet'",
|
|
1471
|
+
"complexTypes": []
|
|
1472
|
+
},
|
|
1473
|
+
{
|
|
1474
|
+
"text": "'arrow'",
|
|
1475
|
+
"complexTypes": []
|
|
1476
|
+
},
|
|
1477
|
+
{
|
|
1478
|
+
"text": "'detailed'",
|
|
1479
|
+
"complexTypes": []
|
|
1480
|
+
}
|
|
1481
|
+
]
|
|
1482
|
+
},
|
|
1483
|
+
{
|
|
1484
|
+
"name": "TModifierIndent",
|
|
1485
|
+
"slug": "tmodifierindent",
|
|
1486
|
+
"docs": "",
|
|
1487
|
+
"types": [
|
|
1488
|
+
{
|
|
1489
|
+
"text": "'small'",
|
|
1490
|
+
"complexTypes": []
|
|
1491
|
+
},
|
|
1492
|
+
{
|
|
1493
|
+
"text": "'medium'",
|
|
1494
|
+
"complexTypes": []
|
|
1495
|
+
},
|
|
1496
|
+
{
|
|
1497
|
+
"text": "'large'",
|
|
1498
|
+
"complexTypes": []
|
|
1499
|
+
}
|
|
1500
|
+
]
|
|
1501
|
+
}
|
|
1502
|
+
],
|
|
1170
1503
|
"pluginConfigs": []
|
|
1171
1504
|
}
|
|
@@ -7,24 +7,75 @@ export interface ZyPrinter {
|
|
|
7
7
|
port?: number;
|
|
8
8
|
rssi?: number;
|
|
9
9
|
}
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
export declare type TSize = '1' | '2' | '3' | '4' | 'normal' | 'large' | 'xlarge';
|
|
11
|
+
export declare type TModifierStyle = 'standard' | 'minimal' | 'bullet' | 'arrow' | 'detailed';
|
|
12
|
+
export declare type TModifierIndent = 'small' | 'medium' | 'large';
|
|
13
|
+
export interface HeaderConfig {
|
|
14
|
+
restaurant_name?: string;
|
|
15
|
+
sub_header?: string;
|
|
16
|
+
prefix?: string;
|
|
17
|
+
gst_number?: string;
|
|
18
|
+
address?: string;
|
|
19
|
+
phone_number?: string;
|
|
20
|
+
size?: TSize;
|
|
21
|
+
bold?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface ItemConfig {
|
|
24
|
+
size?: TSize;
|
|
25
|
+
bold?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface ModifierConfig {
|
|
28
|
+
style?: TModifierStyle;
|
|
29
|
+
indent?: TModifierIndent;
|
|
30
|
+
size?: TSize;
|
|
31
|
+
}
|
|
32
|
+
export interface TotalConfig {
|
|
33
|
+
size?: TSize;
|
|
34
|
+
bold?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface FooterConfig {
|
|
37
|
+
message?: string;
|
|
38
|
+
date_format?: string;
|
|
39
|
+
time_format?: string;
|
|
40
|
+
size?: TSize;
|
|
41
|
+
bold?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface KitchenItem {
|
|
44
|
+
qty?: number;
|
|
45
|
+
name?: string;
|
|
46
|
+
menu?: {
|
|
47
|
+
_id?: string;
|
|
48
|
+
name: string;
|
|
49
|
+
price?: string;
|
|
50
|
+
categoryName?: string;
|
|
51
|
+
printer?: string;
|
|
52
|
+
};
|
|
53
|
+
quantity?: number;
|
|
54
|
+
price?: number;
|
|
55
|
+
total_price?: number;
|
|
56
|
+
modifiers?: Array<{
|
|
57
|
+
modifier?: string;
|
|
58
|
+
name: string;
|
|
59
|
+
qty?: number;
|
|
60
|
+
quantity?: number;
|
|
61
|
+
price?: number;
|
|
62
|
+
}>;
|
|
17
63
|
}
|
|
18
64
|
export interface ReceiptTemplate {
|
|
19
|
-
header?:
|
|
65
|
+
header?: HeaderConfig;
|
|
66
|
+
kitchen?: KitchenItem[];
|
|
20
67
|
items?: Array<{
|
|
21
68
|
name: string;
|
|
22
69
|
price: string;
|
|
23
70
|
}>;
|
|
24
|
-
kitchen?: Array<any>;
|
|
25
71
|
total?: string;
|
|
26
|
-
|
|
27
|
-
|
|
72
|
+
order_type?: string;
|
|
73
|
+
table_name?: string;
|
|
74
|
+
order_number?: string;
|
|
75
|
+
footer?: FooterConfig;
|
|
76
|
+
item?: ItemConfig;
|
|
77
|
+
total_config?: TotalConfig;
|
|
78
|
+
modifier?: ModifierConfig;
|
|
28
79
|
}
|
|
29
80
|
export interface ZyprintPlugin {
|
|
30
81
|
echo(options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["// Enhanced printer interface with connection type details\nexport interface ZyPrinter {\n identifier: string;\n model: string;\n status: string;\n connectionType: 'bluetooth' | 'wifi' | 'usb';\n ipAddress?: string;\n port?: number;\n rssi?: number;\n}\n\nexport
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["// Enhanced printer interface with connection type details\nexport interface ZyPrinter {\n identifier: string;\n model: string;\n status: string;\n connectionType: 'bluetooth' | 'wifi' | 'usb';\n ipAddress?: string;\n port?: number;\n rssi?: number;\n}\n\nexport type TSize = '1' | '2' | '3' | '4' | 'normal' | 'large' | 'xlarge';\nexport type TModifierStyle = 'standard' | 'minimal' | 'bullet' | 'arrow' | 'detailed';\nexport type TModifierIndent = 'small' | 'medium' | 'large';\n\nexport interface HeaderConfig {\n restaurant_name?: string;\n sub_header?: string;\n prefix?: string;\n gst_number?: string;\n address?: string;\n phone_number?: string;\n size?: TSize;\n bold?: boolean;\n}\n\nexport interface ItemConfig {\n size?: TSize;\n bold?: boolean;\n}\n\nexport interface ModifierConfig {\n style?: TModifierStyle;\n indent?: TModifierIndent;\n size?: TSize;\n}\n\nexport interface TotalConfig {\n size?: TSize;\n bold?: boolean;\n}\n\nexport interface FooterConfig {\n message?: string;\n date_format?: string;\n time_format?: string;\n size?: TSize;\n bold?: boolean;\n}\n\nexport interface KitchenItem {\n // Simple format (edit.vue)\n qty?: number;\n name?: string;\n \n // Complex format (zyprint-test.vue - from API/backend)\n menu?: {\n _id?: string;\n name: string;\n price?: string;\n categoryName?: string;\n printer?: string;\n };\n quantity?: number;\n price?: number;\n total_price?: number;\n \n // Shared properties\n modifiers?: Array<{ \n modifier?: string;\n name: string; \n qty?: number;\n quantity?: number;\n price?: number;\n }>;\n}\n\nexport interface ReceiptTemplate {\n header?: HeaderConfig;\n kitchen?: KitchenItem[];\n items?: Array<{ name: string; price: string }>; // Legacy support\n total?: string;\n order_type?: string;\n table_name?: string;\n order_number?: string;\n footer?: FooterConfig;\n item?: ItemConfig;\n total_config?: TotalConfig;\n modifier?: ModifierConfig;\n}\n\nexport interface ZyprintPlugin {\n echo(options: { value: string }): Promise<{ value: string }>;\n \n // Enhanced Printer Discovery Methods\n discoverPrinters(): Promise<{ printers: ZyPrinter[] }>;\n discoverBluetoothPrinters(): Promise<{ printers: ZyPrinter[] }>;\n discoverWiFiPrinters(options?: { networkRange?: string }): Promise<{ printers: ZyPrinter[] }>;\n discoverUSBPrinters(): Promise<{ printers: ZyPrinter[] }>;\n \n // Connection Management\n connectToPrinter(options: { identifier: string }): Promise<{ connected: boolean }>;\n disconnectFromPrinter(options: { identifier: string }): Promise<{ disconnected: boolean }>;\n \n // Printing Methods\n printText(options: { text: string; identifier: string }): Promise<{ success: boolean }>;\n printReceipt(options: { template: ReceiptTemplate; identifier: string }): Promise<{ success: boolean }>;\n \n // Printer Status\n getPrinterStatus(options: { identifier: string }): Promise<{ status: string; paperStatus: string; connected: boolean }>;\n}\n"]}
|
|
@@ -93,10 +93,10 @@ import ExternalAccessory
|
|
|
93
93
|
for accessory in connectedAccessories {
|
|
94
94
|
// Check if the accessory might be a printer
|
|
95
95
|
// Common printer protocol strings include manufacturer-specific identifiers
|
|
96
|
-
let isPotentialPrinter = accessory.protocolStrings.contains {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
let isPotentialPrinter = accessory.protocolStrings.contains { protocolString in
|
|
97
|
+
protocolString.lowercased().contains("printer") ||
|
|
98
|
+
protocolString.lowercased().contains("print") ||
|
|
99
|
+
protocolString.lowercased().contains("pos")
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
if isPotentialPrinter || !accessory.protocolStrings.isEmpty {
|
|
@@ -369,30 +369,267 @@ import ExternalAccessory
|
|
|
369
369
|
// Center align (ESC a 1)
|
|
370
370
|
printData.append(Data([0x1B, 0x61, 0x01]))
|
|
371
371
|
|
|
372
|
-
//
|
|
373
|
-
if let header =
|
|
374
|
-
|
|
372
|
+
// ========== HEADER SECTION (NEW STRUCTURE) ==========
|
|
373
|
+
if let header = template["header"] as? [String: Any] {
|
|
374
|
+
// Get header formatting
|
|
375
|
+
var sizeCode: UInt8 = 0x00
|
|
376
|
+
var headerBold = false
|
|
375
377
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
378
|
+
if let size = header["size"] {
|
|
379
|
+
sizeCode = mapHeaderSizeToCode(size)
|
|
380
|
+
}
|
|
381
|
+
if let bold = header["bold"] as? Bool {
|
|
382
|
+
headerBold = bold
|
|
381
383
|
}
|
|
382
|
-
print("ZywellSDK: Header size code: \(sizeCode)")
|
|
383
384
|
|
|
384
|
-
//
|
|
385
|
-
|
|
385
|
+
// Apply bold if needed
|
|
386
|
+
if headerBold {
|
|
387
|
+
printData.append(Data([0x1B, 0x45, 0x01])) // Bold on
|
|
388
|
+
}
|
|
386
389
|
|
|
387
|
-
|
|
390
|
+
// Set font size
|
|
391
|
+
if sizeCode != 0x00 {
|
|
392
|
+
printData.append(Data([0x1D, 0x21, sizeCode]))
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// Restaurant name
|
|
396
|
+
if let restaurantName = getString(header["restaurant_name"]),
|
|
397
|
+
let nameData = (restaurantName + "\n").data(using: .utf8) {
|
|
398
|
+
printData.append(nameData)
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// Sub header
|
|
402
|
+
if let subHeader = getString(header["sub_header"]),
|
|
403
|
+
!subHeader.isEmpty,
|
|
404
|
+
let subData = (subHeader + "\n").data(using: .utf8) {
|
|
405
|
+
printData.append(subData)
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// GST number
|
|
409
|
+
if let gstNumber = getString(header["gst_number"]),
|
|
410
|
+
!gstNumber.isEmpty,
|
|
411
|
+
let gstData = ("GST number: \(gstNumber)\n").data(using: .utf8) {
|
|
412
|
+
printData.append(gstData)
|
|
413
|
+
}
|
|
388
414
|
|
|
389
|
-
// Reset
|
|
390
|
-
|
|
415
|
+
// Reset header formatting
|
|
416
|
+
if sizeCode != 0x00 {
|
|
417
|
+
printData.append(Data([0x1D, 0x21, 0x00])) // Normal size
|
|
418
|
+
}
|
|
419
|
+
if headerBold {
|
|
420
|
+
printData.append(Data([0x1B, 0x45, 0x00])) // Bold off
|
|
421
|
+
}
|
|
391
422
|
}
|
|
392
423
|
|
|
393
424
|
// Left align (ESC a 0)
|
|
394
425
|
printData.append(Data([0x1B, 0x61, 0x00]))
|
|
395
426
|
|
|
427
|
+
// Separator
|
|
428
|
+
if let separatorData = ("--------------------------------\n").data(using: .utf8) {
|
|
429
|
+
printData.append(separatorData)
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// ========== ORDER INFO SECTION ==========
|
|
433
|
+
// Template type (e.g., "Kitchen Tickets")
|
|
434
|
+
if let orderType = getString(template["order_type"]),
|
|
435
|
+
let orderTypeData = (orderType + "\n").data(using: .utf8) {
|
|
436
|
+
printData.append(orderTypeData)
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// Table and order number with prefix
|
|
440
|
+
var orderInfoLine = ""
|
|
441
|
+
if let tableName = getString(template["table_name"]) {
|
|
442
|
+
orderInfoLine += tableName
|
|
443
|
+
}
|
|
444
|
+
if let orderNumber = getString(template["order_number"]) {
|
|
445
|
+
if !orderInfoLine.isEmpty {
|
|
446
|
+
orderInfoLine += " | "
|
|
447
|
+
}
|
|
448
|
+
orderInfoLine += orderNumber
|
|
449
|
+
}
|
|
450
|
+
if !orderInfoLine.isEmpty,
|
|
451
|
+
let orderInfoData = (orderInfoLine + "\n").data(using: .utf8) {
|
|
452
|
+
printData.append(orderInfoData)
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
// Separator for items section
|
|
457
|
+
if let separatorData = ("--------------------------------\n").data(using: .utf8) {
|
|
458
|
+
printData.append(separatorData)
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// ========== ITEMS SECTION (NEW STRUCTURE) ==========
|
|
462
|
+
if let kitchen = template["kitchen"] as? [[String: Any]] {
|
|
463
|
+
// Get item formatting from item object
|
|
464
|
+
var itemSizeCode: UInt8 = 0x00
|
|
465
|
+
var itemBold = false
|
|
466
|
+
|
|
467
|
+
if let item = template["item"] as? [String: Any] {
|
|
468
|
+
if let size = item["size"] {
|
|
469
|
+
itemSizeCode = mapHeaderSizeToCode(size)
|
|
470
|
+
}
|
|
471
|
+
if let bold = item["bold"] as? Bool {
|
|
472
|
+
itemBold = bold
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// Apply item formatting
|
|
477
|
+
if itemBold {
|
|
478
|
+
printData.append(Data([0x1B, 0x45, 0x01])) // Bold on
|
|
479
|
+
}
|
|
480
|
+
if itemSizeCode != 0x00 {
|
|
481
|
+
printData.append(Data([0x1D, 0x21, itemSizeCode])) // Set size
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// Get modifier formatting from modifier object
|
|
485
|
+
var modifierStyle = "bullet" // default
|
|
486
|
+
var modifierSizeCode: UInt8 = 0x00
|
|
487
|
+
var modifierIndent = " " // default: medium
|
|
488
|
+
|
|
489
|
+
if let modifier = template["modifier"] as? [String: Any] {
|
|
490
|
+
if let style = getString(modifier["style"]) {
|
|
491
|
+
modifierStyle = style
|
|
492
|
+
}
|
|
493
|
+
if let size = modifier["size"] {
|
|
494
|
+
modifierSizeCode = mapHeaderSizeToCode(size)
|
|
495
|
+
}
|
|
496
|
+
if let indent = getString(modifier["indent"]) {
|
|
497
|
+
switch indent.lowercased() {
|
|
498
|
+
case "small": modifierIndent = " "
|
|
499
|
+
case "medium": modifierIndent = " "
|
|
500
|
+
case "large": modifierIndent = " "
|
|
501
|
+
default: modifierIndent = " "
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
for item in kitchen {
|
|
507
|
+
var itemName = ""
|
|
508
|
+
var quantity = "1"
|
|
509
|
+
|
|
510
|
+
// Get item name
|
|
511
|
+
if let name = getString(item["name"]) {
|
|
512
|
+
itemName = name
|
|
513
|
+
} else if let menu = item["menu"] as? [String: Any],
|
|
514
|
+
let name = getString(menu["name"]) {
|
|
515
|
+
itemName = name
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
// Get quantity
|
|
519
|
+
if let qty = item["qty"] {
|
|
520
|
+
quantity = "x\(getString(qty) ?? "1")"
|
|
521
|
+
} else if let qty = item["quantity"] {
|
|
522
|
+
quantity = "x\(getString(qty) ?? "1")"
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// Print main item line
|
|
526
|
+
let line = String(format: "%@ %@\n", itemName, quantity)
|
|
527
|
+
if let lineData = line.data(using: .utf8) {
|
|
528
|
+
printData.append(lineData)
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// Print modifiers
|
|
532
|
+
if let modifiers = item["modifiers"] as? [[String: Any]] {
|
|
533
|
+
// Apply modifier size if specified
|
|
534
|
+
if modifierSizeCode != 0x00 {
|
|
535
|
+
printData.append(Data([0x1D, 0x21, modifierSizeCode]))
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
for mod in modifiers {
|
|
539
|
+
if let modName = getString(mod["name"]) {
|
|
540
|
+
var prefix = ""
|
|
541
|
+
|
|
542
|
+
// Determine prefix based on style
|
|
543
|
+
switch modifierStyle.lowercased() {
|
|
544
|
+
case "dash":
|
|
545
|
+
prefix = "-"
|
|
546
|
+
case "bullet":
|
|
547
|
+
prefix = "•"
|
|
548
|
+
case "arrow":
|
|
549
|
+
prefix = "→"
|
|
550
|
+
default:
|
|
551
|
+
prefix = "•"
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// Build modifier line
|
|
555
|
+
let modLine = "\(modifierIndent)\(prefix) \(modName)\n"
|
|
556
|
+
|
|
557
|
+
if let modData = modLine.data(using: .utf8) {
|
|
558
|
+
printData.append(modData)
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// Reset modifier size if it was changed
|
|
564
|
+
if modifierSizeCode != 0x00 {
|
|
565
|
+
printData.append(Data([0x1D, 0x21, 0x00]))
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
// Reset item formatting
|
|
571
|
+
if itemSizeCode != 0x00 {
|
|
572
|
+
printData.append(Data([0x1D, 0x21, 0x00])) // Normal size
|
|
573
|
+
}
|
|
574
|
+
if itemBold {
|
|
575
|
+
printData.append(Data([0x1B, 0x45, 0x00])) // Bold off
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// Table number
|
|
580
|
+
if let tableNumber = getString(template["tableNumber"]),
|
|
581
|
+
let tableData = ("Table:\(tableNumber)\n").data(using: .utf8) {
|
|
582
|
+
printData.append(tableData)
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// Order number and type
|
|
586
|
+
if let orderNumber = getString(template["orderNumber"]) {
|
|
587
|
+
var orderLine = "ORDER NO.: \(orderNumber)\n"
|
|
588
|
+
if let orderType = getString(template["orderType"]) {
|
|
589
|
+
orderLine += "\(orderType)\n"
|
|
590
|
+
}
|
|
591
|
+
if let orderData = orderLine.data(using: .utf8) {
|
|
592
|
+
printData.append(orderData)
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
// Served by
|
|
597
|
+
if let servedBy = getString(template["servedBy"]),
|
|
598
|
+
let servedData = ("Served By:\(servedBy)\n").data(using: .utf8) {
|
|
599
|
+
printData.append(servedData)
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
// Date/Time
|
|
603
|
+
if let dateTime = template["dateTime"] {
|
|
604
|
+
let formatter = DateFormatter()
|
|
605
|
+
formatter.dateFormat = "yyyy-MMM-dd HH:mm:ss"
|
|
606
|
+
|
|
607
|
+
var dateString = ""
|
|
608
|
+
if let date = dateTime as? Date {
|
|
609
|
+
dateString = formatter.string(from: date)
|
|
610
|
+
} else if let dateStr = getString(dateTime) {
|
|
611
|
+
dateString = dateStr
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
if !dateString.isEmpty,
|
|
615
|
+
let dateData = ("Date:\(dateString)\n").data(using: .utf8) {
|
|
616
|
+
printData.append(dateData)
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
// Separator for items section
|
|
621
|
+
if let separatorData = ("--------------------------------\n").data(using: .utf8) {
|
|
622
|
+
printData.append(separatorData)
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
// Items header (ITEM, QTY, AMT)
|
|
626
|
+
if let headerData = ("ITEM\t\t\tQTY\tAMT\n").data(using: .utf8) {
|
|
627
|
+
printData.append(headerData)
|
|
628
|
+
}
|
|
629
|
+
if let separatorData = ("--------------------------------\n").data(using: .utf8) {
|
|
630
|
+
printData.append(separatorData)
|
|
631
|
+
}
|
|
632
|
+
|
|
396
633
|
// Items
|
|
397
634
|
if let kitchen = template["kitchen"] as? [[String: Any]] {
|
|
398
635
|
// Get item formatting
|
|
@@ -416,6 +653,7 @@ import ExternalAccessory
|
|
|
416
653
|
for item in kitchen {
|
|
417
654
|
var itemName = ""
|
|
418
655
|
var itemPrice = ""
|
|
656
|
+
var quantity = "1"
|
|
419
657
|
|
|
420
658
|
// Get name from menu object
|
|
421
659
|
if let menu = item["menu"] as? [String: Any],
|
|
@@ -423,38 +661,103 @@ import ExternalAccessory
|
|
|
423
661
|
itemName = name
|
|
424
662
|
}
|
|
425
663
|
|
|
426
|
-
//
|
|
664
|
+
// Get quantity
|
|
427
665
|
if let qty = item["quantity"] {
|
|
428
|
-
|
|
666
|
+
quantity = "x\(getString(qty) ?? "1")"
|
|
429
667
|
}
|
|
430
668
|
|
|
431
669
|
// Format price
|
|
432
670
|
if let price = item["total_price"] {
|
|
433
671
|
if let priceDouble = Double(getString(price) ?? "0") {
|
|
434
|
-
itemPrice = String(format: "
|
|
672
|
+
itemPrice = String(format: "%.1f", priceDouble)
|
|
435
673
|
} else {
|
|
436
|
-
itemPrice =
|
|
674
|
+
itemPrice = getString(price) ?? "0.00"
|
|
437
675
|
}
|
|
438
676
|
}
|
|
439
677
|
|
|
440
|
-
// Print main item
|
|
441
|
-
let line = String(format: "%@\t%@\n", itemName, itemPrice)
|
|
678
|
+
// Print main item line
|
|
679
|
+
let line = String(format: "%@ %@\t%@\n", itemName, quantity, itemPrice)
|
|
442
680
|
if let lineData = line.data(using: .utf8) {
|
|
443
681
|
printData.append(lineData)
|
|
444
682
|
}
|
|
445
683
|
|
|
446
684
|
// Print modifiers
|
|
447
685
|
if let modifiers = item["modifiers"] as? [[String: Any]] {
|
|
686
|
+
// Get modifier formatting options
|
|
687
|
+
var modifierStyle = "standard" // default
|
|
688
|
+
var modifierSizeCode: UInt8 = 0x00
|
|
689
|
+
var modifierIndent = " " // default: 2 spaces
|
|
690
|
+
|
|
691
|
+
if let formatting = template["formatting"] as? [String: Any] {
|
|
692
|
+
if let style = getString(formatting["modifierStyle"]) {
|
|
693
|
+
modifierStyle = style
|
|
694
|
+
}
|
|
695
|
+
if let size = formatting["modifierSize"] {
|
|
696
|
+
modifierSizeCode = mapHeaderSizeToCode(size)
|
|
697
|
+
}
|
|
698
|
+
if let indent = getString(formatting["modifierIndent"]) {
|
|
699
|
+
switch indent.lowercased() {
|
|
700
|
+
case "small": modifierIndent = " "
|
|
701
|
+
case "medium": modifierIndent = " "
|
|
702
|
+
case "large": modifierIndent = " "
|
|
703
|
+
default: modifierIndent = indent
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
// Apply modifier size if specified
|
|
709
|
+
if modifierSizeCode != 0x00 {
|
|
710
|
+
printData.append(Data([0x1D, 0x21, modifierSizeCode]))
|
|
711
|
+
}
|
|
712
|
+
|
|
448
713
|
for mod in modifiers {
|
|
449
714
|
if let modName = getString(mod["name"]) {
|
|
450
|
-
var modLine = "
|
|
715
|
+
var modLine = ""
|
|
716
|
+
var prefix = ""
|
|
451
717
|
|
|
452
|
-
//
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
718
|
+
// Determine prefix based on style
|
|
719
|
+
switch modifierStyle.lowercased() {
|
|
720
|
+
case "minimal":
|
|
721
|
+
prefix = "-"
|
|
722
|
+
case "bullet":
|
|
723
|
+
prefix = "•"
|
|
724
|
+
case "arrow":
|
|
725
|
+
prefix = "→"
|
|
726
|
+
case "detailed":
|
|
727
|
+
prefix = "+"
|
|
728
|
+
default: // "standard"
|
|
729
|
+
prefix = "+"
|
|
457
730
|
}
|
|
731
|
+
|
|
732
|
+
// Build modifier line based on style
|
|
733
|
+
switch modifierStyle.lowercased() {
|
|
734
|
+
case "minimal":
|
|
735
|
+
modLine = "\(modifierIndent)\(prefix) \(modName)"
|
|
736
|
+
case "bullet":
|
|
737
|
+
modLine = "\(modifierIndent)\(prefix) \(modName)"
|
|
738
|
+
case "arrow":
|
|
739
|
+
modLine = "\(modifierIndent)\(prefix) \(modName)"
|
|
740
|
+
case "detailed":
|
|
741
|
+
// Show quantity if available
|
|
742
|
+
var quantityStr = ""
|
|
743
|
+
if let qty = mod["quantity"],
|
|
744
|
+
let qtyInt = qty as? Int, qtyInt > 1 {
|
|
745
|
+
quantityStr = " (x\(qtyInt))"
|
|
746
|
+
}
|
|
747
|
+
modLine = "\(modifierIndent)\(prefix) \(modName)\(quantityStr)"
|
|
748
|
+
default: // "standard"
|
|
749
|
+
modLine = "\(modifierIndent)\(prefix) \(modName)"
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
// Add price if > 0 (except for minimal style)
|
|
753
|
+
if modifierStyle.lowercased() != "minimal" {
|
|
754
|
+
if let modPrice = mod["price"],
|
|
755
|
+
let priceDouble = Double(getString(modPrice) ?? "0"),
|
|
756
|
+
priceDouble > 0 {
|
|
757
|
+
modLine += String(format: "\t$%.2f", priceDouble)
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
|
|
458
761
|
modLine += "\n"
|
|
459
762
|
|
|
460
763
|
if let modData = modLine.data(using: .utf8) {
|
|
@@ -462,6 +765,11 @@ import ExternalAccessory
|
|
|
462
765
|
}
|
|
463
766
|
}
|
|
464
767
|
}
|
|
768
|
+
|
|
769
|
+
// Reset modifier size if it was changed
|
|
770
|
+
if modifierSizeCode != 0x00 {
|
|
771
|
+
printData.append(Data([0x1D, 0x21, 0x00]))
|
|
772
|
+
}
|
|
465
773
|
}
|
|
466
774
|
}
|
|
467
775
|
|
|
@@ -512,20 +820,51 @@ import ExternalAccessory
|
|
|
512
820
|
}
|
|
513
821
|
}
|
|
514
822
|
|
|
515
|
-
//
|
|
516
|
-
if let
|
|
517
|
-
|
|
518
|
-
|
|
823
|
+
// Separator
|
|
824
|
+
if let separatorData = ("--------------------------------\n").data(using: .utf8) {
|
|
825
|
+
printData.append(separatorData)
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
// Subtotal, Discount, GST
|
|
829
|
+
if let subtotal = getString(template["subtotal"]) {
|
|
830
|
+
if let data = ("SUBTOTAL\t\t\t$\(subtotal)\n").data(using: .utf8) {
|
|
831
|
+
printData.append(data)
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
if let discount = getString(template["discount"]) {
|
|
836
|
+
if let discountDouble = Double(discount), discountDouble > 0 {
|
|
837
|
+
if let data = ("SAFRA Members\t\t\t-$\(discount)\n").data(using: .utf8) {
|
|
838
|
+
printData.append(data)
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
if let gst = getString(template["gst"]) {
|
|
844
|
+
if let data = ("9% (Incl.) GST\t\t\t$\(gst)\n").data(using: .utf8) {
|
|
845
|
+
printData.append(data)
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
// ========== TOTAL SECTION (NEW STRUCTURE) ==========
|
|
850
|
+
if let total = getString(template["total"]) {
|
|
851
|
+
// Separator
|
|
852
|
+
if let separatorData = ("--------------------------------\n").data(using: .utf8) {
|
|
853
|
+
printData.append(separatorData)
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
// Get total formatting from total_config object
|
|
519
857
|
var totalSizeCode: UInt8 = 0x00
|
|
520
858
|
var totalBold = false
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
859
|
+
|
|
860
|
+
if let totalConfig = template["total_config"] as? [String: Any] {
|
|
861
|
+
if let size = totalConfig["size"] {
|
|
862
|
+
totalSizeCode = mapHeaderSizeToCode(size)
|
|
863
|
+
}
|
|
864
|
+
if let bold = totalConfig["bold"] as? Bool {
|
|
865
|
+
totalBold = bold
|
|
524
866
|
}
|
|
525
|
-
totalBold = getBool(formatting["totalBold"])
|
|
526
867
|
}
|
|
527
|
-
print("ZywellSDK: Total size code: \(totalSizeCode)")
|
|
528
|
-
print("ZywellSDK: Total bold: \(totalBold)")
|
|
529
868
|
|
|
530
869
|
// Apply total formatting
|
|
531
870
|
if totalBold {
|
|
@@ -535,7 +874,9 @@ import ExternalAccessory
|
|
|
535
874
|
printData.append(Data([0x1D, 0x21, totalSizeCode])) // Set size
|
|
536
875
|
}
|
|
537
876
|
|
|
538
|
-
|
|
877
|
+
if let totalData = ("TOTAL\t\t\t$\(total)\n").data(using: .utf8) {
|
|
878
|
+
printData.append(totalData)
|
|
879
|
+
}
|
|
539
880
|
|
|
540
881
|
// Reset total formatting
|
|
541
882
|
if totalSizeCode != 0x00 {
|
|
@@ -546,22 +887,53 @@ import ExternalAccessory
|
|
|
546
887
|
}
|
|
547
888
|
}
|
|
548
889
|
|
|
549
|
-
//
|
|
550
|
-
if let
|
|
551
|
-
|
|
890
|
+
// Separator
|
|
891
|
+
if let separatorData = ("--------------------------------\n").data(using: .utf8) {
|
|
892
|
+
printData.append(separatorData)
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
// Payment method
|
|
896
|
+
if let paymentMethod = getString(template["paymentMethod"]),
|
|
897
|
+
let paymentData = ("PAYMENT BY:\(paymentMethod)\t\(getString(template["total"]) ?? "")\n").data(using: .utf8) {
|
|
898
|
+
printData.append(paymentData)
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
// Separator
|
|
902
|
+
if let separatorData = ("--------------------------------\n").data(using: .utf8) {
|
|
903
|
+
printData.append(separatorData)
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
// ========== FOOTER SECTION (NEW STRUCTURE) ==========
|
|
908
|
+
// Center align for footer
|
|
909
|
+
printData.append(Data([0x1B, 0x61, 0x01]))
|
|
910
|
+
|
|
911
|
+
if let footer = template["footer"] as? [String: Any] {
|
|
552
912
|
// Get footer formatting
|
|
553
913
|
var footerSizeCode: UInt8 = 0x00
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
914
|
+
var footerBold = false
|
|
915
|
+
|
|
916
|
+
if let size = footer["size"] {
|
|
917
|
+
footerSizeCode = mapHeaderSizeToCode(size)
|
|
918
|
+
}
|
|
919
|
+
if let bold = footer["bold"] as? Bool {
|
|
920
|
+
footerBold = bold
|
|
557
921
|
}
|
|
558
922
|
|
|
559
923
|
// Apply footer formatting
|
|
924
|
+
if footerBold {
|
|
925
|
+
printData.append(Data([0x1B, 0x45, 0x01])) // Bold on
|
|
926
|
+
}
|
|
560
927
|
if footerSizeCode != 0x00 {
|
|
561
928
|
printData.append(Data([0x1D, 0x21, footerSizeCode])) // Set size
|
|
562
929
|
}
|
|
563
930
|
|
|
564
|
-
|
|
931
|
+
// Footer message
|
|
932
|
+
if let message = getString(footer["message"]),
|
|
933
|
+
!message.isEmpty,
|
|
934
|
+
let messageData = (message + "\n").data(using: .utf8) {
|
|
935
|
+
printData.append(messageData)
|
|
936
|
+
}
|
|
565
937
|
|
|
566
938
|
// Reset footer formatting
|
|
567
939
|
if footerSizeCode != 0x00 {
|
package/package.json
CHANGED