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 🙏

© 2026 – Pkg Stats / Ryan Hefner

h3c-expense-cli

v2.1.2

Published

H3C 发票报销 CLI 工具

Readme

H3C 发票报销 CLI

用于 H3C 报销场景的命令行工具,支持发票识别、新建报销单、我的申请事项查询、我的发票删除、待办审批等。

架构图(目录结构)

cli/
├── package.json
├── README.md
├── SKILL.md
└── src/
    ├── index.js                  # 程序入口:注册所有命令、定义交互主菜单与 --help
    ├── commands/                 # 交互/命令编排层:参数校验、提示交互、流程编排
    │   ├── auth.js               # 登录/状态/登出入口,维护凭证生命周期
    │   ├── approval.js           # 待办审批交互:多选、汇总、同意/驳回、意见校验
    │   ├── config.js             # 配置初始化与展示
    │   ├── invoice.js            # 发票识别、查看识别缓存、清理缓存
    │   ├── query.js              # 我的申请事项/我的发票/我的订单/收款账户查询入口
    │   └── reimburse.js          # 新建报销单入口:报销发票、识别并报销
    ├── services/                 # 业务实现层:封装接口请求、响应解析、业务规则
    │   ├── approval.js           # 待审批列表查询与批量审批提交
    │   ├── invoice-ocr.js        # PDF/OCR识别与发票信息抽取、缓存读写
    │   ├── query.js              # 单据/发票/订单/收款账户查询与删除能力
    │   └── reimbursement.js      # 报销单创建主流程(表头/行数据构造与提交)
    ├── shortcuts/                # 快捷命令层:对常用场景提供更短命令
    │   ├── invoice.js            # +invoice
    │   ├── list.js               # +list
    │   └── submit.js             # +submit
    ├── api/                      # 底层网络层:HTTP、Cookie、登录鉴权接口
    │   ├── auth.js               # 登录相关接口
    │   └── client.js             # 通用 fetch、Cookie 持久化、重试辅助
    ├── utils/                    # 通用工具:与业务无关的可复用模块
    │   ├── auth.js               # 登录态检查与辅助
    │   ├── config.js             # ~/.h3c-cli 配置与路径管理
    │   ├── logger.js             # 终端日志与 loading 动画
    │   └── output.js             # 表格/金额等输出格式化
    └── skills/
        └── index.js              # Skills 元数据(描述与可用命令)

分层职责说明

  • index.js 只做“路由与菜单”,不写具体业务逻辑。
  • commands/* 负责“人机交互”和“调用顺序”,例如先查询后选择再删除。
  • services/* 负责“业务动作”,例如构造 _request_data、解析 success/result、处理重登录。
  • api/client.js 是所有网络调用的统一入口,负责 Cookie 自动带上与落盘。
  • utils/* 提供跨模块通用能力,避免在业务层重复实现。

关键调用链

用户命令/菜单选择
  -> src/index.js
  -> src/commands/*.js (交互与编排)
  -> src/services/*.js (业务实现)
  -> src/api/client.js (HTTP + Cookie)
  -> Newsse API

安装与运行

cd cli
npm install
npm link
h3c

交互菜单(推荐)

直接运行 h3c 进入交互模式,当前一级菜单包括:

  • 新建报销单
  • 我的申请事项
  • 我的发票
  • 我的订单
  • 个人收款账户
  • 待办审批

常用命令

认证

h3c auth login
h3c auth status
h3c auth logout

发票

h3c +invoice 发票.pdf
h3c invoice recognize 发票.pdf
h3c invoice info
h3c invoice clear

新建报销单

h3c +submit 发票.pdf
h3c reimburse submit 发票.pdf
h3c reimburse quick

我的申请事项

h3c +list
h3c query summary
h3c query summary -d
h3c query draft
h3c query ongoing
h3c query return
h3c query over

我的发票 / 我的订单 / 收款账户

h3c query invoice   # 查看并支持删除
h3c query taxi      # 打车报销订单
h3c query account   # 我个人收款账户

待办审批

h3c approval list
h3c approval approve

功能说明

  • 草稿箱支持空格多选删除
  • 我的发票支持空格多选删除
  • 待办审批支持多选、汇总金额、同意/驳回、意见校验(驳回必填)
  • 报销发票模式会优先使用已识别信息并自动补齐缺失识别

数据文件

  • ~/.h3c-cli/config.json:配置文件
  • ~/.h3c-cli/.cookies.json:Cookie 缓存
  • ~/.h3c-cli/invoice-info.json:发票识别缓存

开发命令

cd cli
npm install
npm link
node src/index.js