Save Quota
สร้างหรืออัปเดตโควตาการลาของพนักงาน (Upsert) รองรับการบันทึกหลายพนักงานและหลายประเภทการลาพร้อมกัน
Endpoint
POST /api/v1/open-apis/salary/add-data-filterRequest Body
| Parameter | Type | Required | Description |
|---|---|---|---|
path_action | string | Yes | ต้องเป็น save_quota |
employee_lists | array | Yes | รายการพนักงานพร้อมโควตา |
employee_lists[].employee_code | string | Yes | รหัสพนักงาน (plain text) |
employee_lists[].quota | array | Yes | รายการโควตาของพนักงาน |
employee_lists[].quota[].quota_year | string | Yes | ปีโควตา (YYYY) |
employee_lists[].quota[].time_leave_flag | string | Yes | รหัสประเภทการลา (01-09) |
employee_lists[].quota[].time_leave_flag_quota | string | No | จำนวนโควตา (ถ้าไม่ระบุจะใช้ค่าเริ่มต้นจากระบบ) |
Example Request Body
{
"path_action": "save_quota",
"employee_lists": [
{
"employee_code": "EMP001",
"quota": [
{
"quota_year": "2026",
"time_leave_flag": "01",
"time_leave_flag_quota": "10"
},
{
"quota_year": "2026",
"time_leave_flag": "06",
"time_leave_flag_quota": "15"
}
]
},
{
"employee_code": "EMP002",
"quota": [
{
"quota_year": "2026",
"time_leave_flag": "06",
"time_leave_flag_quota": "10"
}
]
}
]
}ถ้าพนักงานมีโควตาในประเภทการลาและปีเดียวกันอยู่แล้ว ระบบจะอัปเดตจำนวนโควตา (Upsert) ถ้ายังไม่มีจะสร้างใหม่
Response Format
Success Response
{
"code": 200,
"message": "สำเร็จ",
"payload": {
"saved_count": 3,
"updated_count": 1,
"created_count": 2,
"employees": [
{
"employee_code": "EMP001",
"quotas_saved": 2
},
{
"employee_code": "EMP002",
"quotas_saved": 1
}
]
}
}Response Fields
| Field | Type | Description |
|---|---|---|
saved_count | number | จำนวนโควตาที่บันทึกทั้งหมด |
updated_count | number | จำนวนที่อัปเดต (มีอยู่แล้ว) |
created_count | number | จำนวนที่สร้างใหม่ |
employees[].employee_code | string | รหัสพนักงาน |
employees[].quotas_saved | number | จำนวนโควตาที่บันทึกสำหรับพนักงานคนนี้ |
Error Response
{
"code": 400,
"message": "ไม่สำเร็จ",
"errors": ["employee_lists is required"]
}Code Examples
cURL
curl -X POST "https://openapi.humansoft.co.th/api/v1/open-apis/salary/add-data-filter" \
-H "Ocp-Apim-Subscription-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"path_action": "save_quota",
"employee_lists": [
{
"employee_code": "EMP001",
"quota": [
{
"quota_year": "2026",
"time_leave_flag": "06",
"time_leave_flag_quota": "15"
}
]
}
]
}'Notes
- ถ้าไม่ระบุ
time_leave_flag_quotaระบบจะใช้ค่าเริ่มต้นจากกฎธุรกิจ (ใช้ Get Default Quota เพื่อดูค่าล่วงหน้า) - รองรับการบันทึกหลายพนักงานและหลายประเภทการลาใน request เดียว
- ถ้ามีโควตาอยู่แล้ว (employee + year + leave type เดียวกัน) จะอัปเดตจำนวน ไม่สร้างซ้ำ
Related APIs
- Get Default Quota - คำนวณโควตาเริ่มต้นก่อนบันทึก
- Update Quota - แก้ไขจำนวนโควตารายการเดียว
- List Quotas - ดูรายการโควตาทั้งหมดหลังบันทึก
- Get Leave Types - ดูประเภทการลาสำหรับเลือก time_leave_flag
Last updated on