# X12 Reader Transaction Set Notes

Use these notes when `read_x12` has parsed a document and you need to locate common business fields in the returned JSON.

## General Navigation

The usual path is:

```text
groups[].transactionSets[]
```

Each transaction set has an `ST` segment with:

- `TransactionSetIdentifierCode_01`: transaction set type, such as `850` or `810`.
- `TransactionSetControlNumber_02`: transaction set control number.

## 850 Purchase Order

Common fields:

- PO number: `BEG.PurchaseOrderNumber_03`
- PO date: `BEG.Date_05`
- Purpose code: `BEG.TransactionSetPurposeCode_01`
- PO type: `BEG.PurchaseOrderTypeCode_02`
- Parties: `N1Loop[].N1`
- Line items: `PO1Loop[].PO1`

When answering, identify the value and segment, for example: "PO number is `PO123456` from BEG03."

## 810 Invoice

Common fields:

- Invoice date: `BIG.Date_01`
- Invoice number: `BIG.InvoiceNumber_02`
- Line items: `IT1Loop[].IT1`
- Monetary total: `TDS.Amount_01`

X12 monetary amounts such as TDS are commonly represented in cents. Confirm trading-partner conventions before converting to decimal currency.

## 856 Advance Ship Notice

Common fields:

- Shipment identification often appears in `BSN`.
- Hierarchical shipment, order, pack, and item structure appears in HL loops.
- Carrier and tracking data often appear in TD segments.

Use the parsed segment names from the response. If a loop name differs by X12 version, inspect the actual JSON keys rather than assuming a fixed loop name.

## 997 Functional Acknowledgment

Common fields:

- Functional group acknowledged: `AK1`
- Transaction set acknowledged: `AK2`
- Transaction status: `AK5`
- Functional group status: `AK9`

If the user asks whether the 997 accepted or rejected a document, summarize AK5 and AK9 values and include the acknowledged group and transaction control numbers.
