SuperAPI AI Directory

invoice-organizer

Data & analytics

View repository

Updated 10-15 20:10

About this skill

Invoice information organization and list issuance

Read the structured information from a batch of invoice PDFs, trace upward to the project context to fill in the purpose, file them into the corresponding project, and issue a list (by default a reimbursement list, which can be switched to an expense list, reconciliation statement, or other forms).

When to use

  • The user provides one or more invoice/receipt PDFs (transportation, accommodation, meals, office purchases, etc.) and needs to organize reimbursement
  • The user wants to file invoices into a certain case/project directory and generate a list
  • Trigger words: "reimburse these few invoices", "organize this batch of invoices", "make a reimbursement list", "file these receipts under project XX", "produce an expense list", "organize invoices by project"

Not applicable: legal/tax compliance review of invoices, substantive analysis as litigation evidence, physical PDF processing (merging/compression/page numbering).

Workflow

1. Extract invoice text

Prefer using pdftotext(poppler) to extract the text layer; electronic invoices mostly have a built-in text layer and work out of the box:

pdftotext -layout "发票.pdf" -

To extract multiple PDFs in bulk, use this skill's script (automatic separation, prompts for missing dependencies):

python3 scripts/extract_invoice.py 发票1.pdf 发票2.pdf 发票3.pdf
# 或传一个目录
python3 scripts/extract_invoice.py ~/Downloads/

If pdftotext produces no text output (scanned/image-based invoices), fall back to OCR: call legal-ocr or pdf skill。

2. Identify key fields

Parse the core fields of each invoice from the text; for identification points see references/invoice-field-guide.md. Common types quick reference:

Invoice type Required fields
Railway electronic ticket Departure and arrival stations, train number, date, fare, passenger, purchaser, invoice number
General VAT invoice (accommodation/meals/services) Purchaser, seller, item, amount, tax amount, total amount including tax, invoice number, invoicing date

Mark fields that cannot be confirmed as "pending manual confirmation"; do not speculate.

3. Match the corresponding project

Determine which project this batch of invoices belongs to based on the **purchaser name (invoice header)**: take the purchaser's full name and search the work document library for a matching client/customer; invoices with the same header belong to the same project; if no match can be made, confirm with the user and do not file on your own initiative.

4. Read the project context (trace upward for the purpose)

Trace upward from the invoice location (or intended filing location), read the information file of the corresponding project, and use it to fill in the purpose/case number/date/route/reimbursing unit in the "reimbursement information" table of the list:

python3 scripts/find_project_context.py "发票所在目录或文件路径"

For identification and extraction points see references/project-context-guide.md. Core mapping:

List field Project context source
Purpose Project/case name + the event that triggered the trip
Case number "Court case number" in 项目信息.md
Date Project timeline event matching the invoice business date
Route Event location (e.g., location of the court) ↔ usual place of residence
Reimbursing unit Client/Client (cross-verified with the invoice purchaser)
Traveler Handling lawyer/project traveler

Compare the invoice business date with the project timeline to infer the purpose of this trip (e.g., invoices 06-15 to 17 + project "06-16 Shijiazhuang hearing" → purpose "travel to Shijiazhuang to attend the first hearing"). If it cannot be confirmed from context, verify with the user; do not fabricate.

5. Archive to the project reimbursement directory

After determining the project it belongs to, copy the invoiceCopy(do not move; keep the original) to the reimbursement subdirectory of that project:

  • The target directory is determined by the AI based on the project's actual directory structure, and is not hard-bound to a fixed path
    • Litigation cases (12-directory system): commonly found under "Other Materials/Miscellaneous" type directories; do not place in case substantive directories such as evidence/documents
    • When there is no obvious directory, create a new 报销/(default; travel, etc. may be further subcategorized, e.g., 报销/差旅/)
  • Standard invoice file naming:YYMMDD 类型 摘要 [人名].pdf
    • Business date (not invoice date) + type + key summary + optional related personnel
    • Example:260615 高铁票 苏州北-石家庄 G1220 张某.pdf
    • Example:260615-0617 住宿费 石家庄XX酒店.pdf
    • Example:260620 餐饮费 XX餐厅 部门聚餐.pdf

