360 Secure SkillHub
360 安全技能中心

Accounting Skill

该 Skill 通过 Python 脚本从发票、采购订单和银行对账单中抽取结构化字段,自动在数字 PDF 解析与 OCR 之间选择流程,做金额与日期校验,输出 Excel 台账和 JSON 备份,并可将未知文档分类后路由到对应抽取脚本。支持越南语与国际格式。

dvnghiem
dvnghiem
热度 85.40
最近更新 2026-05-18 12:28:23
分类:数据依赖:代码执行 / 读写文件应用场景:数据处理 / 财务 / 报告撰写 / 模板 ...

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add vn-accounting-skill
Metadata
name
accounting-skill
description
Process accounting documents — invoices (hóa đơn GTGT), purchase orders, and bank statements. Extract structured data from PDF (digital and scanned), JPG, and PNG files using OCR. Output Excel tracking sheets and JSON backups. Classify unknown documents and route to the correct extractor. Supports Vietnamese and international formats. Use when asked to extract, process, classify, or track invoices, POs, bank statements, or accounting documents.

Accounting Skill

Extract structured data from accounting documents (invoices, POs, bank statements) into Excel tracking sheets with JSON backups. Handles digital PDFs, scanned PDFs, and images via automatic OCR.

Prerequisites

Install system OCR dependencies before first use. See {baseDir}/references/ocr-setup.md for full guide.

# Ubuntu / Debian
sudo apt install tesseract-ocr tesseract-ocr-vie poppler-utils

# Verify
uv run {baseDir}/scripts/ocr_utils.py check

Quick Start

1. Classify an unknown document

uv run {baseDir}/scripts/classify_document.py /path/to/document.pdf

Returns JSON with type (invoice / po / statement / other), confidence, and a ready-to-run extraction command.

2. Extract an invoice

uv run {baseDir}/scripts/extract_invoice.py /path/to/invoice.pdf -o invoice_tracking.xlsx

Appends to the Excel tracking sheet. Use --dry-run to preview parsed data without writing.

3. Extract a bank statement

uv run {baseDir}/scripts/extract_statement.py /path/to/statement.pdf

Creates statement_{bank}_{date}.xlsx with transactions. Use -o to specify output path.

4. Extract a purchase order

uv run {baseDir}/scripts/extract_po.py /path/to/po.pdf -o po_tracking.xlsx

Tracks delivery dates and flags overdue/urgent POs.

5. Generate empty Excel templates

uv run {baseDir}/scripts/generate_templates.py all -o ~/accounting/

Creates blank tracking sheets: invoice_tracking.xlsx, po_tracking.xlsx, statement_template.xlsx.

Common Options (all extractors)

Flag Description
--format excel|json|both Output format (default: both)
--dry-run Parse and validate only, print JSON to stdout
--json-dir DIR Directory for JSON backup files
-o FILE Output Excel file path

Workflow

Single Document

File → classify_document.py → route → extract_*.py → Excel + JSON

Batch Processing

For a folder of mixed documents, classify first, then route:

for f in /path/to/docs/*; do
  uv run {baseDir}/scripts/classify_document.py "$f" --output-dir ~/accounting/
done

Then run the suggested extraction commands from each classification result.

OCR Strategy

All scripts share {baseDir}/scripts/ocr_utils.py which auto-selects the best extraction method:

  1. Digital PDFs → pdfplumber (fast, no OCR needed)
  2. Scanned PDFs → pdf2image + pytesseract at 300 DPI (fallback when pdfplumber gets <50 chars/page)
  3. Images (JPG/PNG/TIFF) → pytesseract with grayscale preprocessing

Each result includes ocr_confidence and extraction_confidence percentages. Documents below 85% are automatically flagged needs_review.

Validation Rules

  • Invoices: Subtotal + VAT = Total (auto-checks math), duplicate detection by invoice number + vendor
  • Bank statements: Opening balance + credits − debits = closing balance
  • POs: Delivery date tracking with overdue/urgent alerts

Reference Documents

Read these for field schemas, Vietnamese format details, and validation logic:

  • {baseDir}/references/invoice-fields.md — Vietnamese VAT invoice fields, tax rates, patterns
  • {baseDir}/references/bank-formats.md — Vietnamese bank names, transaction formats, amount patterns
  • {baseDir}/references/po-fields.md — PO fields, delivery status logic, payment terms
  • {baseDir}/references/ocr-setup.md — OCR installation, troubleshooting, confidence scoring