PDF 發票資料擷取:保留實際的零值,並檢視缺漏欄位
PDF invoice extraction: keep real zeros and review missing fields
PDF 發票資料擷取流程應區分缺漏欄位、空字串和實際零值,避免推算未列明的付款期限或排除有效金額。ComPDF Intelligent Document Extraction 可擷取欄位及來源位置;對漏讀、未列明或互相矛盾的日期,應交由審核人員核對原始 PDF。未解決的項目不應進入自動排程。
An invoice has a date and a total, but no due date comes back from your extractor. Adding 30 days to the invoice date would invent a payment term. Before any reminder or payment is scheduled, the workflow needs to know what the invoice actually says.
Give the reviewer a reason to look
Save the raw value, the normalized value if you have one, and the reason for review. A missing field, an empty string, and a real zero should stay distinct throughout the workflow.
| What you know | What to do |
|---|---|
| Nobody has checked the source | Leave the field unverified and send it for a source check. |
| The source gives no due date | Record it as unspecified; leave the payment date unset. |
| The date is visible but the extractor missed it | Ask the reviewer to confirm the value against the source. |
| The invoice gives two conflicting dates | Keep both dates and their locations for review. |
Inspect the value and the source together
In ComPDF Intelligent Document Extraction, request the fields your workflow needs. If you're building a payment review queue, start with the invoice number, amount due, and due date. Request source grounding where supported, and attach the page reference when the response includes one. Without a location, give the reviewer the original PDF to check.
On one synthetic invoice, a layout extraction request returned INV-711 and USD 0.00, both located on page 1. The invoice didn't give a purchase order number; that field returned an empty string and an empty bboxes array. The response structure guide explains the value and grounding fields.
Values and source references from one layout extraction result. An empty field on a different invoice still needs a source check.
Avoid a truthiness check on the normalized amount. Once parsed, 0 is a legitimate number; a JavaScript expression such as amount || null would erase it. The review reasons in the table are decisions made by the application or a reviewer; they don't come back as statuses from the extraction API.
Test the review queue with four short invoices
Use fictional data. Put each sample on a separate one-page PDF. For B, first omit the due date from a mocked response so you can reproduce the missed-field case on demand. Run a separate pass against real PDFs to see what your extractor actually returns.
| Sample | Source text | Check in your application |
|---|---|---|
| A | Due: 2027-03-15 · Amount due: USD 0.00 | Keep the date and the zero. |
| B | Due: 2027-03-18 · Amount due: USD 120.00 | If the response omits the date, leave it unverified until someone checks the source. |
| C | Amount due: USD 120.00 | After checking the source, record that no due date was specified. |
| D | Due: 2027-03-20 · Payment note: due 2027-03-27 | Preserve both candidates and ask for a decision. |
Before letting the workflow schedule anything, open the review queue. For each unresolved item, check whether the reviewer can see why it was flagged and where to look. If they can't tell the difference between a blank, a missed value, and two conflicting dates, keep that item out of automatic scheduling.
來源:DEV Community · dev.to
