Skip to Content
🚀 Welcome to Humansoft Open API Documentation

Save Quota

สร้างหรืออัปเดตโควตาการลาของพนักงาน (Upsert) รองรับการบันทึกหลายพนักงานและหลายประเภทการลาพร้อมกัน

Endpoint

POST /api/v1/open-apis/salary/add-data-filter

Request Body

ParameterTypeRequiredDescription
path_actionstringYesต้องเป็น save_quota
employee_listsarrayYesรายการพนักงานพร้อมโควตา
employee_lists[].employee_codestringYesรหัสพนักงาน (plain text)
employee_lists[].quotaarrayYesรายการโควตาของพนักงาน
employee_lists[].quota[].quota_yearstringYesปีโควตา (YYYY)
employee_lists[].quota[].time_leave_flagstringYesรหัสประเภทการลา (01-09)
employee_lists[].quota[].time_leave_flag_quotastringNoจำนวนโควตา (ถ้าไม่ระบุจะใช้ค่าเริ่มต้นจากระบบ)

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

FieldTypeDescription
saved_countnumberจำนวนโควตาที่บันทึกทั้งหมด
updated_countnumberจำนวนที่อัปเดต (มีอยู่แล้ว)
created_countnumberจำนวนที่สร้างใหม่
employees[].employee_codestringรหัสพนักงาน
employees[].quotas_savednumberจำนวนโควตาที่บันทึกสำหรับพนักงานคนนี้

Error Response

{ "code": 400, "message": "ไม่สำเร็จ", "errors": ["employee_lists is required"] }

Code Examples

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 เดียวกัน) จะอัปเดตจำนวน ไม่สร้างซ้ำ

  • Get Default Quota - คำนวณโควตาเริ่มต้นก่อนบันทึก
  • Update Quota - แก้ไขจำนวนโควตารายการเดียว
  • List Quotas - ดูรายการโควตาทั้งหมดหลังบันทึก
  • Get Leave Types - ดูประเภทการลาสำหรับเลือก time_leave_flag
Last updated on