Jpg ocr stat

From XuShuwenn/RedAct · View interactive version

Jpg ocr stat is an AI agent skill from the GitHub repository XuShuwenn/RedAct. Extract date and total amount from receipt JPG images using OCR, and write results to Excel file.

How to use this skill

Skill file

Receipt OCR and Statistics

When to Use

Input

Output

Excel file /app/workspace/stat_ocr.xlsx:

Execution

Validation Workflow

Date Extraction

Total Amount Extraction

Keywords (priority order):

  1. GRAND TOTAL
  2. TOTAL RM, TOTAL: RM
  3. TOTAL AMOUNT
  4. TOTAL, AMOUNT, TOTAL DUE, etc.

Use candidate scoring, not just "last number on a matched line". Prefer lines with strong final-total phrases and penalize headers/summary labels such as Description Amount, Sales, Qty, QTY ITEM TOTAL, or non-final tax summaries.

Enforce keyword priority strictly: if a higher-priority keyword is present, do not fall back to lower-priority groups for that receipt.

Accept an amount only when it is on the same line as, or immediately adjacent to, a total-related keyword. Treat next-line fallback after a keyword as high-risk; use it only when same-line extraction fails and the keyword line clearly indicates a payable final total, not a broad header/table label or metadata.

Treat exclusion terms as negative signals, not absolute blockers: do not discard a line just because it contains GST/SST if it also contains a high-priority total phrase like TOTAL RM or GRAND TOTAL.

Exclude or heavily penalize lines with: SUBTOTAL, DISCOUNT, CHANGE, CASH TENDERED, ROUNDING, tax-only summaries.

Treat generic words like AMOUNT or TOTAL alone as weak signals; prefer strong phrases such as GRAND TOTAL, TOTAL RM, TOTAL AMOUNT, or TOTAL DUE.

Prefer specific final-total phrases and stronger keyword matches over a larger numeric value elsewhere. Reject candidates near unrelated contexts such as litre/quantity/unit-price/item lines, even if the OCR text is noisy.

Do not invent decimals from ambiguous integers unless the receipt text gives strong explicit currency or decimal evidence. Prefer decimal amounts associated with total keywords; avoid plain integers unless the receipt clearly shows no cents.

Treat 0.00 as suspicious unless the OCR text explicitly shows a zero total; otherwise inspect the source line or fallback match and set to null if unresolved.

Do NOT let a later weak match override an earlier stronger total candidate just because it appears lower on the receipt.

If multiple total candidates conflict and context does not clearly disambiguate them, set total_amount to null.

Handle comma separators (1,234.56).

Extraction Reliability

Extraction Reliability

Tips

Execution and Recovery

Final Verification

Final Verification

Execution and Recovery

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.