npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

epson-fiscal-printer

v1.1.24

Published

A typescript module for fiscal printers support.

Downloads

406

Readme

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

| Name | Desc | | --- | --- | | operator | to identify the operator | | sales | sale items or cancel sale items | | lottery | national lottery unique customer code | | personalTaxCode | | refunds | refund items or cancel refunds | | subtotals | | | payments | | | barCode | | | qrCode | | | graphicCoupon | | | openDrawer | |

Fiscal.Report

| Name | Desc | | --- | --- | | type | report type: daily financial report or daily fiscal closure or both | | operator | | | timeout | | | openDrawer | |

Fiscal.Cancel

| Name | Desc | | --- | --- | | type | void or redund | | zRepNum | daily fiscal closure report number | | docNum | document number | | date | | | fiscalNum | fiscal serial number of the printer | | operator | |

Fiscal.Command

| Name | Desc | | --- | --- | | code | command type | | data | data required by the command |

Commands

| Command | Desc | Support | --- | --- | --- | | OPEN_DRAWER | value: 0, open drawer | Epson / Custom | | QUERY_PRINTER_STATUS | value 1, query printer status | Epson / Custom | | RESET_PRINTER | value 2, reset printer | Epson / Custom | | GET_NATIVE_CODE_FUNCTION | value 3, use printer native code command | Epson / Custom | | GET_INFO | value 4, get printer device info | Custom Only |

Interfaces

| Epson | Custom | RCH | | --- | --- | --- | | 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[]) |executeCommand(commands: RCHProtocol.Commands) |

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
});
  • RCH Protocol Examples
    // init instance
    const rchInstance = new RCHXmlHttpClient({
        host: '192.168.1.99',
    });
    // exec sale item command
    const response = await rchInstance.executeCommand([
        '=R1/$200/(DOLCE)',
        '=R2/$100/*2/(CAFFE)',
        '=T1'
    ]);
    // get fiscal status command
    const getStatus = await rchInstance.executeCommand([
        '</?i/*4',
    ]); 
    /**
     * refund
     * 180923: DDMMYY
     * 27: lastZ + 1
     * 16: lastDocF
    */
    const getStatus = await rchInstance.executeCommand([
        `=k/&180923/[27/]16`
    ]);
   

Implemented

| Epson | Custom | RCH | --- | --- | --- | | Fiscal ePOS-Print XML | | |