Document Ingestion
by @samledger67-dotcom
Process raw accounting source documents (PDFs, CSVs, bank statements, invoices, receipts) into standardized transaction records for QBO import. Use when batc...
clawhub install document-ingestionπ About This Skill
name: document-ingestion description: "Process raw accounting source documents (PDFs, CSVs, bank statements, invoices, receipts) into standardized transaction records for QBO import. Use when batch-processing client documents for month-end close, categorizing transactions, or extracting data from 1099s and payroll reports. NOT for bank reconciliation, P&L variance analysis, or AR collections." license: MIT metadata: openclaw: emoji: "π"
Document Ingestion Engine β SKILL.md
When to Use This Skill
Use when a user needs to process raw accounting source documents into standardized transaction records for QBO import. Triggers on:When NOT to Use
bank-reconciliation skill)pl-quick-compare skill)ar-collections-agent skill)What It Does
Processes 6 document types β standardized records β Excel workbook + QBO import CSV.
| Input Type | Formats | Extracts | |---|---|---| | Bank Statements | CSV, OFX/QFX, PDF | Date, vendor, amount | | Credit Card Stmts | CSV, PDF | Date, merchant, amount, category | | Invoices | PDF | Vendor, total, date, due date, invoice #, line items | | Receipts | PDF, JPG/PNG* | Merchant, date, amount | | 1099 / Tax Forms | PDF | Payer, TIN, form type, box amounts | | Payroll Reports | CSV, PDF | Employee, gross, taxes, net per employee |
*Image OCR requires tesseract installed.
Processing Steps
1. File type detection β magic bytes + extension fallback 2. Document classification β bank/CC/invoice/receipt/1099/payroll 3. Content extraction β CSV parsing, OFX parsing, PDF text extraction 4. Format normalization β dates (multi-format), amounts (Decimal), vendor names (strip noise) 5. QBO COA pull β fetches live Chart of Accounts from QBO for categorization 6. Duplicate detection β same amount + vendor within Β±3 days β flagged 7. Auto-categorization β vendor map β COA keywords β doc-class default 8. Confidence scoring β HIGH (exact match) / MEDIUM (fuzzy) / LOW (needs review) 9. Exception flagging β missing dates, zero amounts, unknown vendors, LOW confidence 10. QBO import CSV β ready for batch import (excludes dups + failed extractions) 11. Excel workbook β 6 tabs (see below) 12. CDC tracking β delta since last run cached in.cache/document-ingestion/{slug}.jsonExcel Output Tabs
| Tab | Contents | |---|---| | Processed Transactions | All records with category, confidence, dup flag, exception | | β Exceptions | Records needing manual review before import | | Duplicates | Flagged potential duplicates with "Dup Of" reference | | Category Mapping | Unique vendor β QBO account map with confidence | | Import Ready | QBO-format rows (Date, Description, Amount, Account, Memo) | | CDC Log | Delta metrics vs. prior run + this-run stats summary |Script Location
scripts/pipelines/document-ingestion.py
Usage
# Process a directory of mixed documents
python3 scripts/pipelines/document-ingestion.py \
--slug sb-paulson \
--input-dir ~/Downloads/month-end-docsSingle file
python3 scripts/pipelines/document-ingestion.py \
--slug sb-paulson \
--file ~/Downloads/invoice_march.pdfMultiple files + custom output dir
python3 scripts/pipelines/document-ingestion.py \
--slug glowlabs \
--file ~/Downloads/stmt.csv \
--file ~/Downloads/payroll.csv \
--out ~/Desktop/ingestedOffline mode (no QBO auth needed)
python3 scripts/pipelines/document-ingestion.py \
--slug sb-paulson \
--input-dir ./docs \
--no-qbo-coaQBO sandbox
python3 scripts/pipelines/document-ingestion.py \
--slug sb-paulson \
--input-dir ./docs \
--sandbox
All CLI Flags
| Flag | Default | Description | |---|---|---| |--slug | required | Company slug (QBO + client vendor map) |
| --input-dir | β | Directory of docs to process |
| --file | β | Single file (repeatable) |
| --out | ~/Desktop | Output directory |
| --no-qbo-coa | false | Use built-in COA only (offline) |
| --sandbox | false | QBO sandbox mode |Dependencies
Required (pip)
pip install openpyxl
Optional (better extraction quality)
pip install pdfminer.six # Better PDF text extraction
pip install ofxparse # Better OFX/QFX parsing
brew install tesseract # Image receipt OCR (JPG/PNG)
Node.js QBO Client
Node.js QBO client # Auth token must be configured
Categorization Logic
Priority Chain
1. Vendor Map exact match βHIGH confidence
2. Vendor Map substring match β HIGH confidence
3. COA keyword index (built from COA account names + keywords) β MEDIUM confidence
4. Doc-class default β LOW confidenceBuilt-in Vendor Map
50+ known vendors pre-mapped:VENDOR_MAP in script)Client-Specific Overrides
Auto-loaded by--slug:
clients/{slug}/categorization-map*.md markdown tablesDuplicate Detection Rules
DUP_WINDOW_DAYS constant)is_duplicate=True, excluded from import fileException Rules (auto-flagged)
| Condition | Flag | |---|---| | Missing transaction date | "Missing transaction date" | | Zero amount (non-1099) | "Zero amount β verify or skip" | | Empty/unknown vendor | "Vendor name missing or unknown" | | LOW confidence category | "Low categorization confidence β manual review" | | PDF extraction failed | "PDF text extraction failed β manual review required" | | Image without tesseract | "Image OCR not available β manual entry required" |QBO Import CSV Format
Ready-to-import columns:Date | Description | Amount | Vendor/Customer | Account | Class | Memo | Doc Number
CDC Cache
Location:.cache/document-ingestion/{slug}.jsonTracks between runs:
docs_processed, records_extracted, duplicates_caughtexceptions_flagged, import_readyhigh_confidence, medium_confidence, low_confidenceOutput File Naming
DocIngestion_{slug}_{YYYYMMDD}.xlsx
DocIngestion_{slug}_{YYYYMMDD}_QBO_Import.csv
Agent Instructions
Standard Run
1. Collect input files from user (directory path or individual files) 2. Get client slug (sb-paulson, glowlabs, etc.)
3. Run pipeline. If QBO auth not set, use --no-qbo-coa
4. Deliver summary:
- Records extracted, dups caught, exceptions
- HIGH/MED/LOW confidence split
- Path to Excel + import CSV
5. Walk user through Exceptions tab β those need action before importMonth-End Close Integration
--input-dir pointing to client's document drop folderbank-reconciliation.pyException Handling
nano-pdf skill or manual entryVENDOR_MAP in script or add to clients/{slug}/categorization-map.mdAdding New Client Vendor Maps
Editload_client_vendor_map() in the script:
if slug_lower in ("new-client", "nc"):
client_map.update({
"vendor name": "QBO Account Name",
})
Or create clients/{slug}/categorization-map.md with markdown table:
| Vendor / Memo Keyword | Primary Account | Notes |
|---|---|---|
| Amazon | Office Supplies | |
| Comcast | Utilities | |
Financial Math
All amounts use PythonDecimal with ROUND_HALF_UP to 2 decimal places. No float arithmetic.
π‘ Examples
# Process a directory of mixed documents
python3 scripts/pipelines/document-ingestion.py \
--slug sb-paulson \
--input-dir ~/Downloads/month-end-docsSingle file
python3 scripts/pipelines/document-ingestion.py \
--slug sb-paulson \
--file ~/Downloads/invoice_march.pdfMultiple files + custom output dir
python3 scripts/pipelines/document-ingestion.py \
--slug glowlabs \
--file ~/Downloads/stmt.csv \
--file ~/Downloads/payroll.csv \
--out ~/Desktop/ingestedOffline mode (no QBO auth needed)
python3 scripts/pipelines/document-ingestion.py \
--slug sb-paulson \
--input-dir ./docs \
--no-qbo-coaQBO sandbox
python3 scripts/pipelines/document-ingestion.py \
--slug sb-paulson \
--input-dir ./docs \
--sandbox
All CLI Flags
| Flag | Default | Description | |---|---|---| |--slug | required | Company slug (QBO + client vendor map) |
| --input-dir | β | Directory of docs to process |
| --file | β | Single file (repeatable) |
| --out | ~/Desktop | Output directory |
| --no-qbo-coa | false | Use built-in COA only (offline) |
| --sandbox | false | QBO sandbox mode |