Developer Docs

เริ่มต้น

Partner API — Auth

Partner API — Products

Partner API — Inventory

Partner API — Customers

Partner API — Reports

Inventory Summary

ดึงรายงานสรุป Stock ของ Warehouse หนึ่ง ณ ขณะที่เรียก API

Endpoint นี้คืนข้อมูลสรุป (Aggregate) เพียง response เดียว ไม่ใช้ Pagination — เหมาะสำหรับ Dashboard ที่ต้องการภาพรวม Stock Value และ Out-of-stock ทันที

Endpoint นี้เหมาะสำหรับ:

  • แสดง Stock Value รวมบน Dashboard ผู้บริหาร
  • ตรวจสอบจำนวน SKU ที่หมด Stock ใน Warehouse
  • รายงานสรุป Inventory ประจำวัน / สิ้นงวด

Required Scope

read:reports

Access Token ต้องได้รับ Scope read:reports มิฉะนั้นระบบจะปฏิเสธคำขอ


Endpoint

GET /api/partner/v1/reports/inventory-summary

Request Headers

Authorization: Bearer <access_token>

Query Parameters

ParameterTypeRequiredDescription
warehouse_idstring (UUID)YesWarehouse ที่ต้องการดึงรายงาน ต้องอยู่ใน Branch ที่ Token's allowed_branch_ids อนุญาต

Example Request

curl -X GET \
  "https://<host>/api/partner/v1/reports/inventory-summary?warehouse_id=1c5e4054-faef-4fb4-b95b-3baeefc2bcb9" \
  -H "Authorization: Bearer <access_token>"

Example Response

{
  "data": {
    "warehouse_id": "1c5e4054-faef-4fb4-b95b-3baeefc2bcb9",
    "warehouse_name": "Main Storage",
    "branch_id": "b1f85720-71cf-420e-a584-e36b75d3fd20",
    "total_skus": 24,
    "total_quantity_on_hand": "226",
    "total_quantity_available": "216",
    "total_stock_value": "60997.3",
    "out_of_stock_count": 18
  }
}

InventorySummary Object

FieldTypeDescription
warehouse_idstring (UUID)Warehouse ที่รายงาน
warehouse_namestringชื่อ Warehouse
branch_idstring (UUID)สาขาของ Warehouse นี้
total_skusnumberจำนวน SKU ทั้งหมดที่ติดตาม Stock ใน Warehouse นี้
total_quantity_on_handstring (decimal)จำนวน Stock รวมทุก SKU
total_quantity_availablestring (decimal)จำนวน Stock ที่พร้อมใช้รวมทุก SKU (on_hand − reserved)
total_stock_valuestring (decimal)มูลค่า Stock รวมทุก SKU (ต้นทุนเฉลี่ย × จำนวน)
out_of_stock_countnumberจำนวน SKU ที่มี quantity_on_hand ≤ 0

Error Responses

Warehouse Not Found

404 Not Found
{
  "error": "not_found",
  "message": "Warehouse not found"
}

สาเหตุ:

  • warehouse_id ไม่ถูกต้อง
  • Warehouse อยู่ใน Branch ที่นอกขอบเขตสิทธิ์ของ Token (allowed_branch_ids)