## TL;DR

Continued rows are the quiet killer of invoice accuracy: a description that wraps to a second line looks like a new row with no amounts. Merge continuation lines by checking whether a row has amounts; rows without amounts attach to the previous row's description. Then verify the merged row count is plausible and amounts reconcile.

## Steps

1. Parse all rows and mark which ones contain numeric amount fields.
   Expected: Two groups: amount-bearing rows and description-only rows.
2. Attach each description-only row to the nearest preceding amount-bearing row.
   Expected: Wrapped descriptions merged into their parent rows.
3. For page-boundary splits, apply the same rule across the page break.
   Expected: Rows spanning pages become single logical rows.
4. Check that every merged row has exactly one quantity, one unit price, and one extended price.
   Expected: Structural validation of the merge.
5. Reconcile the extended-price sum against the invoice subtotal.
   Expected: A match confirms no rows were lost or doubled.

## When to use

- Long product descriptions that wrap in invoice tables
- Rows appearing without amounts in extracted output
- Subtotal reconciliation fails after extraction

## When not to use

- Tables where every row fits on one line
- Non-tabular invoice content
- Invoices already delivered as structured data

## Compatibility

Works with any table extractor (Textract, Document AI, pdfplumber, Camelot). Downstream of OCR quality.

## Variant phrasings

### invoice description wraps to next line

### continuation rows in invoice tables

### merge wrapped line items

## Root cause

Table extractors emit one record per visual line, but invoices use visual lines for word wrap. Without a semantic rule (amounts define row boundaries), wrapped text becomes phantom rows that corrupt counts and sums.

## Edge cases

- Discount or tax summary lines also lack amounts in the item columns; exclude footer zones before merging
- Multi-column layouts (two item blocks side by side) need column-zone splitting first
- Some invoices put the amount on the first line and wrap the description after; invert the attach direction when amounts lead

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_r78bD6kjstE3BK3vKsBUcw
