# Supplier Invoice / 3-Way Match / Payable Foundation v27

## Purchasing lifecycle

v27 completes the first controlled purchasing chain:

Purchase Order
→ Goods Receipt
→ Supplier Invoice
→ 3-Way Match
→ Approved Supplier Invoice
→ Accounts Payable

## Three-way match

The system compares:

1. PO ordered quantity and agreed unit cost
2. Goods Receipt cumulative received quantity
3. Supplier Invoice billed quantity and billed unit cost

Line results:
- matched
- quantity_variance
- price_variance
- mixed_variance

Invoice match status is derived from its lines.

## Quantity rule

Foundation rule:

A billed quantity may not exceed cumulative received quantity.

If:
- received = 4
- billed = 5

the invoice is `quantity_variance`.

This intentionally blocks approval until a later variance-approval workflow explicitly accepts it.

## Price rule

If billed unit cost differs from PO unit cost, the line becomes `price_variance`.

No tolerance band is introduced in v27.
Tolerance configuration and Approval Engine integration come later.

## Approval

Only a fully matched invoice can be approved in v27.

Approval creates one Accounts Payable record, idempotently.

## Accounts payable

Payable stores:
- supplier
- supplier invoice
- currency
- original amount
- outstanding amount
- invoice date
- due date
- status

Payment settlement is intentionally not included in this foundation.

## APIs

Supplier invoices:
- POST /api/v1/purchasing/supplier-invoices
- GET  /api/v1/purchasing/supplier-invoices/{invoiceId}
- POST /api/v1/purchasing/supplier-invoices/{invoiceId}/lines
- POST /api/v1/purchasing/supplier-invoices/{invoiceId}/match
- POST /api/v1/purchasing/supplier-invoices/{invoiceId}/approve

Payables:
- GET /api/v1/payables

## Permissions

Purchasing:
- purchasing.invoice.view
- purchasing.invoice.manage
- purchasing.invoice.approve

Payables:
- payables.view

## Next

v28:
- supplier payable payments
- partial supplier payment
- payable ledger / settlement
- cash/bank payment source boundary
- outstanding balance reconciliation
