@reservation-studio/electron-types
Version:
TypeScript типове за ReservationStudioElectron
464 lines (463 loc) • 12.1 kB
TypeScript
/**
* Interface for fiscal device operations
*/
export interface FiscalDeviceInterface {
/**
* The model name of the fiscal device
*/
readonly model: string;
/**
* The manufacturer of the fiscal device
*/
readonly manufacturer: string;
/**
* The serial number of the fiscal device
*/
readonly serialNumber: string;
/**
* The port path of the fiscal device
*/
readonly port: string;
/**
* Initializes the fiscal device
*
* @returns {Promise<boolean>} A promise that resolves to true if initialization was successful
*/
initialize(): Promise<boolean>;
/**
* Checks if the device is connected and responsive
*
* @returns {Promise<boolean>} A promise that resolves to true if the device is connected
*/
isConnected(): Promise<boolean>;
/**
* Gets detailed information about the device
*
* @returns {Promise<DeviceInfo>} A promise that resolves to the device information
*/
getDeviceInfo(): Promise<DeviceInfo>;
/**
* Prints a fiscal receipt
*
* @param {FiscalReceipt} receipt - The receipt to print
* @returns {Promise<FiscalResponse>} A promise that resolves to the fiscal response
*/
printReceipt(receipt: FiscalReceipt): Promise<FiscalResponse>;
/**
* Prints a non-fiscal receipt based on the provided receipt details.
*
* @param {FiscalReceipt} receipt - The receipt object containing all relevant data for generating the non-fiscal receipt.
* @return {Promise<FiscalResponse>} A promise that resolves to a FiscalResponse object containing the status and details of the print operation.
*/
printNonFiscalReceipt(receipt: FiscalReceipt): Promise<FiscalResponse>;
/**
* Prints a reversal receipt
*
* @param {ReversalReceipt} receipt - The reversal receipt to print
* @returns {Promise<FiscalResponse>} A promise that resolves to the fiscal response
*/
printReversalReceipt(receipt: ReversalReceipt): Promise<FiscalResponse>;
/**
* Gets the last fiscal memory record
*
* @returns {Promise<FiscalMemoryRecord>} A promise that resolves to the last fiscal memory record
*/
getLastFiscalRecord(): Promise<FiscalMemoryRecord>;
/**
* Gets the status of the fiscal device
*
* @returns {Promise<FiscalDeviceStatus>} A promise that resolves to the status of the fiscal device
*/
getStatus(): Promise<FiscalDeviceStatus>;
/**
* Prints an X report (daily financial report without reset)
*
* @returns {Promise<boolean>} A promise that resolves to true if printing was successful
*/
printXReport(): Promise<boolean>;
/**
* Prints a Z report (daily financial report with reset)
*
* @returns {Promise<boolean>} A promise that resolves to true if printing was successful
*/
printZReport(): Promise<boolean>;
/**
* Deposits money into the cash register
*
* @param {number} amount - The amount to deposit
* @returns {Promise<boolean>} A promise that resolves to true if the deposit was successful
*/
depositMoney(amount: number): Promise<boolean>;
/**
* Withdraws money from the cash register
*
* @param {number} amount - The amount to withdraw
* @returns {Promise<boolean>} A promise that resolves to true if the withdrawal was successful
*/
withdrawMoney(amount: number): Promise<boolean>;
/**
* Gets the current cash amount in the register
*
* @returns {Promise<number>} A promise that resolves to the current cash amount
*/
getCashAmount(): Promise<number>;
/**
* Sets the date and time on the fiscal device
*
* @param {Date} dateTime - The date and time to set
* @returns {Promise<boolean>} A promise that resolves to true if setting was successful
*/
setDateTime(dateTime: Date): Promise<boolean>;
/**
* Prints a duplicate of the last receipt
*
* @returns {Promise<boolean>} A promise that resolves to true if printing was successful
*/
printDuplicate(): Promise<boolean>;
/**
* Closes the connection to the fiscal device
*
* @returns {Promise<boolean>} A promise that resolves to true if closing was successful
*/
close(): Promise<boolean>;
}
/**
* Interface for fiscal receipt
*/
export interface FiscalReceipt {
/**
* An object representing various operator-related properties.
*/
operator: {
/**
* Represents a numerical value.
* This variable can store any valid number, including integers and floating-point values.
*/
number: number;
/**
* A string representing the password for authentication or security purposes.
* This variable typically holds sensitive information and should be handled securely.
* Ensure this value is kept private and not exposed in any logs or outputs.
*/
password: string;
};
/**
* The unique sale number
*/
uniqueSaleNumber?: string;
/**
* The items in the receipt
*/
items: FiscalReceiptItem[];
/**
* The payments in the receipt
*/
payments: FiscalPayment[];
/**
* The client information (for invoice receipts)
*/
client?: FiscalClient;
}
/**
* Interface for fiscal receipt item
*/
export interface FiscalReceiptItem {
/**
* The name of the item
*/
name: string;
/**
* Optional description providing additional information or context.
* This can be used to supply user-friendly details or explanations
* associated with a particular resource, item, or operation.
*/
description?: string;
/**
* The price of the item
*/
unitPrice: number;
/**
* Represents the currency code in ISO 4217 format (e.g., 'USD', 'EUR', 'JPY').
* Typically used to indicate the currency of a monetary value.
*/
currency: string;
/**
* The quantity of the item
*/
quantity: number;
/**
* The VAT group of the item
*/
vatGroup: FiscalVATGroup;
/**
* The discount percentage (optional)
*/
discount?: number;
}
/**
* Interface for fiscal payment
*/
export interface FiscalPayment {
/**
* The payment type
*/
type: FiscalPaymentType;
/**
* The amount of the payment
*/
amount: number;
}
/**
* Enum for fiscal payment types
*/
export declare enum FiscalPaymentType {
CASH = "cash",
CARD = "card",
CHECK = "check",
TRANSFER = "transfer"
}
/**
* Interface for fiscal client information
*/
export interface FiscalClient {
/**
* The name of the client
*/
name: string;
/**
* The address of the client
*/
address?: string;
/**
* The tax number of the client
*/
taxNumber?: string;
/**
* The VAT number of the client
*/
vatNumber?: string;
}
/**
* Interface for fiscal memory record
*/
export interface FiscalMemoryRecord {
/**
* The number of the record
*/
number: string;
/**
* The date of the record
*/
date: Date;
/**
* The total amount of the record
*/
total: number;
}
/**
* Interface for fiscal device status
*/
export interface FiscalDeviceStatus {
/**
* Whether the operation was successful
*/
ok: boolean;
/**
* Whether the device is connected
*/
connected?: boolean;
/**
* Whether the device has paper
*/
hasPaper?: boolean;
/**
* Whether the fiscal memory is full
*/
fiscalMemoryFull?: boolean;
/**
* Whether a fiscal receipt is currently open
*/
fiscalReceiptOpen?: boolean;
/**
* Whether a non-fiscal receipt is currently open
*/
nonFiscalReceiptOpen?: boolean;
/**
* Whether printing is allowed
*/
printingAllowed?: boolean;
/**
* The error code if any
*/
errorCode?: number;
/**
* The error message if any
*/
errorMessage?: string;
/**
* The messages returned by the fiscal device
*/
messages: FiscalResponseMessage[];
}
/**
* Interface for fiscal device information in list responses
*/
export interface FiscalDeviceResponse {
/**
* The manufacturer of the fiscal device
*/
manufacturer: string;
/**
* The model name of the fiscal device
*/
model: string;
/**
* The serial number of the fiscal device
*/
serialNumber: string;
}
/**
* Interface for detailed device information
*/
export interface DeviceInfo {
/**
* The serial number of the fiscal device
*/
serialNumber: string;
/**
* The fiscal memory serial number
*/
fiscalMemorySerialNumber: string;
/**
* The manufacturer of the fiscal device
*/
manufacturer: string;
/**
* The model name of the fiscal device
*/
model: string;
/**
* The firmware version of the fiscal device
*/
firmwareVersion: string;
/**
* The current date and time of the fiscal device
*/
currentDateTime?: string;
/**
* The maximum length of item text
*/
itemTextMaxLength: number;
/**
* The maximum length of comment text
*/
commentTextMaxLength: number;
/**
* The maximum length of operator password
*/
operatorPasswordMaxLength: number;
/**
* The supported payment types
*/
supportedPaymentTypes: string[];
}
/**
* Interface for fiscal response
*/
export interface FiscalResponse {
/**
* Whether the operation was successful
*/
ok: boolean;
/**
* The receipt number (if applicable)
*/
number?: string;
/**
* Represents a unique identifier for a receipt generated for a particular sale.
* This variable is used to ensure that each sale has a distinct and traceable number.
* It may be undefined if no sale has been processed or the number has not been generated yet.
*/
generatedUniqueSaleNumber?: string;
/**
* The receipt date and time (if applicable)
*/
datetime?: string;
/**
* The receipt amount (if applicable)
*/
amount?: number;
/**
* Represents an optional piece of information regarding a device.
* This variable can store details such as the device's specifications,
* status, or metadata, depending on the structure of the `DeviceInfo` type.
*
* The value of `deviceInfo` may be undefined if no device information is available.
*
* @type {DeviceInfo | undefined}
*/
deviceInfo?: DeviceInfo;
/**
* The messages returned by the fiscal device
*/
messages: FiscalResponseMessage[];
}
/**
* Interface for fiscal response message
*/
export interface FiscalResponseMessage {
/**
* The type of the message
*/
type: 'info' | 'warning' | 'error';
/**
* The code of the message (if applicable)
*/
code?: string;
/**
* The text of the message
*/
text: string;
}
/**
* Interface for reversal receipt
*/
export interface ReversalReceipt extends FiscalReceipt {
/**
* The reason for the reversal
*/
reason: ReversalReason;
/**
* The original receipt number
*/
originalReceiptNumber: string;
/**
* The original receipt date and time
*/
originalReceiptDateTime: Date;
/**
* The original fiscal memory serial number
*/
originalFiscalMemorySerialNumber: string;
}
/**
* Enum for reversal reasons
*/
export declare enum ReversalReason {
OPERATOR_ERROR = "operator-error",
REFUND = "refund",
TAX_BASE_REDUCTION = "tax-base-reduction"
}
/**
* Enum for fiscal VAT groups
*/
export declare enum FiscalVATGroup {
A = "1",// 20%
B = "2",// 9%
C = "3",// 0%
D = "4",// Exempt
E = "5",// Special rate 1
F = "6",// Special rate 2
G = "7",// Special rate 3
H = "8"
}