6. Issue a list

The read invoice information can generate various lists—Reimbursement list (default), or as needed output consumption lists, reconciliation statements, monthly summaries, etc. When the user does not specify, issue the reimbursement list by default. For templates and naming conventions, see references/output-template.md。

Default output style(unless the user requests otherwise):

  • The list contains two parts: reimbursement information table + voucher detail table
  • The reimbursement information table's purpose/case number/date/route, etc.preferentially taken from the project context in step 4, and cross-verified with the invoice header
  • Voucher details columns:序号 | 日期 | 类型 | 摘要 | 金额(元) | 发票号, with a total in the last row
  • No emoji, no remarks or explanatory text paragraphs
  • For personnel involved, write only names, not ID numbers or other credential information
  • List file name:YYMMDD 报销清单.md(YYMMDD is the expected sending date; ask the user; if none, use the current day)
  • Type enumeration covers transportation/accommodation/catering/office procurement, etc., not limited to travel

Acceptance criteria

After completing one invoice organization, perform the following gate self-check. If any Hard Fail is hit, this output is judged unqualified and must not be delivered.

Hard Fail (one-vote veto)

  1. Must not fabricate: Invoice fields, amounts, and purpose must be taken from the original invoice text or project context; if unavailable, always mark "To be confirmed"; do not speculate or complete
  2. No archiving mismatch: When the invoice purchaser header does not match the target project client, you must confirm with the user and not archive on your own
  3. Original untouched: Archiving is always cp copy; prohibited mv move or delete the original
  4. Desensitization: Lists and archived file names contain only names; ID numbers, phone numbers, and other credential information must not appear
  5. Purpose not fabricated: When the invoice business date has no corresponding event in the project timeline, mark the purpose as "To be confirmed"; do not fabricate the travel purpose based on place names or dates

Completion conditions (machine-judgeable)

  • The voucher detail table has a total in the last row, and the total amount = the sum of the detail amounts
  • Each invoice has been matched to a unique project, or marked "pending confirmation" (no orphan invoices)
  • All dates are unified as YYYY-MM-DD; the archive file names and the list's "Date" column use the business date (not the invoice date)
  • List file name YYMMDD 报销清单.md(YYMMDD is the expected send date, already asked the user)
  • No emoji, no explanatory remark paragraphs, no ID numbers for personnel

Typical scenario self-check

Input: 2 invoices (1 high-speed rail ticket + 1 accommodation fee), the purchaser is the same company, and the business dates fall around a certain case's "XX hearing" timeline.

Expected output:

  • Both invoices are assigned to the same project, and the archive directory is that project's 报销/ subdirectory
  • The reason is inferred from the hearing event (e.g. "travel to XX to attend the hearing"), not fabricated
  • Voucher details 2 rows + total row, the amount is the total amount including tax
  • List "Reimbursement Unit" = purchaser name, cross-validated as consistent with the project client

Not within this skill's acceptance scope: OCR recognition accuracy itself (scanned documents fall back to legal-ocr), invoice authenticity, tax compliance judgment.

Dependencies

System dependencies

Dependency Installation method
poppler (provides pdftotext) macOS: brew install popplerLinux: sudo apt-get install poppler-utils

Poppler is only needed for "text extraction"; when the text layer is missing, switch to the OCR skill instead, no forced installation.scripts/find_project_context.py Uses only the Python standard library, no installation required.

Coordination with other skills

  • legal-ocr / pdf:pdftotext When there is no text layer, use its OCR capability to recognize scanned/image-type invoices
  • new-case: if the archive target is a litigation case, the directory system and project information file are defined by new-case; this skill judges the reimbursement subdirectory and retrospective context based on its structure
  • xlsx: if the list needs to be exported as an Excel spreadsheet, hand it over to the xlsx skill for processing