Skip to Content
🚀 Welcome to Humansoft Open API Documentation

Add Actual Leave

เพิ่มรายการลาจริงของพนักงาน เพื่อนำไปหักจากโควตาการลาของปีที่ระบุ

Endpoint

POST /api/v1/open-apis/employee/add-employee-setting?path_action=actual-quota

สิทธิ์ที่ต้องการ: API Key ต้องมีสิทธิ์ ข้อมูลพนักงานพื้นฐาน (employee:read:basic)

Query Parameters

ParameterTypeRequiredDescription
path_actionstringYesต้องเป็น actual-quota (หรือ add-actual-quota)

Request Body

ParameterTypeRequiredDescription
employee_codestringYesรหัสพนักงาน
work_datestringYesวันที่ลา (YYYY-MM-DD)
in_yearstringYesปีโควตาที่ต้องการหัก เป็น ปี ค.ศ. (YYYY) เช่น 2026
absence_flag_lvstringYesรหัสประเภทการลา (ค่าเดียวกับ time_leave_flag) เช่น "03"
absence_daynumberYesจำนวนวันลา เช่น 1, 0.5 — ส่ง 0 เมื่อลาเป็นชั่วโมง
absence_sum_timestringYesเวลาลารวม (HH:MM:SS) — ส่ง "00:00:00" เมื่อลาเป็นวัน
time_leave_descstringNoหมายเหตุการลา

การระบุจำนวนลา

ส่ง absence_day และ absence_sum_time ทั้งคู่เสมอ โดยให้ค่าใดค่าหนึ่งเป็นศูนย์ ระบบจะคำนวณอีกค่าให้จากจำนวนชั่วโมงทำงานต่อวันที่ตั้งค่าไว้ขององค์กร

กรณีabsence_dayabsence_sum_timeระบบคำนวณ
ลาเป็นวันจำนวนวัน เช่น 1"00:00:00"absence_sum_time
ลาเป็นชั่วโมง0เวลาลา เช่น "04:00:00"absence_day

ถ้า absence_day เป็น 0 และ absence_sum_time เป็น "00:00:00" พร้อมกัน ระบบจะไม่บันทึกรายการ และตอบกลับ error ไม่สามารถบันทึกโควตาได้


Example Request

{ "employee_code": "EMP001", "work_date": "2026-06-15", "in_year": "2026", "absence_flag_lv": "03", "absence_day": 1, "absence_sum_time": "00:00:00", "time_leave_desc": "ป่วยไข้หวัด" }

Response Format

Success Response

{ "code": 200, "message": "Add Actual Leave Success", "payload": { "time_leave_source": "Manual", "employee_id": "20250101A1B2C3D4E5F6", "work_date": "2026-06-15", "in_year": "2026", "absence_flag_lv": "03", "time_leave_desc": "ป่วยไข้หวัด", "absence_day": 1, "absence_sum_time": "08:00:00", "time_leave_log_id": "20251127D4573C421639" } }

Response Fields

FieldTypeDescription
time_leave_log_idstringID ของรายการลาจริงที่สร้าง — ใช้สำหรับ Delete Actual Leave
time_leave_sourcestringแหล่งที่มาของรายการ: Manual
employee_idstringID ของพนักงาน
work_datestringวันที่ลา (YYYY-MM-DD)
in_yearstringปีโควตาที่หัก (ค.ศ.)
absence_flag_lvstringรหัสประเภทการลา
absence_daynumberจำนวนวันลา (ค่าที่ส่งมา หรือค่าที่ระบบคำนวณให้)
absence_sum_timestringเวลาลารวม HH:MM:SS (ค่าที่ส่งมา หรือค่าที่ระบบคำนวณให้)
time_leave_descstring/nullหมายเหตุการลา

Error Response

ข้อมูลไม่ครบ

{ "code": 400, "message": "ข้อมูลไม่ถูกต้อง", "errors": [ "กรุณาระบุ 'work_date'", "กรุณาระบุ 'absence_flag_lv'" ] }

ไม่พบพนักงาน

{ "code": 400, "message": "Employee not found with code: EMP001" }

Validation Rules

เงื่อนไขError Message
ไม่ส่ง employee_code หรือส่งค่าว่างกรุณาระบุ 'employee_code' สำหรับ action 'actual-quota' (ใน errors)
ไม่ส่ง work_date หรือส่งค่าว่างกรุณาระบุ 'work_date' (ใน errors)
ไม่ส่ง absence_flag_lv หรือส่งค่าว่างกรุณาระบุ 'absence_flag_lv' (ใน errors)
ไม่พบพนักงานตาม employee_codeEmployee not found with code: xxx (ใน message)
absence_day เป็น 0 และ absence_sum_time เป็น "00:00:00"ไม่สามารถบันทึกโควตาได้ (ใน message)

Code Examples

curl -X POST "https://openapi.humansoft.co.th/api/v1/open-apis/employee/add-employee-setting?path_action=actual-quota" \ -H "Content-Type: application/json" \ -H "Ocp-Apim-Subscription-Key: YOUR_API_KEY" \ -d '{ "employee_code": "EMP001", "work_date": "2026-06-15", "in_year": "2026", "absence_flag_lv": "03", "absence_day": 1, "absence_sum_time": "00:00:00", "time_leave_desc": "ป่วยไข้หวัด" }'

Notes

  • หลังบันทึก ระบบจะคำนวณยอดลาที่ใช้ไปของประเภทการลาและปีนั้นใหม่อัตโนมัติ ดูผลได้จากฟิลด์ actual ใน Get Quota
  • time_leave_log_id ใน response เป็นค่า raw — ต้องแปลงเป็น Base64 ก่อนส่งให้ Delete Actual Leave
  • API ไม่ตรวจสอบ in_year และ absence_flag_lv — หากไม่ส่ง in_year หรือส่งรหัสประเภทการลาที่ไม่มีในระบบ คำขอจะสำเร็จแต่รายการนั้นจะไม่ถูกนำไปหักโควตา

  • Get Quota - ดึงข้อมูลโควตาการลา
  • Update Quota - บันทึกโควตาการลา
  • Delete Actual Leave - ลบรายการลาจริง
Last updated on