Repository navigation
Replies: 1 comment 1 reply
|
How do you add it to Edge gallery - Agent skills? |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Purpose
Extract structured accounting and inventory data from:
The skill converts unstructured invoice documents into normalized ERP-ready JSON.
Core Objectives
The agent must:
Supported Input Types
supported_inputs:
Expected Output
{
"success": true,
"document_type": "Tax Invoice",
"supplier": {},
"customer": {},
"invoice": {},
"items": [],
"totals": {},
"tax": {},
"meta": {}
}
Extraction Pipeline
Step 1 — Image Preprocessing
Before OCR:
Required preprocessing
Optional enhancement
Step 2 — OCR Layer
Use OCR engine:
Recommended:
OCR should preserve:
Step 3 — Document Classification
Classify document:
possible_types:
Step 4 — Field Extraction
Supplier Information
Extract:
{
"supplier_name": "",
"supplier_trn": "",
"supplier_address": "",
"supplier_phone": [],
"supplier_email": [],
"supplier_website": ""
}
Customer Information
Extract:
{
"customer_name": "",
"customer_trn": "",
"customer_address": "",
"customer_phone": ""
}
Invoice Header
Extract:
{
"invoice_number": "",
"invoice_date": "",
"invoice_time": "",
"currency": "",
"payment_status": "",
"salesman": "",
"lpo_no": ""
}
Step 5 — Line Item Extraction
Each row should become:
{
"line_no": 1,
"item_code": "",
"description": "",
"quantity": 0,
"unit": "",
"unit_price": 0,
"discount": 0,
"tax_percent": 0,
"tax_amount": 0,
"line_total": 0
}
Step 6 — Totals Extraction
Extract:
{
"subtotal": 0,
"discount_total": 0,
"vat_amount": 0,
"grand_total": 0,
"paid_amount": 0,
"balance": 0
}
Step 7 — Validation Rules
Accounting Validation
Rule 1
subtotal + vat - discount = grand_total
Rule 2
sum(line_totals) == subtotal
Rule 3
TRN format validation:
Rule 4
Date normalization:
Confidence Scoring
Every extracted field should contain confidence.
Example:
{
"invoice_number": {
"value": "506979",
"confidence": 0.98
}
}
Error Handling
If OCR confidence is low
Return:
{
"warnings": [
"Low OCR confidence on item code"
]
}
If totals mismatch
Return:
{
"validation_errors": [
"Grand total mismatch"
]
}
Final JSON Schema
{
"success": true,
"document_type": "Tax Invoice",
"company": {
"name": "",
"trn": "",
"address": ""
},
"supplier": {
"name": "",
"trn": "",
"address": "",
"phone": [],
"email": [],
"website": ""
},
"invoice": {
"invoice_no": "",
"invoice_date": "",
"currency": "AED",
"salesman": "",
"payment_status": ""
},
"items": [],
"totals": {},
"tax": {},
"validation": {
"is_valid": true,
"warnings": [],
"errors": []
},
"meta": {
"ocr_engine": "",
"ocr_confidence": 0,
"processed_at": ""
}
}
Recommended AI Prompt
System Prompt
You are an invoice extraction engine.
Your job is to extract structured accounting data from invoices.
Rules:
Recommended Tech Stack
Backend
backend:
OCR
ocr:
AI Extraction
llm:
Recommended Processing Architecture
Upload File
↓
Preprocess Image
↓
OCR Extraction
↓
Layout Detection
↓
LLM Structured Parsing
↓
Validation Layer
↓
ERP JSON Formatter
↓
Save / Import
ERP Import Enhancements
Recommended additional fields:
{
"branch_id": "",
"warehouse_id": "",
"cost_center_id": "",
"supplier_id": "",
"purchase_account": "",
"vat_account": "",
"attachments": []
}
Advanced Features
Future Enhancements
supplier + invoice_no + amount
Auto map:
AI predicts:
Auto detect:
Use:
Security Considerations
Example Output
{
"success": true,
"document_type": "Tax Invoice",
"supplier": {
"name": "Adarc Computers LLC",
"trn": "105191898300003"
},
"company": {
"name": "Juran Information Systems LLC",
"trn": "100616249700003"
},
"invoice": {
"invoice_no": "506979",
"invoice_date": "2026-04-09",
"currency": "AED"
},
"items": [
{
"description": "MJ POS Thermal Printer",
"quantity": 1,
"unit_price": 228.60,
"tax_amount": 11.43,
"line_total": 240.03
}
],
"totals": {
"subtotal": 228.60,
"vat_amount": 11.43,
"grand_total": 240.03
}
}
All reactions