@reservation-studio/electron-types 0.0.29 → 0.0.31

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 CHANGED
@@ -112,13 +112,12 @@ const response = await ReservationStudioElectron.fiscalDevices.printReceipt(
112
112
  name: 'Product 1',
113
113
  unitPrice: 10.0,
114
114
  quantity: 1,
115
- vatGroup: '1',
116
- currency: 'BGN'
115
+ vatGroup: FiscalVATGroup.A
117
116
  }
118
117
  ],
119
118
  payments: [
120
119
  {
121
- type: 'cash',
120
+ type: FiscalPaymentType.CASH,
122
121
  amount: 10.0
123
122
  }
124
123
  ]
@@ -133,20 +132,12 @@ await ReservationStudioElectron.fiscalDevices.printNonFiscalReceipt(
133
132
  number: 1,
134
133
  password: '1'
135
134
  },
136
- uniqueSaleNumber: '1',
137
135
  items: [
138
136
  {
139
137
  name: 'Service',
140
138
  unitPrice: 5.0,
141
139
  quantity: 1,
142
- vatGroup: '1',
143
- currency: 'BGN'
144
- }
145
- ],
146
- payments: [
147
- {
148
- type: 'cash',
149
- amount: 5.0
140
+ vatGroup: FiscalVATGroup.A
150
141
  }
151
142
  ]
152
143
  },
@@ -160,6 +151,76 @@ const lastRecord =
160
151
  // Get the fiscal device status
161
152
  const status =
162
153
  await ReservationStudioElectron.fiscalDevices.getStatus(deviceId);
154
+
155
+ // Print X report (daily report without reset)
156
+ await ReservationStudioElectron.fiscalDevices.printXReport(deviceId);
157
+
158
+ // Print Z report (daily report with reset)
159
+ await ReservationStudioElectron.fiscalDevices.printZReport(deviceId);
160
+
161
+ // Print duplicate of last receipt
162
+ await ReservationStudioElectron.fiscalDevices.printDuplicate(deviceId);
163
+
164
+ // Deposit money to cash register
165
+ await ReservationStudioElectron.fiscalDevices.depositMoney(100, deviceId);
166
+
167
+ // Withdraw money from cash register
168
+ await ReservationStudioElectron.fiscalDevices.withdrawMoney(50, deviceId);
169
+
170
+ // Get current cash amount in register
171
+ const cashAmount =
172
+ await ReservationStudioElectron.fiscalDevices.getCashAmount(deviceId);
173
+
174
+ // Set date and time on fiscal device
175
+ await ReservationStudioElectron.fiscalDevices.setDateTime(new Date(), deviceId);
176
+
177
+ // Get date and time from fiscal device
178
+ const deviceDateTime =
179
+ await ReservationStudioElectron.fiscalDevices.getDateTime(deviceId);
180
+
181
+ // Run diagnostics test
182
+ const diagnosticsResult =
183
+ await ReservationStudioElectron.fiscalDevices.runDiagnostics(deviceId, {
184
+ operator: {
185
+ number: 1,
186
+ password: '0000',
187
+ code: 'OP01' // optional
188
+ },
189
+ amount: 1,
190
+ vatGroup: FiscalVATGroup.A,
191
+ itemName: 'Diagnostic item'
192
+ });
193
+
194
+ // Print reversal receipt
195
+ const reversalResponse =
196
+ await ReservationStudioElectron.fiscalDevices.printReversalReceipt(
197
+ {
198
+ operator: {
199
+ number: 1,
200
+ password: '0000'
201
+ },
202
+ uniqueSaleNumber: '1',
203
+ reason: 'refund', // or 'void', 'tax-base-reduction'
204
+ originalReceiptNumber: '12345',
205
+ originalReceiptDateTime: new Date('2023-01-01T10:00:00'),
206
+ originalFiscalMemorySerialNumber: 'FM12345678',
207
+ items: [
208
+ {
209
+ name: 'Returned Item',
210
+ unitPrice: 10.0,
211
+ quantity: 1,
212
+ vatGroup: FiscalVATGroup.A
213
+ }
214
+ ],
215
+ payments: [
216
+ {
217
+ type: FiscalPaymentType.CASH,
218
+ amount: 10.0
219
+ }
220
+ ]
221
+ },
222
+ deviceId
223
+ );
163
224
  ```
164
225
 
165
226
  ## Interfaces
@@ -199,21 +260,39 @@ interface HttpOptions {
199
260
  }
200
261
  ```
