@reservation-studio/electron-types 0.0.28 → 0.0.30

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 'operator-error', '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
+ OPERATOR_ERROR = 'operator-error',
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
  *
@@ -198,6 +198,14 @@ export interface ApiInterface {
198
198
  * @throws {Error} If the device with the specified deviceId is not found.
199
199
  */
200
200
  setDateTime(dateTime: Date, deviceId: string): Promise<boolean>;
201
+ /**
202
+ * Gets the date and time from a fiscal device.
203
+ *
204
+ * @param {string} deviceId - Device identifier from list/scan.
205
+ * @return {Promise<Date>} A promise that resolves to the device date/time.
206
+ * @throws {Error} If the device with the specified deviceId is not found.
207
+ */
208
+ getDateTime(deviceId: string): Promise<Date>;
201
209
  /**
202
210
  * Prints a duplicate of the last receipt using a fiscal device.
203
211
  *
@@ -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;
@@ -15,8 +34,10 @@ export interface DeviceCapabilities {
15
34
  withdrawMoney: boolean;
16
35
  getCashAmount: boolean;
17
36
  setDateTime: boolean;
37
+ getDateTime: boolean;
18
38
  getLastFiscalRecord: boolean;
19
39
  getStatus: boolean;
40
+ printBarcode: boolean;
20
41
  };
21
42
  supportsInvoices: boolean;
22
43
  supportsRefunds: boolean;
@@ -28,45 +49,56 @@ export interface DeviceCapabilities {
28
49
  paymentTypes: FiscalPaymentType[];
29
50
  }
30
51
  /**
31
- * Interface for fiscal receipt
52
+ * Common payload fields shared by fiscal and non-fiscal receipts.
32
53
  */
33
- export interface FiscalReceipt {
34
- /**
35
- * An object representing various operator-related properties.
36
- */
37
- operator: {
38
- /**
39
- * Represents a numerical value.
40
- * This variable can store any valid number, including integers and floating-point values.
41
- */
42
- number: number;
43
- /**
44
- * Optional operator code. If not provided, driver may derive it from operator number.
45
- */
46
- code?: string;
47
- /**
48
- * A string representing the password for authentication or security purposes.
49
- * This variable typically holds sensitive information and should be handled securely.
50
- * Ensure this value is kept private and not exposed in any logs or outputs.
51
- */
52
- password: string;
53
- };
54
+ export interface BaseReceipt {
54
55
  /**
55
- * The unique sale number
56
+ * Operator information
56
57
  */
57
- uniqueSaleNumber?: string;
58
+ operator: OperatorInfo;
58
59
  /**
59
60
  * The items in the receipt
60
61
  */
61
62
  items: FiscalReceiptItem[];
62
63
  /**
63
- * 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.
64
91
  */
65
92
  payments: FiscalPayment[];
93
+ }
94
+ /**
95
+ * Interface for non-fiscal (service) receipt
96
+ */
97
+ export interface NonFiscalReceipt extends BaseReceipt {
66
98
  /**
67
- * The client information (for invoice receipts)
99
+ * Optional informational payments printed on the receipt.
68
100
  */
69
- client?: FiscalClient;
101
+ payments?: FiscalPayment[];
70
102
  }
71
103
  /**
72
104
  * Interface for fiscal receipt item
@@ -83,14 +115,10 @@ export interface FiscalReceiptItem {
83
115
  */
84
116
  description?: string;
85
117
  /**
86
- * 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.
87
120
  */
88
121
  unitPrice: number;
89
- /**
90
- * Represents the currency code in ISO 4217 format (e.g., 'USD', 'EUR', 'JPY').
91
- * Typically used to indicate the currency of a monetary value.
92
- */
93
- currency: string;
94
122
  /**
95
123
  * The quantity of the item
96
124
  */
@@ -100,7 +128,7 @@ export interface FiscalReceiptItem {
100
128
  */
101
129
  vatGroup: FiscalVATGroup;
102
130
  /**
103
- * The discount percentage (optional)
131
+ * Discount percentage (optional). Use 0-100, no surcharges.
104
132
  */
105
133
  discount?: number;
106
134
  }
@@ -168,10 +196,6 @@ export interface FiscalMemoryRecord {
168
196
  * Interface for fiscal device status
169
197
  */
170
198
  export interface FiscalDeviceStatus {
171
- /**
172
- * Whether the operation was successful
173
- */
174
- ok: boolean;
175
199
  /**
176
200
  * Whether the device is connected
177
201
  */
@@ -196,14 +220,6 @@ export interface FiscalDeviceStatus {
196
220
  * Whether printing is allowed
197
221
  */
198
222
  printingAllowed?: boolean;
199
- /**
200
- * The error code if any
201
- */
202
- errorCode?: number;
203
- /**
204
- * The error message if any
205
- */
206
- errorMessage?: string;
207
223
  /**
208
224
  * The messages returned by the fiscal device
209
225
  */
@@ -274,10 +290,8 @@ export interface FiscalDeviceDiagnosticStepNonFiscalReceipt extends FiscalDevice
274
290
  }
275
291
  export type FiscalDeviceDiagnosticStep = FiscalDeviceDiagnosticStepDeviceInfo | FiscalDeviceDiagnosticStepStatus | FiscalDeviceDiagnosticStepLastFiscalRecord | FiscalDeviceDiagnosticStepCashAmount | FiscalDeviceDiagnosticStepNonFiscalReceipt;
276
292
  export interface FiscalDeviceDiagnosticsOptions {
277
- operatorNumber: number;
278
- operatorPassword: string;
293
+ operator: OperatorInfo;
279
294
  amount?: number;
280
- currency?: string;
281
295
  vatGroup?: FiscalVATGroup;
282
296
  itemName?: string;
283
297
  }
@@ -343,16 +357,12 @@ export interface DeviceInfo {
343
357
  /**
344
358
  * The supported payment types
345
359
  */
346
- supportedPaymentTypes: string[];
360
+ supportedPaymentTypes: FiscalPaymentType[];
347
361
  }
348
362
  /**
349
363
  * Interface for fiscal response
350
364
  */
351
365
  export interface FiscalResponse {
352
- /**
353
- * Whether the operation was successful
354
- */
355
- ok: boolean;
356
366
  /**
357
367
  * The receipt number (if applicable)
358
368
  */
@@ -445,3 +455,15 @@ export declare enum FiscalVATGroup {
445
455
  G = "7",// Special rate 3
446
456
  H = "8"
447
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
  */
@@ -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.28",
3
+ "version": "0.0.30",
4
4
  "description": "TypeScript типове за ReservationStudioElectron",
5
5
  "scripts": {
6
6
  "build": "tsc --project tsconfig.json",