## TL;DR

Invoice extraction often swaps ship-to and bill-to addresses because the labels vary ('deliver to', 'sold to', 'remit to') and the blocks look alike. Fix it with label-aware extraction: map each address block to its label using the invoice's own terminology, and validate against master data (the bill-to should match the customer's billing address on file). When labels are missing, use position heuristics plus master-data matching, and flag low-confidence assignments for review. Swapped addresses cause tax and payment misdirection, so this check earns its place in every template.

## The query

```text
ship-to vs bill-to address confusion in invoice extraction
```

## Use this when

- Bill-to and ship-to addresses swapped in extraction output
- Address labels varying across invoice layouts
- Validating extracted addresses against master data

## Not for

- Tax jurisdiction determination (uses the addresses, separate logic)
- Remit-to address handling (third address type)

## Steps

1. Extract each address block together with its nearby label text.
   Expected output: Labels and blocks stay associated.
2. Normalize label variants: deliver/ship to vs sold/bill to vs remit to.
   Expected output: Variant labels map to the right role.
3. Match the bill-to candidate against the customer's billing address in master data.
   Expected output: The match confirms the assignment.
4. Flag invoices where confidence is low or labels are absent.
   Expected output: Ambiguous cases get human eyes.
5. Record the label mapping per vendor template so it improves over time.
   Expected output: Repeat vendors extract correctly.

## Variant phrasings

### ship to bill to address extraction invoice

### invoice addresses swapped OCR

### bill-to ship-to disambiguation extraction

## Root cause

The blocks look alike because they are both addresses; only the label gives the role. Label-aware extraction works because it reads the invoice's own words instead of guessing from position, and master-data matching provides the ground truth when labels are absent.

## Edge cases

- Drop-ship scenarios legitimately have unusual address combos; do not over-flag them
- Remit-to is a third role; do not force it into ship-to or bill-to

## Provenance

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