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

ireceipt

v1.0.2

Published

Generate Taiwan's electronic receipt including QR code, bar code, and XML for National Taxation Bureau

Downloads

19

Readme

iReceipt

Generate Taiwan's electronic receipt including QR code, bar code, and XML for National Taxation Bureau. The spec. from National Taxation Bureau is trivial but very complicated and hard to read. iReceipt can save your life and time!!!

npm GitHub stars GitHub forks npm GitHub license

Installation

npm install ireceipt --save

Run in a Browser

Just leverage Webpack to bundle IReceipt to let IReceipt work in a browser.

Usage

import IReceipt from 'ireceipt';

const info = new IReceipt.ReceiptInfo(
        1234,
        new Date(),
        { id: '{{SELLER_ID}}', name: '{{SELLER_NAME}}' },
        { id: '{{BUYER_ID}}', name: '{{BUYER_NAME}}' },
        false
    ),
    items = [new IReceipt.Item('{{ITEM_DESCRIPTION}}', 3000, 1)],
    receipt = new IReceipt.Receipt(info, items),
    AESKey = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];

receipt
    .render(AESKey)
    .then(htmlString => {
        const win = window.open();
        win.document.body.innerHTML = htmlString;
    })
    .catch(err => {
        window.console.error('err', err);
    });

// toXmL
window.console.log(receipt.toXML());

// Taiwan Receipt Lottery
// The format of the list of winners:
// 53925591  10510LC60123189...
// 53925591  10510LC60122037...
const winnersList = IReceipt.Receipt.parseWinnersList('{{WINNERS_LIST}}');
window.console.log(receipt.isWinning(winnersList));

Receipt

The receipt JavaScript object. It owns a ReceiptInfo, Items and creates a Amount based on items.

constructor(info, items)

info ReceiptInfo
items array of Item

Member Methods

toXML() Receipt object to xml string.
generateBarCodeString() generate bar code string.
generateLeftQRCodeString() generate left QR code string including the receipt's information. generateRightQRCodeString() generate right QR code string including information for all items.
renderRightQRCode() generate right QR code svg string. return Promise.
renderLeftQRCode(AESKey) generate left QR code svg string. return Promise.

AESKey the type is array (see the usage section) and the AES key is applied from National Taxation Bureau. More details: 取得電子發票QRCODE中AES加密金鑰

renderBarCode()generate bar code svg string. return Promise.
render(AESKey) render Taiwan's electronic receipt. return Promise.

AESKey refer to renderLeftQRCode(AESKey)

ReceiptInfo

Store the receipt information.

constructor(number, date, seller, buyer, type, carrier, donationID, orderno)

number receipt number
date receipt date
seller seller information, including id and name. ({ id: '{{SELLER_ID}}', name: '{{SELLER_NAME}}' })
buyer buyer information, including id and name. ({ id: '{{BUYER_ID}}', name: '{{BUYER_NAME}}' })
type receipt type (default 07)
carrier receipt carrier information, including id and type. ({id: '{{CARRIER_ID}}', type:'CARRIER_TYPE'})
donationID charity's love code (愛心碼)
orderno order number

Item

The product item buyed by buyer.

constructor(description, unitPrice, sequenceNumber, quantity, taxType)

description product item's description
unitPrice unit price for a product item
sequenceNumber sequence number
quantity quantity of product items (default 1)
taxType tax type (default TaxType.TAX)

Amount

Store the amount information.

constructor(taxItems, freeTaxItems, zeroTaxItems)

taxItems tax items
freeTaxItems free tax items
zeroTaxItems zero tax items

TaxType

Tax type enum.

{
    TAX: 1,
    ZERO_TAX: 2,
    FREE_TAX: 3,
    SPECIAL_TAX: 4,
    COMPOUND_TAX: 9
}

EncodeType

Encode type for QR code enum.

{
    BIG5: 0,
    UTF8: 1,
    BASE64: 3
}

Reference

  • E-invoice Platform (財政部電子發票整合服務平台)
  • 電子發票證明聯一維及二維條碼規格說明(V1.6)
  • 電子發票資料交換標準文件與範例(V3.1.2)
  • 取得電子發票QRCODE中AES加密金鑰

Author

Zheng-Xiang Ke, [email protected]

Contributors

Sin-Fong Lyu, [email protected]

License

iReceipt is available under the MIT license. See the LICENSE file for more info.