"text":"Transcribe the complete purchase order, including its title and order number, the full recipient block starting at 'To', Required By, Ordered By, and every line of the items table. The supplier is the company receiving the order in the 'To' or supplier/vendor field (for example Kerbing Consultant). Mega Infrastructure (Pty) Ltd in the page heading is the buyer placing the order, not the supplier. Never invent a missing supplier. Preserve the Material Code and Cost Code columns separately, including all cost codes such as C26/09, MC-KER. Preserve quantities, units, unit rates, discounts, VAT percentages and printed totals. Do not omit header fields while extracting the table.",
"inputSchema":"{\n \"type\": \"object\",\n \"required\": [\n \"po_number\",\n \"supplier\",\n \"project_code\",\n \"items\"\n ],\n \"properties\": {\n \"po_number\": {\n \"type\": \"string\",\n \"description\": \"Unique PO number printed on the document\"\n },\n \"supplier\": {\n \"type\": \"string\",\n \"description\": \"The supplier is the company receiving the order in the 'To' or supplier/vendor field (for example Kerbing Consultant). Mega Infrastructure (Pty) Ltd in the page heading is the buyer placing the order, not the supplier. Never invent a missing supplier. Return an empty string only if the recipient is unreadable.\"\n },\n \"project_code\": {\n \"type\": \"string\",\n \"description\": \"Printed project reference if present; use an empty string when missing. The upload already has a site.\"\n },\n \"required_by_date\": {\n \"type\": \"string\",\n \"nullable\": true,\n \"description\": \"Required-by date in ISO YYYY-MM-DD format, or null if not stated\"\n },\n \"order_date\": {\n \"type\": \"string\",\n \"nullable\": true,\n \"description\": \"The 'PO Creation Date' (order date) printed on the PO, in ISO YYYY-MM-DD format. Dates on our POs are day/month/year (15/09/2026 = 2026-09-15). Not the 'Required By' date and not the 'Printed' date. Null only if no creation/order date is printed.\"\n },\n \"ordered_by\": {\n \"type\": \"string\",\n \"nullable\": true,\n \"description\": \"Person who placed the order, or null if not shown\"\n },\n \"items\": {\n \"type\": \"array\",\n \"description\": \"Line items in the PO\",\n \"items\": {\n \"type\": \"object\",\n \"required\": [\n \"description\",\n \"qty\",\n \"rate\"\n ],\n \"properties\": {\n \"description\": {\n \"type\": \"string\",\n \"description\": \"Item description / part name\"\n },\n \"qty\": {\n \"type\": \"number\",\n \"description\": \"Quantity ordered (can be 0 or greater)\"\n },\n \"rate\": {\n \"type\": \"number\",\n \"minimum\": 0,\n \"description\": \"Unit rate excluding VAT (must be 0 or greater)\"\n },\n \"unit\": {\n \"type\": \"string\",\n \"nullable\": true,\n \"description\": \"Unit of measure, or null if not specified\"\n },\n \"material_code\": {\n \"type\": \"string\",\n \"nullable\": true,\n \"description\": \"Internal material code, or null if not present\"\n },\n \"cost_code\": {\n \"type\": \"string\",\n \"nullable\": true,\n \"description\": \"Cost code or GL account, or null if not present\"\n },\n \"disc_percent\": {\n \"type\": \"number\",\n \"minimum\": 0,\n \"maximum\": 100,\n \"nullable\": true,\n \"description\": \"Discount percentage 0-100, or null if not applied\"\n },\n \"vat_percent\": {\n \"type\": \"number\",\n \"minimum\": 0,\n \"maximum\": 100,\n \"nullable\": true,\n \"description\": \"VAT percentage 0-100, or null if not applied\"\n }\n }\n }\n }\n }\n}",
"systemPromptTemplate":"Extract the purchase order header and every line item from the document text. The supplier is the company receiving the order in the 'To' or supplier/vendor field (for example Kerbing Consultant). Mega Infrastructure (Pty) Ltd in the page heading is the buyer placing the order, not the supplier. Never invent a missing supplier. Read supplier from 'To'. Use the printed required-by date in YYYY-MM-DD. Preserve material_code and cost_code for every row. Only po_number and usable items are needed to process; use an empty string for an unreadable supplier or missing project_code. Never invent values."
"inputSchema":"{\n \"type\": \"object\",\n \"required\": [\n \"po_number\",\n \"supplier\",\n \"project_code\",\n \"items\"\n ],\n \"properties\": {\n \"po_number\": {\n \"type\": \"string\",\n \"description\": \"Unique PO number printed on the document\"\n },\n \"supplier\": {\n \"type\": \"string\",\n \"description\": \"The supplier is the company receiving the order in the 'To' or supplier/vendor field (for example Kerbing Consultant). Mega Infrastructure (Pty) Ltd in the page heading is the buyer placing the order, not the supplier. Never invent a missing supplier. Return an empty string only if the recipient is unreadable.\"\n },\n \"project_code\": {\n \"type\": \"string\",\n \"description\": \"Printed project reference if present; use an empty string when missing. The upload already has a site.\"\n },\n \"required_by_date\": {\n \"type\": \"string\",\n \"nullable\": true,\n \"description\": \"Required-by date in ISO YYYY-MM-DD format, or null if not stated\"\n },\n \"order_date\": {\n \"type\": \"string\",\n \"nullable\": true,\n \"description\": \"The 'PO Creation Date' (order date) printed on the PO, in ISO YYYY-MM-DD format. Dates on our POs are day/month/year (15/09/2026 = 2026-09-15). Not the 'Required By' date and not the 'Printed' date. Null only if no creation/order date is printed.\"\n },\n \"ordered_by\": {\n \"type\": \"string\",\n \"nullable\": true,\n \"description\": \"Person who placed the order, or null if not shown\"\n },\n \"items\": {\n \"type\": \"array\",\n \"description\": \"Line items in the PO\",\n \"items\": {\n \"type\": \"object\",\n \"required\": [\n \"description\",\n \"qty\",\n \"rate\"\n ],\n \"properties\": {\n \"description\": {\n \"type\": \"string\",\n \"description\": \"Item description / part name\"\n },\n \"qty\": {\n \"type\": \"number\",\n \"description\": \"Quantity ordered (can be 0 or greater)\"\n },\n \"rate\": {\n \"type\": \"number\",\n \"minimum\": 0,\n \"description\": \"Unit rate excluding VAT (must be 0 or greater)\"\n },\n \"unit\": {\n \"type\": \"string\",\n \"nullable\": true,\n \"description\": \"Unit of measure, or null if not specified\"\n },\n \"material_code\": {\n \"type\": \"string\",\n \"nullable\": true,\n \"description\": \"Internal material code, or null if not present\"\n },\n \"cost_code\": {\n \"type\": \"string\",\n \"nullable\": true,\n \"description\": \"Cost code or GL account, or null if not present\"\n },\n \"disc_percent\": {\n \"type\": \"number\",\n \"minimum\": 0,\n \"maximum\": 100,\n \"nullable\": true,\n \"description\": \"Discount percentage 0-100, or null if not applied\"\n },\n \"vat_percent\": {\n \"type\": \"number\",\n \"minimum\": 0,\n \"maximum\": 100,\n \"nullable\": true,\n \"description\": \"VAT percentage 0-100, or null if not applied\"\n }\n }\n }\n }\n }\n}",
"systemMessage":"You are a purchase order parser. Given the attached PDF or scanned image, extract the purchase order header and line items.\n\nReturn ONLY a JSON object (no markdown, no commentary) matching this exact schema:\n\n{\n \"po_number\": string,\n \"supplier\": string,\n \"project_code\": string,\n \"order_date\": \"YYYY-MM-DD\" | null,\n \"required_by_date\": \"YYYY-MM-DD\" | null,\n \"ordered_by\": string | null,\n \"items\": [\n {\n \"description\": string,\n \"qty\": number,\n \"rate\": number,\n \"unit\": string | null,\n \"material_code\": string | null,\n \"cost_code\": string | null,\n \"disc_percent\": number | null,\n \"vat_percent\": number | null\n }\n ]\n}\n\nRules:\n- Use null (not \"\") for missing optional fields.\n- disc_percent and vat_percent must be 0-100 if provided.\n- Drop any line item missing description, qty, or rate.\n- po_number and usable items are required. If supplier or project_code is unreadable, return an empty string. The supplier is the company receiving the order in the 'To' or supplier/vendor field (for example Kerbing Consultant). Mega Infrastructure (Pty) Ltd in the page heading is the buyer placing the order, not the supplier. Never invent a missing supplier.\n- order_date is the 'PO Creation Date' printed on the PO (day/month/year on our POs: 15/09/2026 = 2026-09-15). It is when the order was placed. Never use the 'Required By' date or the 'Printed' date for it. Read it from photos and scans too.",