← 返回 Skills 市场
发票识别
作者
fangdeqian
· GitHub ↗
· v1.0.3
· MIT-0
131
总下载
0
收藏
0
当前安装
4
版本数
在 OpenClaw 中安装
/install invoice-recognition
功能描述
支持增值税发票、普通发票、区块链发票等多种票据的OCR识别与信息提取;自动完成票据类型分类、关键字段提取、格式校验;当用户需要识别发票内容、提取发票信息、校验发票格式时使用
使用说明 (SKILL.md)
发票识别技能
任务目标
- 本Skill用于: 对发票图像或文档进行智能识别,提取结构化信息并完成校验
- 核心能力:
- 发票图像OCR识别与信息提取
- 票据类型自动分类与识别
- 发票信息格式校验与逻辑验证
- 发票真伪查验操作指导(提供官方查验平台信息和使用步骤)
- 多格式文件处理支持
- 触发条件:
- 用户上传发票图片或文档
- 用户请求识别发票内容
- 用户需要校验发票格式
- 用户需要了解发票真伪查验方法
前置准备
支持的文件格式
| 格式类型 | 处理方式 |
|---|---|
| 图片文件(JPG/PNG/BMP) | 直接进行图像识别 |
| PDF文档 | 调用脚本转换为图片后识别 |
| OFD文档 | 调用脚本转换为图片后识别(需额外安装ofd2pdf库) |
环境准备
如需处理PDF文件,确保已安装必要工具:
# 安装PDF处理依赖(脚本执行前需要)
pip install pdf2image==1.16.3 Pillow==10.0.0
如需处理OFD文件,需要额外安装:
pip install ofd2pdf
操作步骤
标准流程
1. 文件接收与预处理
- 接收用户上传的发票文件(图片、PDF、OFD等)
- 判断文件格式:
- 图片格式(JPG/PNG)→ 直接进入识别流程
- PDF格式 → 调用
scripts/pdf_to_image.py转换为图片 - OFD格式 → 调用
scripts/pdf_to_image.py转换为图片(需安装ofd2pdf库)
2. 发票识别(OCR)
- OCR实现方式:使用智能体的原生图像识别能力,无需额外依赖OCR库
- 提取关键字段:
- 发票代码(Invoice Code)
- 发票号码(Invoice Number)
- 开票日期(Invoice Date)
- 购买方信息(Buyer Info)
- 销售方信息(Seller Info)
- 商品明细(Line Items)
- 金额信息(Amounts)
- 校验码(Check Code)
- 税率与税额(Tax Rate/Amount)
3. 票据类型分类
-
根据发票特征自动识别类型:
- 增值税专用发票(发票代码12位,第1位为0或1)
- 增值税普通发票(发票代码12位,第1位为0或1)
- 区块链电子发票(发票代码以"1"开头,共20位)
- 医疗电子票据(特定编码规则)
- 其他类型发票
-
分类标准:
- 增值税发票(noteType=1):含税号、具有完整的税额信息
- 非增值税发票(noteType=2):不包含税号或税额信息
4. 信息校验
-
格式校验:检查各字段格式是否符合规范
- 发票代码:10位或12位数字
- 发票号码:8位数字
- 校验码:20位或32位
- 税号:15/17/18/20位
- 开票日期:YYYY-MM-DD格式
-
逻辑校验:验证金额之间的逻辑关系
- 价税合计 = 不含税金额 + 税额
- 税率必须符合规定(如13%、9%、6%、3%等)
- 单价与数量的乘积应等于金额
- 各行明细汇总应等于总金额
5. 发票查验操作指导(如用户需要)
- 指导方式:提供官方查验平台信息和操作步骤,由用户自行完成查验
- 官方查验平台:
- 国家税务总局全国增值税发票查验平台:https://inv-veri.chinatax.gov.cn
- 操作指导内容:
- 增值税发票查验所需的关键信息提取
- 不同发票类型的查验规则说明
- 查验结果判定标准
- 常见问题及解决方案
注意:本技能不提供自动API调用查验,仅提供操作指导。用户需手动访问官方平台进行查验。
6. 结果输出
- 结构化输出发票信息:
{ "invoice_type": "增值税普通发票", "invoice_code": "144031900110", "invoice_number": "12345678", "invoice_date": "2024-01-15", "buyer": { "name": "购买方名称", "tax_number": "91440300XXXXXXXXX" }, "seller": { "name": "销售方名称", "tax_number": "91440300XXXXXXXXX" }, "line_items": [ { "description": "商品名称", "quantity": 1, "unit_price": 100.00, "amount": 100.00, "tax_rate": 0.13, "tax_amount": 13.00 } ], "subtotal": 100.00, "tax_amount": 13.00, "total_amount": 113.00, "check_code": "12345678901234567890", "validation": { "format_valid": true, "logic_valid": true } }
可选分支
分支A:二维码/源文件识别
- 二维码识别:直接解析发票上的二维码获取信息
分支B:信息补全
当OCR识别不完整时:
- 识别缺失字段:标记识别失败的字段
- 智能补全:根据已有信息推断缺失内容
- 人工确认:提示用户确认补全信息的准确性
资源索引
- 格式规范:见 references/invoice-formats.md
- 何时读取:进行格式校验或需要了解具体格式要求时
- 票据分类:见 references/invoice-types.md
- 何时读取:需要识别票据类型或分类规则时
- PDF转图片脚本:见 scripts/pdf_to_image.py
- 用途:将PDF/OFD文档转换为图片以便识别
- 参数:
input_path(输入文件路径)、output_path(输出图片路径)
注意事项
- 图像质量:上传发票图片时,建议确保图片清晰、光照均匀、无遮挡
- 格式校验:校验失败的信息需要人工复核确认
- 查验时效:发票查验建议在开票后一定时间内完成,避免查验平台超时
- 隐私保护:处理发票时注意保护敏感信息,识别完成后可提示用户是否需要删除原文件
- OFD文件处理:处理OFD文件需额外安装ofd2pdf库,安装命令:
pip install ofd2pdf
使用示例
示例1:识别发票图片
场景:用户上传了一张增值税发票图片,需要提取发票信息
执行步骤:
- 加载用户上传的图片
- 使用智能体原生图像识别能力识别发票内容
- 提取关键字段:发票代码、号码、日期、金额等
- 根据格式规范校验各字段
- 校验金额逻辑关系
- 输出结构化发票信息
示例2:识别PDF发票
场景:用户上传了一个PDF格式的电子发票,需要提取发票信息
执行步骤:
- 调用
scripts/pdf_to_image.py将PDF转换为图片 - 使用智能体原生图像识别能力识别发票内容
- 提取关键字段:发票代码、号码、日期、金额等
- 根据格式规范校验各字段
- 校验金额逻辑关系
- 输出结构化发票信息
示例3:校验发票格式
场景:用户提供了发票信息文本,需要校验格式是否正确
执行步骤:
- 解析用户提供的发票信息
- 参考格式规范校验各字段格式
- 校验金额逻辑关系
- 输出校验结果(通过/失败详情)
- 如有错误,提供修正建议
安全使用建议
This skill appears to do what it claims: convert PDFs/OFDs to images and validate invoice fields. Before using it, note: (1) you must install pdf2image and Pillow (and ofd2pdf only if you need OFD support); (2) OCR is performed by the agent/model (the SKILL.md references the agent's native image recognition), so uploaded images will be processed by whatever vision pipeline your platform uses — treat invoice images as sensitive and confirm your platform's data handling; (3) run the included pdf_to_image.py locally if you have untrusted files and prefer local conversion; and (4) remove or encrypt stored files containing personal/tax information after processing. If you need automatic server-side invoice verification against official APIs, this skill does not perform automatic queries — it only provides manual guidance for the official tax site.
功能分析
Type: OpenClaw Skill
Name: invoice-recognition
Version: 1.0.3
The skill bundle provides legitimate invoice OCR and validation capabilities. The Python script `scripts/pdf_to_image.py` uses standard libraries (pdf2image, Pillow) to convert documents for processing, and the instructions in `SKILL.md` are strictly aligned with the stated purpose of invoice recognition without any signs of prompt injection, data exfiltration, or malicious execution.
能力评估
Purpose & Capability
The name/description (invoice OCR and validation) match the included resources: format reference docs and a PDF->image conversion script. Declared Python dependencies (pdf2image, Pillow) are appropriate for PDF conversion and image handling.
Instruction Scope
Runtime instructions stay within invoice processing: accept user files, convert PDFs/OFDs using the provided script, then perform OCR and validation. One small ambiguity: the SKILL.md says OCR is done using the agent's "native image recognition ability" rather than a local OCR library — this is a design choice but means images may be processed by the platform/model provider. The skill does not instruct reading unrelated files, environment variables, or contacting external endpoints (it only lists an official government URL for manual verification).
Install Mechanism
There is no automated install spec; the skill is instruction-only and includes a small, local conversion script. Dependencies are standard Python packages (pdf2image, Pillow) and an optional ofd2pdf for OFD conversion — no downloads from unknown hosts or archive extraction are present.
Credentials
The skill requests no environment variables, credentials, or config paths. The files and libraries it uses are proportional to converting and validating invoice files.
Persistence & Privilege
always is false and the skill does not request persistent or elevated platform privileges, nor does it modify other skills or system-wide settings.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install invoice-recognition - 安装完成后,直接呼叫该 Skill 的名称或使用
/invoice-recognition触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.3
- No code or documentation changes detected in this version.
- Functionality and guidance for invoice recognition remain unchanged.
- Users can continue to use all features as before.
v1.0.2
No changes detected in this version.
- No file changes were made.
- Functionality and documentation remain the same as the previous version.
v1.0.1
- 官方发票查验改为操作指导,不再提供自动查验、真伪验证或批量查验能力,用户需手动访问官方查验平台
- OFD电子发票支持调整:新增需安装ofd2pdf库方可处理OFD文件
- 去除批量处理、去重、查验API调用等说明,专注图片、PDF、OFD单据识别与结构化信息提取
- 操作步骤中强调仅提供查验流程和官方指南,不代替查验动作
- 使用示例和操作说明同步精简,聚焦关键场景
v1.0.0
invoice-recognition 技能说明
核心能力概览:
这是一个专用于发票智能处理的技能,具备三大核心能力:
一、功能定位
这个技能主要解决发票处理的四个核心场景:
发票识别与信息提取:对发票进行OCR识别,自动提取发票代码、号码、日期、金额、购买方/销售方信息等关键字段
票据类型自动分类:能识别增值税发票(专用/普通)、区块链电子发票、医疗电子票据等多种类型
格式校验与逻辑验证:检查发票格式规范性(如发票代码位数、税号格式等),并验证金额逻辑关系(价税合计=不含税金额+税额)
发票真伪查验指导:提供多种查验方式的指导(云端查验、本地查验、区块链查验等)
二、触发方式
当你有以下需求时,这个技能就会被激活:
上传发票文件时:无论是图片(JPG/PNG)、PDF、OFD还是XML格式,都可以直接处理
明确要求识别发票内容时:比如"识别这张发票"、"提取发票信息"
需要校验发票时:比如"校验这张发票的格式"、"验证发票真伪"
批量处理需求:需要处理多张发票或整个文件夹的发票时
三、技术优势
相比传统人工处理,这个技能的价值在于:
智能化:自动完成从图像到结构化数据的转换
精准性:支持格式校验和逻辑验证,减少人为错误
高效性:支持批量处理,可一次性处理多张发票
兼容性:支持多种文件格式(图片、PDF、OFD、XML)
元数据
常见问题
发票识别 是什么?
支持增值税发票、普通发票、区块链发票等多种票据的OCR识别与信息提取;自动完成票据类型分类、关键字段提取、格式校验;当用户需要识别发票内容、提取发票信息、校验发票格式时使用. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 131 次。
如何安装 发票识别?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install invoice-recognition」即可一键安装,无需额外配置。
发票识别 是免费的吗?
是的,发票识别 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
发票识别 支持哪些平台?
发票识别 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 发票识别?
由 fangdeqian(@fangdeqian)开发并维护,当前版本 v1.0.3。
推荐 Skills