# SalesPurchaseOrderLinks

> Which purchase is meant for which sales order: one row per pair of a purchase status row and a sales status row, with the quantity.

Subject: Purchase.

Which purchase is meant for which sales order: one row per pair of a purchase status row and a sales status row, with the quantity. The links follow the status rows, but not on every action: after an approval or an order instruction a link stays on the finished purchase row, and some sales actions drop links. So a link that exists is a real link, but a missing one doesn't prove there never was one.

Label in Fledge: Verkooporder koppeling met inkooporder.

| | |
| --- | --- |
| URL | `https://odata-api.fledge.nl/v2-8/SalesPurchaseOrderLinks` |
| Key | `administration_id`, `purchase_order_header_id`, `purchase_order_line_id`, `purchase_order_line_status_id`, `sales_order_header_id`, `sales_order_line_id`, `sales_order_line_status_id` |
| Administration-specific | yes: always filter on `administration_id` |
| Operations | GET list, GET one, POST, PATCH, DELETE |
| Read licenses | BASIS, BASISAPP, URENPC |
| Write licenses | VERKOOP, INKOOP |
| Scopes | FLEDGE_PORTAL, FLEDGE_TERMINAL |

> **Watch out:** Links can sit on finished status rows. To find the purchase for a sales order, filter on sales_order_header_id (and sales_order_line_id) and read purchase_order_header_id and purchase_order_line_id, without requiring an open status row.

## Example requests

```http
GET https://odata-api.fledge.nl/v2-8/SalesPurchaseOrderLinks?$filter=administration_id eq 1&$select=purchase_order_header_id,purchase_order_line_id,purchase_order_line_status_id,sales_order_header_id,sales_order_line_id,sales_order_line_status_id,quantity&$top=50
GET https://odata-api.fledge.nl/v2-8/SalesPurchaseOrderLinks(administration_id=1,purchase_order_header_id='{purchase_order_header_id}',purchase_order_line_id={purchase_order_line_id},purchase_order_line_status_id={purchase_order_line_status_id},sales_order_header_id='{sales_order_header_id}',sales_order_line_id={sales_order_line_id},sales_order_line_status_id={sales_order_line_status_id})
```

## Fields

| Field | Type | Description |
| --- | --- | --- |
| `administration_id` (key) | Int32 | Administratienummer |
| `purchase_order_header_id` (key) | String, not null | Ordernummer |
| `purchase_order_line_id` (key) | Int32, not null | Regelnummer |
| `purchase_order_line_status_id` (key) | Int32, not null | Volgnummer. The purchase status row; it can be a finished one. |
| `sales_order_line_id` (key) | Int32, not null | Regelnummer |
| `sales_order_header_id` (key) | String, not null | Verkoopordernummer |
| `sales_order_line_status_id` (key) | Int32, not null | Volgnummer. The sales status row (SalesOrderLineStatuses). |
| `quantity` | Decimal | Aantal. The quantity of the purchase meant for the sales line. |

## Relations

- `Administration` → [Administrations](https://docs.fledge.nl/en/api/reference/Administrations.md) (one)
- `PurchaseOrderHeader` → [PurchaseOrderHeaders](https://docs.fledge.nl/en/api/reference/PurchaseOrderHeaders.md) (one)
- `PurchaseOrderLine` → [PurchaseOrderLines](https://docs.fledge.nl/en/api/reference/PurchaseOrderLines.md) (one)
- `PurchaseOrderLineStatus` → [PurchaseOrderLineStatuses](https://docs.fledge.nl/en/api/reference/PurchaseOrderLineStatuses.md) (one)
- `SalesOrderHeaders` → [SalesOrderHeaders](https://docs.fledge.nl/en/api/reference/SalesOrderHeaders.md) (one)
- `SalesOrderLines` → [SalesOrderLines](https://docs.fledge.nl/en/api/reference/SalesOrderLines.md) (one)
- `SalesOrderLineStatuses` → [SalesOrderLineStatuses](https://docs.fledge.nl/en/api/reference/SalesOrderLineStatuses.md) (one)

---

Source: https://docs.fledge.nl/en/api/reference/SalesPurchaseOrderLinks
