1.1.21 • Published 8 months ago

epson-fiscal-printer v1.1.21

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Fiscal Printer

In order to easily interface with different brands of fiscal printers and use their same functions, this module defines a unified interactive data structure and interfaces. By implementing these interfaces to interact with a certain certain brand of fiscal printer.

Interactive data structure

Fiscal.Receipt

NameDesc
operatorto identify the operator
salessale items or cancel sale items
lotterynational lottery unique customer code
personalTaxCode
refundsrefund items or cancel refunds
subtotals
payments
barCode
qrCode
graphicCoupon
openDrawer

Fiscal.Report

NameDesc
typereport type: daily financial report or daily fiscal closure or both
operator
timeout
openDrawer

Fiscal.Cancel

NameDesc
typevoid or redund
zRepNumdaily fiscal closure report number
docNumdocument number
date
fiscalNumfiscal serial number of the printer
operator

Fiscal.Command

NameDesc
codecommand type
datadata required by the command

Commands

CommandDescSupport
OPEN_DRAWERvalue: 0, open drawerEpson / Custom
QUERY_PRINTER_STATUSvalue 1, query printer statusEpson / Custom
RESET_PRINTERvalue 2, reset printerEpson / Custom
GET_NATIVE_CODE_FUNCTIONvalue 3, use printer native code commandEpson / Custom
GET_INFOvalue 4, get printer device infoCustom Only

Interfaces

EpsonCustom
printFiscalReceipt(receipt: Fiscal.Receipt)printFiscalReceipt(receipt: FPrinterCustom.Receipt)
printFiscalReport(report: Fiscal.Report)printFiscalReport(report: FPrinterCustom.Report)
printCancel(cancel: Fiscal.Cancel)printCancel(cancel: FPrinterCustom.Cancel)
executeCommand(...commands: Fiscal.Command[])executeCommand(...commands: FPrinterCustom.Command[])

Usage

  • Epson Fiscal ePOS-Print XML Examples
// Create a client
const fprinter: FPrinter.Client = new EpsonXmlHttpClient({
    host: '192.168.1.1',
    deviceId: 'local_printer',
    timeout: 10000
});

// Fiscal receipt
await client.printFiscalReceipt({
    sales: [
        {
            type: Fiscal.ItemType.HOLD,
            description: 'A',
            quantity: 1,
            unitPrice: 5
        },
        {
            type: Fiscal.ItemType.HOLD,
            description: 'B',
            quantity: 2,
            unitPrice: 2.5
        },
        {
            type: Fiscal.ItemType.HOLD,
            description: 'C',
            quantity: 3,
            unitPrice: 3
        },
    ],
    payments: [
        {
            description: 'Payment in cash',
            payment: 19
        }
    ]
});

// Fiscal Report
await client.printFiscalReport({
    type: Fiscal.ReportType.DAILY_FISCAL_CLOUSE,
});
  • Custom Protocol Examples
  • Note: unit quantity multiplied by 1000, unit price multiplied by 1000, include the discount, payment
// Create a client
const fprinter: FPrinterCustom.Client = new CustomXmlHttpClient({
    host: '192.168.1.1',
    fiscalId: 'STMTE500432', // 11 digits
});

// Fiscal receipt
await fprinter.printFiscalReceipt({
    sales: [
        {
            type: Fiscal.ItemType.HOLD,
            description: 'A',
            quantity: 1 * 1000,
            unitPrice: 5 * 100
        },
        {
            type: Fiscal.ItemType.HOLD,
            description: 'B',
            quantity: 2 * 1000,
            unitPrice: 2.5 * 100
        },
        {
            type: Fiscal.ItemType.HOLD,
            description: 'C',
            quantity: 3 * 1000,
            unitPrice: 3 * 100
        },
    ],
    payments: [
        {
            description: 'Payment in cash',
            payment: 19 * 100,
            paymentType: 1
        }
    ]
});

// Fiscal Refund
// step 1 request to make sure the annulment is possible, if responseBuf === 1 then execute step 2 
await fprinter.printCancel({
    docRefZ: '0021',
    docRefNumber: '0034',
    docDate: '011022', // DDMMYY
    printPreview: CustomProtocol.EnableType.DISABLE,
    fiscalSerial: 'STMTE500432',
    checkOnly: CustomProtocol.EnableType.ABLE, 
    codLottery: 'ASDSFES7',
});

// step 2 to proceed with the actual void request
await fprinter.printCancel({
    docRefZ: '0021',
    docRefNumber: '0034',
    docDate: '011022', // DDMMYY,
    printPreview: CustomProtocol.EnableType.DISABLE,
    fiscalSerial: 'STMTE500432',
    checkOnly: CustomProtocol.EnableType.DISABLE,
    codLottery: 'ASDSFES7',
});

// Fiscal Report
await fprinter.printFiscalReport({
    type: CustomProtocol.ReportType.DAILY_FISCAL_CLOUSE,
});

// Fiscal Command
await fprinter.executeCommand({
    code: CustomProtocol.CommandCode.OPEN_DRAWER
});

Implemented

EpsonCustom
Fiscal ePOS-Print XML
1.1.19

8 months ago

1.1.21

8 months ago

1.1.20

8 months ago

1.1.16

1 year ago

1.1.18

1 year ago

1.1.17

1 year ago

1.1.15

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.12

2 years ago

1.1.11

2 years ago

1.1.10

2 years ago

1.1.14

2 years ago

1.1.13

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago