Use when importing Chinese VAT e-invoices into monthly Excel ledgers inside agent workflows, especially when XML files are available, matching PDF files should be archived, and the agent should handle staging plus monthly workbook updates end to end.
Import Chinese VAT invoice files into a month-based ledger inside an agent workflow:
For every run, stage files under a single workspace-local temp root:
Staging root: <cwd>/tmp/invoice-batch-inputRun folder: <cwd>/tmp/invoice-batch-input/<run-id>Recommended shell flow:
RUN_ID="$(date +%Y-%m-%d-%H%M%S)"
STAGING_ROOT="$PWD/tmp/invoice-batch-input"
RUN_DIR="$STAGING_ROOT/$RUN_ID"
mkdir -p "$RUN_DIR"
cp -f "/path/to/invoice A.xml" "$RUN_DIR/"
cp -f "/path/to/invoice A.pdf" "$RUN_DIR/"
Run the bundled script from this skill directory:
python3 scripts/invoice_to_xlsx.py \
--input-dir "$RUN_DIR" \
--ledger-root /path/to/invoice-ledger \
--recursive
If the repository root is the current directory, this also works:
python3 skills/cn-invoice-to-xlsx/scripts/invoice_to_xlsx.py \
--input-dir "$RUN_DIR" \
--ledger-root /path/to/invoice-ledger \
--recursive
.xml, .pdf.ofd is not imported in this versionThe script creates one folder per issue month:
<ledger-root>/
2026-03/
invoices_2026-03.xlsx
source/
xml/
pdf/
manifest/
rows.csv
import-log.csv
invoices_YYYY-MM.xlsx: monthly ledger workbooksource/xml, source/pdf: archived originalsmanifest/rows.csv: canonical monthly row store used to rebuild the workbookmanifest/import-log.csv: import audit trailColumns are defined in references/xlsx_schema.md.
Invoices are deduplicated by:
invoice_numberissue_dateamount_incl_taxbuyer_tax_idBehavior:
pdf_fallback row for the same invoicepdftotext (Poppler) for PDF fallback parsingAfter every import run, include this block in the user-facing summary:
Staging root: absolute pathRun folder: absolute pathCopied files: count and filenames with original names unchangedLedger root: absolute pathImport summary: imported / duplicate_skipped / upgraded_from_pdf / parse_error / archive_errorCleanup choice: ask whether to delete or keep the staged batch