ดึงรายการใบสั่งซื้อ (Purchase Orders) ทั้งหมดที่ผู้ใช้งานมีสิทธิ์เข้าถึง
Endpoint นี้เหมาะสำหรับ:
read:purchasing
Access Token ต้องได้รับ Scope read:purchasing มิฉะนั้นระบบจะปฏิเสธคำขอ
GET /api/partner/v1/purchase-orders
Authorization: Bearer <access_token>
| Parameter | Type | Required | Description |
|---|---|---|---|
| from | string (YYYY-MM-DD) | No | กรองรายการที่มี order_date ตั้งแต่วันที่กำหนด |
| to | string (YYYY-MM-DD) | No | กรองรายการที่มี order_date ไม่เกินวันที่กำหนด |
| branch_id | string (UUID) | No | กรองตามสาขา สามารถส่งหลายค่าได้ |
| status | string | No | กรองตามสถานะ PO |
| supplier_id | string (UUID) | No | กรองตาม Supplier |
| limit | integer | No | จำนวนรายการต่อหน้า (1–200) ค่าเริ่มต้น 50 |
| cursor | string | No | Cursor สำหรับดึงหน้าถัดไป |
| Status | Description |
|---|---|
| DRAFT | ร่าง PO ยังไม่ส่ง |
| PENDING_APPROVAL | รอการอนุมัติ |
| APPROVED | อนุมัติแล้ว รอรับสินค้า |
| PARTIALLY_RECEIVED | รับสินค้าบางส่วนแล้ว |
| FULLY_RECEIVED | รับสินค้าครบแล้ว |
| REJECTED | ถูกปฏิเสธ |
| CANCELLED | ยกเลิก PO |
Endpoint นี้ใช้ Cursor-based Pagination
หาก has_more เป็น true ให้ส่ง next_cursor กลับมาใน parameter cursor
GET /api/partner/v1/purchase-orders?cursor=<next_cursor>
curl -X GET \
"https://<host>/api/partner/v1/purchase-orders?from=2026-06-01&to=2026-06-30&status=FULLY_RECEIVED&limit=50" \
-H "Authorization: Bearer <access_token>"
{
"data": [
{
"id": "...",
"po_number": "PO-000001",
"branch_id": "b1f85720-71cf-420e-a584-e36b75d3fd20",
"warehouse_id": "1c5e4054-faef-4fb4-b95b-3baeefc2bcb9",
"supplier_id": "...",
"order_date": "2026-06-01T00:00:00.000Z",
"expected_delivery_date": "2026-06-05T00:00:00.000Z",
"status": "FULLY_RECEIVED",
"subtotal": "5000",
"discount_amount": "0",
"tax_amount": "350",
"total_amount": "5350",
"created_at": "2026-06-01T08:00:00.000Z",
"updated_at": "2026-06-05T10:00:00.000Z",
"suppliers": {
"company_name": "บริษัท ABC จำกัด",
"supplier_code": "SUP-001"
}
}
],
"pagination": {
"next_cursor": null,
"has_more": false,
"limit": 50
}
}
| Field | Type | Description |
|---|---|---|
| id | string (UUID) | Purchase Order ID |
| po_number | string | เลขที่ PO เช่น PO-000001 |
| branch_id | string (UUID) | สาขาที่ออก PO |
| warehouse_id | string (UUID) | Warehouse ปลายทางที่รับสินค้า |
| supplier_id | string (UUID) | null | Supplier ที่สั่งซื้อ |
| order_date | string (ISO 8601) | วันที่ออก PO |
| expected_delivery_date | string (ISO 8601) | null | วันที่คาดว่าจะรับสินค้า |
| status | string | สถานะ PO ดู Status ด้านบน |
| subtotal | string (decimal) | ยอดรวมก่อนหักส่วนลดและภาษี |
| discount_amount | string (decimal) | ส่วนลดรวม |
| tax_amount | string (decimal) | ภาษีรวม |
| total_amount | string (decimal) | ยอดรวมสุทธิ |
| created_at | string (ISO 8601) | เวลาที่สร้าง record |
| updated_at | string (ISO 8601) | เวลาที่แก้ไขล่าสุด |
| suppliers | { company_name, supplier_code } | null | ข้อมูล Supplier สรุป |
ฟิลด์เกี่ยวกับจำนวนเงินทั้งหมดถูกส่งกลับในรูปแบบ Decimal String เพื่อป้องกันปัญหา Floating Point
Partner ควรใช้ Decimal Library หรือ Big Number Library ในการคำนวณทางการเงิน