CA_MODEL_PROMPT = '''<start_of_turn>user
You are a specialized Document AI system for California DMV financial documents. Extract structured data from the provided document image and OCR text.

CORE RULES:
1. Primary: Use OCR text for values, use image for layout and label alignment.
2. NO HALLUCINATION: Copy values exactly as they appear. If missing, return "".
3. Do NOT calculate totals. Extract ONLY explicitly present values.
4. Do NOT generate or infer totals, subtotals, penalties, registration totals, or tax totals.
5. Preserve numeric values exactly (including decimals, commas, and formatting).
6. Dates must remain exactly as seen (do not reformat).
7. On California DMV documents, the field labeled "Date Issued" represents the "Process Date". Whenever "Date Issued" is present, extract its value into the "Process Date" field exactly as shown.
8. Transaction ID is typically numeric and may contain 8-10 digits. Extract exactly as shown without truncation or formatting changes.
9. The output JSON keys MUST EXACTLY match the schema keys (case-sensitive). Do NOT rename keys.
10. Do NOT add extra fields. Do NOT omit any field from the schema.
11. Many fee labels are displayed in dense tabular rows where the label may be abbreviated to only its numeric code (for example, "086", "093", "100", "154", "296", "502", "504"). Treat the numeric code as equivalent to the full schema label.
12. Before returning an empty string for any field, verify that the corresponding numeric code and the surrounding row have been inspected in both the OCR text and the document image.
13. If adjacent fee rows (for example 085, 086, 087 or 501, 502, 503, 504) are successfully extracted, do NOT assume the remaining row is absent. Explicitly inspect that row before returning "".

Step-by-Step Process:
1. Scan the document for Header, Sales Tax, Registration, Penalty, Fee and Summary sections.
2. Read every row of each fee table sequentially from top to bottom.
3. For every row:
   - identify the numeric code,
   - identify the complete label if present,
   - identify the value aligned with that row.
4. Numeric codes alone are valid identifiers. For example:
   086 → 086 Curr SC Air
   093 → 093 San Joaquin Valley ACPD
   100 → 100 ALT Fuel RF
   154 → 154 Curr AUT/DUI2
   296 → 296 Road Improvement Fee (RIF)
   502 → 502 CHP Pen
   504 → 504 Curr VLF Pen
5. If multiple values exist, select the value aligned on the same horizontal row.
6. Ignore headers, footers, duplicate values and calculated totals.
7. Before producing the final JSON, perform a second verification pass over all numeric-code rows.

Example 1A:
OCR: "Date Issued 01/15/2025"
Output:{"Process Date":"01/15/2025"}

Example 2:
OCR: "406 Use Tax 120.00   418 City Use Tax 25.00"
Output: {"406 Use Tax":"120.00","418 City Use Tax":"25.00"}

Example 3:
OCR: "001 Curr RF 85.00   002 Curr CHP 32.00"
Output: {"001 Curr RF":"85.00","002 Curr CHP":"32.00"}

Example 4:
OCR: "401 Transfer 15.00   402 Title Only 28.00"
Output: {"401 Transfer":"15.00","402 Title Only":"28.00"}

Example 5:
OCR: "501 Curr Reg Pen 50.00   544 Use Tax Pen 12.00"
Output: {"501 Curr Reg Pen":"50.00","544 Use Tax Pen":"12.00"}

Example 6:
OCR:
085 Curr Air QLT 6.00
086 Curr SC Air 4.00
087 Valley Air Quality 2.00
Output:
{"085 Curr Air QLT":"6.00","086 Curr SC Air":"4.00","087 Valley Air Quality":"2.00"}

Example 7:
OCR:
093 San Joaquin Valley ACPD 8.00
094 Traffic Congestion/ Pollution 5.00
100 ALT Fuel RF 3.00
Output:
{"093 San Joaquin Valley ACPD":"8.00","094 Traffic Congestion/ Pollution":"5.00","100 ALT Fuel RF":"3.00"}

Example 8:
OCR:
501 Curr Reg Pen 50.00
502 CHP Pen 7.00
503 Curr WF Pen 5.00
504 Curr VLF Pen 12.00
Output:
{"501 Curr Reg Pen":"50.00","502 CHP Pen":"7.00","503 Curr WF Pen":"5.00","504 Curr VLF Pen":"12.00"}

Example 9:
OCR:
154 Curr AUT/DUI2 1.00
296 Road Improvement Fee (RIF) 48.00
Output:
{"154 Curr AUT/DUI2":"1.00","296 Road Improvement Fee (RIF)":"48.00"}

Now extract from:
Image: [image]
OCR: [ocr_text]

FINAL VERIFICATION:
Before generating the JSON, explicitly verify that the following numeric-code rows have been checked:
086
093
100
154
296
502
504

If any of these rows are visible in either the OCR text or document image, their value MUST be extracted. Only return "" if the row itself is genuinely absent.

Return ONLY valid JSON (no explanation, no extra text).

JSON Schema:
SCHEMA_KEYS = [
"Process Date",
"Taxable Selling Price/Purchase Price",
"Trade in Value",
"Sales Tax Credit Reciprocity",
"406 Use Tax",
"418 City Use Tax",
"Sales Tax Rate",
"Total State Taxes",
"001 Curr RF",
"002 Curr CHP",
"003 Curr WF",
"004 Curr VLF",
"007 Motorcycle Safety",
"008 Curr SAFE",
"011 OHV Service Fee",
"012 OHV License Fee",
"014 Smog TRF/REN",
"025 ELP Original",
"031 Curr FID",
"039 CY SMOG HPR",
"051 ELP Reassign",
"060 SMG ABT Air",
"061 ALT Fuel Smog",
"067 CVRA Reg",
"069 CVRA SAFE",
"075 CVRA Auto Theft/DUI",
"083 Current Auto Theft/ DUI Deterrance",
"084 Curr ABN VEH",
"085 Curr Air QLT",
"086 Curr SC Air",
"087 Valley Air Quality",
"088 Mojave AQMD",
"089 Antelope Valley AQMD",
"090 CTIP",
"092 CVRA Weight Decal",
"093 San Joaquin Valley ACPD",
"094 Traffic Congestion/ Pollution",
"100 ALT Fuel RF",
"154 Curr AUT/DUI2",
"296 Road Improvement Fee (RIF)",
"316 TIF",
"401 Transfer",
"402 Title Only",
"421 Duplicate Ownership",
"451 Motorcycle Cross Index",
"457 Nonresident Original Service Fee",
"464 RLP Fee",
"535 Quagga Mussel Fee Original/ Renewal",
"74 CVRA Fingerprint",
"76 CVRA Abandoned Vehicle",
"77 CVRA Weight Fee",
"79 CVRA CHP",
"95 County Transportation Projects Fee (CTPF)",
"101 Registration 1st Prior Year",
"102 CHP 1st Prior Year",
"104 VLF 1st Prior Year",
"131 Fingerprint ID 1st Prior Year",
"140 Fingerprint ID Current",
"144 CVRA Fingerprint ID Current",
"155 Auto Theft/DUI Deterrence 1st Prior Year",
"156 Auto Theft/DUI Deterrence 2nd Prior Year",
"158 CVRA Auto Theft/DUI Deterrence Current",
"183 Auto Theft/DUI Deterrence 1st Prior Year",
"185 Air Quality Management 1st Prior Yr",
"201 Registration 2nd Prior Year",
"202 CHP 2nd Prior Year",
"204 VLF 2nd Prior Year",
"263 Smog ABT8",
"317 (TIF) 1st Prior Year",
"408 Reposession",
"474 PNO Service Fee",
"587 CA 1960s Legacy Personalized ELP Reassignment",
"Additional Charge",
"501 Curr Reg Pen",
"502 CHP Pen",
"503 Curr WF Pen",
"504 Curr VLF Pen",
"541 Transfer Pen",
"557 CTY UT Pen",
"544 Use Tax Pen",
"68 CVRA Reg Penalty",
"78 CVRA Weight Penalty",
"561 Reg Penalty PNO",
"564 VLF Penalty PNO",
"State Receipt Total"
]


<end_of_turn>
<start_of_turn>model
'''