0.0.3 • Published 5 months ago

js-epos-driver v0.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

EposDriver

How To Use

Installl package
npm install js-epos-driver

Import EposDriver from library
import { EposDriver} from 'js-epos-driver';

Initialize EposDriver

var driver = new EposDriver(
      options={
        ipAddress: '192.168.2.224',
        useSSL: false,
        openCashDrawer: false,
        translateFunction: (text) => {return text +'test'},
        roundPr: (price) => {return price},
        responseHandler: (response) => {console.log(response)},
        errorHandler: (status, response) => {
            console.log('ERROR')
            console.log(status)
            console.log(response)
            }
    });

Parameters

  • ipAddress: ipAddres of the printer
  • useSSL: if set to true connection are made through https. SSL must be enabled on the printer
  • translateFunction: function to translate driver messages.
  • roundPr: function to round float numbers. Default use 2 decimal places
  • errorHandler: function to handle errors from driver
  • responseHandler: function to handle response from driver

responseHandler receive a response object having this structure:

response :{  
    res:{  
        success: bool,  
        code: string,
        status: number,
        statusText: string
    },
    addInfo: dict, //debug info from printer. Only if res.success is false
    tagListNames: list, // debug info from printer. Only if res.success is false
    msgPrinter: string //parsed error message. Only if res.success is false
    msg: string //mesage from printer if getStatusOfFilesForADE is called 
    printed: boolean,
    fiscalReceiptNumber: number
    fiscalReceiptAmount: number
    fiscalReceiptDate: string //format YYYY/MM/DD
    zRepNumber: string
}

Methods

printFiscalReceipt(receipt)

receipt:{
    header: String, optional
    footer: String, optional
    orderlines: [
        {
            quantity: Number, //if negative (refund) all orderlines must be negative
            price: Number, //total price of the line
            discount: Number, percentage
            productName: String,
            unitPrice: Number,
            department:  Number //range 1-99 
        }
    ],
    paymentlines: [
        ticket: String,
        amount: Number,
        type: String, 0=cash, 1=checque, 2=credit card, 3=ticket
        typeIndex: Number, Cash – 0 - 5. Credit – 0 Credit card – 1 - 10. Ticket – 1 - 10.
        description: String, optional
    ],
    operatorId: String, optional default 1
    refundFullRefund: Boolean, optional. Mandatory if quantity in orderLines is negative
    refundDate: String, es. 2020/12/08, optinal. Mandatory if quantity in orderLines is negative
    refundReport: String, //must be four digits, optional. Mandatory if quantity in orderLines is negative
    refundDocNum: String, //must be four digits, optional. Mandatory if quantity in orderLines is negative
    refundCashFiscalSerial: String  //fiscal serial number of the printer that issued the original document, optional. Mandatory if quantity in orderLines is negative
    roundingApplied: Number, optional
    message: String, optional
    lotteryCode: String, optional
}

printFiscalXZReport(operatorId)

It prints report and fiscal closure both
operatorId: the operator id. Must be between 1 and 12, Default 1

printFiscalXReport(operatorId)

It prints report operatorId: the operator id. Must be between 1 and 12, Default 1

getStatusOfFilesForADE()

Retrieves the status of files for ADE (Agenzia delle Entrate).

printFiscalReprintLast(operatorId)

Reprint last receipt operatorId: the operator id. Must be between 1 and 12, Default 1

openCashDrawer(operatorId)

Open drawer operatorId: the operator id. Must be between 1 and 12, Default 1

resetPrinter(operatorId)

operatorId: the operator id. Must be between 1 and 12, Default 1 Return the printer to the STATO REGISTRAZIONE state independent of the current state.

  • Close any open non-fiscal receipts.
  • Close any open administrative documents.
  • Cancel any open fiscal receipts.
  • Cancel any open commercial documents.
  • Cancel any open credit notes.
  • Cancel any open direct invoices printing two copies.
  • Cancel any open free invoices printing one copy.
  • Cancel any open box office tickets plus return the printer to the “SCONTRINO FISCALE” mode.
  • Unblock the keyboard that was previously blocked with the 1055 native protocol command.
  • Clean the keyboard buffer.

printDisplayTest(msg, operatorId)

Displays a text message on the printer's display.
operatorId: the operator id. Must be between 1 and 12, Default 1 msg: message to be displayed. The maximum number of characters is 40

clearText(operatorId)

Clears the text from the printer's display.
operatorId: the operator id. Must be between 1 and 12, Default 1

References

https://support.epson.net/setupnavi/?MKN=FP-81II+RT&PINF=menu&LG2=IT
From epson driver spec files

Common attributes

  • operator: Operator ID number (range 1 - 12). The operator attribute can be omitted. In this case, Operator 01 is assumed. A +50 offset can used with printRecItem, printRecRefund and printRecItemVoid (regarding printRecItemVoid, the offset cannot be used if voidLastItem="1"). Normally if the quantity = 1, the quantity line with "1x" is not printed. Adding the offset to the operator attribute instructs the fiscal printer to print the line when the quantity is exactly 1. The offset has no effect with direct invoices.

  • description: String whose maximum length varies depending on the printer model. Currently the maximum is: Fiscal receipts and commercial documents – 38 characters Direct invoices – 37 characters When printing invoices based on the last fiscal receipt, any 38 character descriptions in the fiscal receipt are truncated to 37 characters. Descriptions that exceed limits are truncated. Note that other attribute names with a similar meaning can have higher maximum lengths such as the “data” attribute used with the “printNormal” sub-element.

  • department: Department ID number (range 1 - 99).

  • qauntity: Epson fiscal printers can compute quantities from 0.001 up to 9999.999. EpsonFPMate automatically rounds down quantities with more than three decimal places. If the quantity exceeds 9999.999, an error is returned. Either a comma or a full stop (period) can represent the decimal point. Thousand separators should not be used. The value must not be zero.
  • unitPrice, amount, payment: Epson fiscal printers can accept prices from 0.00 up to 9999999.99. EpsonFPMate automatically rounds down amounts with more than two decimal places. If it exceeds 9999999.99, an error is returned. Either a comma or a full stop (period) can represent the decimal point. Thousand separators should not be used. The unitPrice and payment attributes can be zero but the amount attribute cannot be zero.
  • justification: Set the customer display description justification. The maximum number of characters that can appear on the display on one line is 20, but descriptions can be longer. This parameter tells the fiscal printer whether to take the first 20 characters or the last 20 from the relative description text to use on the display. Set the attribute as follows: - 1 = First 20 characters - 2 = Last 20 characters
  • font: Fiscal printers support four different font types. Set the attribute as 7 font follows:

    • 1 = Normal
    • 2 = Bold
    • 3 = Double height
    • 4 = Bold and double height

    The font attribute used with barcodes has a different meaning. Please see the ePOS-Print_eng document for an explanation of non-fiscal TM printer fonts.

  • comment: Ignored by the printer. Useful especially for directIO requests.

0.0.3

5 months ago

0.0.2

6 months ago

0.0.1

6 months ago