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

invoice-ofd2json

v1.0.6

Published

解析发票ofd为json

Downloads

4

Readme

说明

功能

轻量化JavaScript库,可解析输入的ofd发票文件内容,并将其提取转为json格式输出

特点

  • [x] 可解析电子发票
  • [x] 可解析全电发票
  • [x] 轻量化JavaScript库
  • [x] 即开即用 易于使用
  • [x] 兼容前端浏览器
  • [x] 兼容后端Node.js
  • [x] 可解析多页发票(试验功能)

TODO(欢迎PR)

  • [ ] 兼容特殊类型发票(例如:成品油、建筑服务类特殊发票,缺少特殊发票样本)
  • [ ] 可解析销货清单(缺少多页发票样本)

原理

通过JSZip解压ofd发票,提取CustomTag.xml以及Pages/*/Content.xml文件并对其进行解析
(所有解析内容来源均为ofd发票文件,仅支持正规格式。受ofd格式限制,文件内部分信息缺失,暂时无法做到100%准确,仅能依靠预定义解决)

使用方法

Node.js

安装(NPM)

npm install invoice-ofd2json

使用

const ofd2json = require("invoice-ofd2json");
/**
 * 解析输入的ofd文件内容并将其转换为json输出
 * @param ofd 任意符合JSZip输入格式的ofd文件格式
 * @param logMessage 用于调试输出时附带的信息
 * @return json格式的解析后的ofd内容
 */
await ofd2json(ofd, ?logMessage)

Browser

安装(CDN)

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jszip.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/invoice-ofd2json/src/parser.js" crossorigin="anonymous"></script>

使用

/**
 * 解析输入的ofd文件内容并将其转换为json输出
 * @param ofd 任意符合JSZip输入格式的ofd文件格式
 * @param logMessage 用于调试输出时附带的信息
 * @return json格式的解析后的ofd内容
 */
await ofd2json(ofd, ?logMessage)

UserScript

安装(CDN)

// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/jszip.min.js
// @require https://cdn.jsdelivr.net/npm/invoice-ofd2json/src/parser.js

使用

/**
 * 解析输入的ofd文件内容并将其转换为json输出
 * @param ofd 任意符合JSZip输入格式的ofd文件格式
 * @param logMessage 用于调试输出时附带的信息
 * @return json格式的解析后的ofd内容
 */
await ofd2json(ofd, ?logMessage)

应用场景

详见Demo

License

MIT