201
262
 
202
- ### FiscalReceipt
263
+ ### OperatorInfo
203
264
 
204
265
  ```typescript
266
+ interface OperatorInfo {
267
+ number: number;
268
+ password: string;
269
+ code?: string;
270
+ }
271
+ ```
272
+
273
+ ### FiscalReceipt
274
+
275
+ ````typescript
205
276
  interface FiscalReceipt {
206
- operator: {
207
- number: number;
208
- password: string;
209
- code?: string;
210
- };
211
- uniqueSaleNumber: string;
277
+ operator: OperatorInfo;
278
+ uniqueSaleNumber: string; // numeric string up to 7 digits
212
279
  items: FiscalReceiptItem[];
213
280
  payments: FiscalPayment[];
214
281
  client?: FiscalClient;
215
282
  }
216
- ```
283
+
284
+ ### NonFiscalReceipt
285
+
286
+ ```typescript
287
+ interface NonFiscalReceipt {
288
+ operator: OperatorInfo;
289
+ items: FiscalReceiptItem[];
290
+ payments?: FiscalPayment[];
291
+ client?: FiscalClient;
292
+ }
293
+ ````
294
+
295
+ ````
217
296
 
218
297
  ### FiscalReceiptItem
219
298
 
@@ -221,12 +300,11 @@ interface FiscalReceipt {
221
300
  interface FiscalReceiptItem {
222
301
  name: string;
223
302
  unitPrice: number;
224
- currency: string;
225
303
  quantity: number;
226
- vatGroup: string;
304
+ vatGroup: FiscalVATGroup;
227
305
  discount?: number;
228
306
  }
229
- ```
307
+ ````
230
308
 
231
309
  ### FiscalPayment
232
310
 
@@ -248,6 +326,21 @@ enum FiscalPaymentType {
248
326
  }
249
327
  ```
250
328
 
329
+ ### FiscalVATGroup
330
+
331
+ ```typescript
332
+ enum FiscalVATGroup {
333
+ A = '1', // 20%
334
+ B = '2', // 9%
335
+ C = '3', // 0%
336
+ D = '4', // Exempt
337
+ E = '5', // Special rate 1
338
+ F = '6', // Special rate 2
339
+ G = '7', // Special rate 3
340
+ H = '8' // Special rate 4
341
+ }
342
+ ```
343
+
251
344
  ### FiscalClient
252
345
 
253
346
  ```typescript
@@ -273,11 +366,55 @@ interface FiscalMemoryRecord {
273
366
 
274
367
  ```typescript
275
368
  interface FiscalDeviceStatus {
276
- connected: boolean;
277
- hasPaper: boolean;
278
- fiscalMemoryFull: boolean;
279
- errorCode?: number;
280
- errorMessage?: string;
369
+ connected?: boolean;
370
+ hasPaper?: boolean;
371
+ fiscalMemoryFull?: boolean;
372
+ fiscalReceiptOpen?: boolean;
373
+ nonFiscalReceiptOpen?: boolean;
374
+ printingAllowed?: boolean;
375
+ messages: FiscalResponseMessage[];
376
+ }
377
+ ```
378
+
379
+ ### FiscalResponseMessage
380
+
381
+ ```typescript
382
+ interface FiscalResponseMessage {
383
+ type: 'info' | 'warning' | 'error';
384
+ code?: string;
385
+ text: string;
386
+ }
387
+ ```
388
+
389
+ ### ReversalReceipt
390
+
391
+ ```typescript
392
+ interface ReversalReceipt extends FiscalReceipt {
393
+ reason: ReversalReason;
394
+ originalReceiptNumber: string;
395
+ originalReceiptDateTime: Date;
396
+ originalFiscalMemorySerialNumber: string;
397
+ }
398
+ ```
399
+
400
+ ### FiscalDeviceDiagnosticsOptions
401
+
402
+ ```typescript
403
+ interface FiscalDeviceDiagnosticsOptions {
404
+ operator: OperatorInfo;
405
+ amount?: number;
406
+ vatGroup?: FiscalVATGroup;
407
+ itemName?: string;
408
+ }
409
+ ```
410
+
411
+ ### ReversalReason
412
+
413
+ ```typescript
414
+ enum ReversalReason {
415
+ VOID = 'void',
416
+ REFUND = 'refund',
417
+ TAX_BASE_REDUCTION = 'tax-base-reduction'
281
418
  }
282
419
  ```
283
420
 
@@ -1,7 +1,7 @@
1
1
  import { CertificateInfo } from './certificate-info.interface';
2
2
  import { HttpOptions, HttpResponse } from './http.interface';
3
3
  import { EnvironmentEnum } from '../enums/envirovment.enum';
4
- import { DeviceInfo, FiscalDeviceDiagnosticsOptions, FiscalDeviceDiagnosticsResult, FiscalDeviceResponse, FiscalDeviceStatus, FiscalMemoryRecord, FiscalReceipt, FiscalResponse, ReversalReceipt } from './fiscal-device.interface';
4
+ import { DeviceInfo, FiscalDeviceDiagnosticsOptions, FiscalDeviceDiagnosticsResult, FiscalDeviceResponse, FiscalDeviceStatus, FiscalMemoryRecord, FiscalReceipt, FiscalResponse, NonFiscalReceipt, ReversalReceipt } from './fiscal-device.interface';
5
5
  export interface ApiInterface {
6
6
  /**
7
7
  * An object representing operations related to certificates.
@@ -116,12 +116,12 @@ export interface ApiInterface {
116
116
  /**
117
117
  * Prints a non-fiscal receipt using a fiscal device.
118
118
  *
119
- * @param {FiscalReceipt} receipt - The receipt object containing details to be printed as a non-fiscal receipt.
119
+ * @param {NonFiscalReceipt} receipt - The receipt object containing details to be printed as a non-fiscal receipt.
120
120
  * @param {string} deviceId - Device identifier from list/scan.
121
121
  * @return {Promise<FiscalResponse>} A promise that resolves to a FiscalResponse object indicating the result of the operation.
122
122
  * @throws {Error} If the device with the specified deviceId is not found.
123
123
  */
124
- printNonFiscalReceipt(receipt: FiscalReceipt, deviceId: string): Promise<FiscalResponse>;
124
+ printNonFiscalReceipt(receipt: NonFiscalReceipt, deviceId: string): Promise<FiscalResponse>;
125
125
  /**
126
126
  * Prints a reversal receipt using a fiscal device.
127
127
  *
@@ -3,6 +3,25 @@
3
3
  */
4
4
  export type DeviceId = string;
5
5
  export type TransportType = 'serial' | 'tcp' | 'bluetooth-spp' | 'bluetooth-ble' | 'hid' | 'sdk';
6
+ /**
7
+ * Interface for operator information
8
+ */
9
+ export interface OperatorInfo {
10
+ /**
11
+ * The operator number
12
+ */
13
+ number: number;
14
+ /**
15
+ * A string representing the password for authentication or security purposes.
16
+ * This variable typically holds sensitive information and should be handled securely.
17
+ * Ensure this value is kept private and not exposed in any logs or outputs.
18
+ */
19
+ password: string;
20
+ /**
21
+ * Optional operator code. If not provided, driver may derive it from operator number.
22
+ */
23
+ code?: string;
24
+ }
6
25
  export interface DeviceCapabilities {
7
26
  supportedOperations: {
8
27
  printFiscalReceipt: boolean;
@@ -18,6 +37,7 @@ export interface DeviceCapabilities {
18
37
  getDateTime: boolean;
19
38
  getLastFiscalRecord: boolean;
20
39
  getStatus: boolean;
40
+ printBarcode: boolean;
21
41
  };
22
42
  supportsInvoices: boolean;
23
43
  supportsRefunds: boolean;
@@ -29,45 +49,56 @@ export interface DeviceCapabilities {
29
49
  paymentTypes: FiscalPaymentType[];
30
50
  }
31
51
  /**
32
- * Interface for fiscal receipt
52
+ * Common payload fields shared by fiscal and non-fiscal receipts.
33
53
  */
34
- export interface FiscalReceipt {
35
- /**
36
- * An object representing various operator-related properties.
37
- */
38
- operator: {
39
- /**
40
- * Represents a numerical value.
41
- * This variable can store any valid number, including integers and floating-point values.
42
- */
43
- number: number;
44
- /**
45
- * Optional operator code. If not provided, driver may derive it from operator number.
46
- */
47
- code?: string;
48
- /**
49
- * A string representing the password for authentication or security purposes.
50
- * This variable typically holds sensitive information and should be handled securely.
51
- * Ensure this value is kept private and not exposed in any logs or outputs.
52
- */
53
- password: string;
54
- };
54
+ export interface BaseReceipt {
55
55
  /**
56
- * The unique sale number
56
+ * Operator information
57
57
  */
58
- uniqueSaleNumber: string;
58
+ operator: OperatorInfo;
59
59
  /**
60
60
  * The items in the receipt
61
61
  */
62
62
  items: FiscalReceiptItem[];
63
63
  /**
64
- * The payments in the receipt
64
+ * The client information (for invoice receipts)
65
+ */
66
+ client?: FiscalClient;
67
+ /**
68
+ * Optional text lines to be printed immediately after the receipt header.
69
+ */
70
+ headerText?: string[];
71
+ /**
72
+ * Optional text lines to be printed at the end of the receipt (before payments).
73
+ */
74
+ footerText?: string[];
75
+ /**
76
+ * Optional barcode to be printed at the end of the receipt (footer).
77
+ * Useful for loyalty programs, order tracking, or return vouchers.
78
+ */
79
+ footerBarcode?: BarcodeData;
80
+ }
81
+ /**
82
+ * Interface for fiscal receipt
83
+ */
84
+ export interface FiscalReceipt extends BaseReceipt {
85
+ /**
86
+ * Numeric string up to 7 digits, used as part of the UNP.
87
+ */
88
+ uniqueSaleNumber: string;
89
+ /**
90
+ * The payments in the receipt. The total must cover the receipt amount to close.
65
91
  */
66
92
  payments: FiscalPayment[];
93
+ }
94
+ /**
95
+ * Interface for non-fiscal (service) receipt
96
+ */
97
+ export interface NonFiscalReceipt extends BaseReceipt {
67
98
  /**
68
- * The client information (for invoice receipts)
99
+ * Optional informational payments printed on the receipt.
69
100
  */
70
- client?: FiscalClient;
101
+ payments?: FiscalPayment[];
71
102
  }
72
103
  /**
73
104
  * Interface for fiscal receipt item
@@ -84,14 +115,10 @@ export interface FiscalReceiptItem {
84
115
  */
85
116
  description?: string;
86
117
  /**
87
- * The price of the item
118
+ * The price of the item including tax (VAT inclusive).
119
+ * This price will be sent directly to the fiscal device and must include all applicable taxes.
88
120
  */
89
121
  unitPrice: number;
90
- /**
91
- * Represents the currency code in ISO 4217 format (e.g., 'USD', 'EUR', 'JPY').
92
- * Typically used to indicate the currency of a monetary value.
93
- */
94
- currency: string;
95
122
  /**
96
123
  * The quantity of the item
97
124
  */
@@ -101,7 +128,7 @@ export interface FiscalReceiptItem {
101
128
  */
102
129
  vatGroup: FiscalVATGroup;
103
130
  /**
104
- * The discount percentage (optional)
131
+ * Discount percentage (optional). Use 0-100, no surcharges.
105
132
  */
106
133
  discount?: number;
107
134
  }
@@ -169,10 +196,6 @@ export interface FiscalMemoryRecord {
169
196
  * Interface for fiscal device status
170
197
  */
171
198
  export interface FiscalDeviceStatus {
172
- /**
173
- * Whether the operation was successful
174
- */
175
- ok: boolean;
176
199
  /**
177
200
  * Whether the device is connected
178
201
  */
@@ -197,14 +220,6 @@ export interface FiscalDeviceStatus {
197
220
  * Whether printing is allowed
198
221
  */
199
222
  printingAllowed?: boolean;
200
- /**
201
- * The error code if any
202
- */
203
- errorCode?: number;
204
- /**
205
- * The error message if any
206
- */
207
- errorMessage?: string;
208
223
  /**
209
224
  * The messages returned by the fiscal device
210
225
  */
@@ -275,10 +290,8 @@ export interface FiscalDeviceDiagnosticStepNonFiscalReceipt extends FiscalDevice
275
290
  }
276
291
  export type FiscalDeviceDiagnosticStep = FiscalDeviceDiagnosticStepDeviceInfo | FiscalDeviceDiagnosticStepStatus | FiscalDeviceDiagnosticStepLastFiscalRecord | FiscalDeviceDiagnosticStepCashAmount | FiscalDeviceDiagnosticStepNonFiscalReceipt;
277
292
  export interface FiscalDeviceDiagnosticsOptions {
278
- operatorNumber: number;
279
- operatorPassword: string;
293
+ operator: OperatorInfo;
280
294
  amount?: number;
281
- currency?: string;
282
295
  vatGroup?: FiscalVATGroup;
283
296
  itemName?: string;
284
297
  }
@@ -344,16 +357,12 @@ export interface DeviceInfo {
344
357
  /**
345
358
  * The supported payment types
346
359
  */
347
- supportedPaymentTypes: string[];
360
+ supportedPaymentTypes: FiscalPaymentType[];
348
361
  }
349
362
  /**
350
363
  * Interface for fiscal response
351
364
  */
352
365
  export interface FiscalResponse {
353
- /**
354
- * Whether the operation was successful
355
- */
356
- ok: boolean;
357
366
  /**
358
367
  * The receipt number (if applicable)
359
368
  */
@@ -429,7 +438,7 @@ export interface ReversalReceipt extends FiscalReceipt {
429
438
  * Enum for reversal reasons
430
439
  */
431
440
  export declare enum ReversalReason {
432
- OPERATOR_ERROR = "operator-error",
441
+ VOID = "void",
433
442
  REFUND = "refund",
434
443
  TAX_BASE_REDUCTION = "tax-base-reduction"
435
444
  }
@@ -446,3 +455,15 @@ export declare enum FiscalVATGroup {
446
455
  G = "7",// Special rate 3
447
456
  H = "8"
448
457
  }
458
+ export declare enum BarcodeType {
459
+ EAN8 = "EAN8",
460
+ EAN13 = "EAN13",
461
+ CODE128 = "CODE128",
462
+ QR = "QR"
463
+ }
464
+ export interface BarcodeData {
465
+ type: BarcodeType;
466
+ data: string;
467
+ height?: number;
468
+ printText?: boolean;
469
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FiscalVATGroup = exports.ReversalReason = exports.FiscalPaymentType = void 0;
3
+ exports.BarcodeType = exports.FiscalVATGroup = exports.ReversalReason = exports.FiscalPaymentType = void 0;
4
4
  /**
5
5
  * Enum for fiscal payment types
6
6
  */
@@ -16,7 +16,7 @@ var FiscalPaymentType;
16
16
  */
17
17
  var ReversalReason;
18
18
  (function (ReversalReason) {
19
- ReversalReason["OPERATOR_ERROR"] = "operator-error";
19
+ ReversalReason["VOID"] = "void";
20
20
  ReversalReason["REFUND"] = "refund";
21
21
  ReversalReason["TAX_BASE_REDUCTION"] = "tax-base-reduction";
22
22
  })(ReversalReason || (exports.ReversalReason = ReversalReason = {}));
@@ -34,3 +34,10 @@ var FiscalVATGroup;
34
34
  FiscalVATGroup["G"] = "7";
35
35
  FiscalVATGroup["H"] = "8"; // Special rate 4
36
36
  })(FiscalVATGroup || (exports.FiscalVATGroup = FiscalVATGroup = {}));
37
+ var BarcodeType;
38
+ (function (BarcodeType) {
39
+ BarcodeType["EAN8"] = "EAN8";
40
+ BarcodeType["EAN13"] = "EAN13";
41
+ BarcodeType["CODE128"] = "CODE128";
42
+ BarcodeType["QR"] = "QR";
43
+ })(BarcodeType || (exports.BarcodeType = BarcodeType = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reservation-studio/electron-types",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "description": "TypeScript типове за ReservationStudioElectron",
5
5
  "scripts": {
6
6
  "build": "tsc --project tsconfig.json",