Skip to Content
🚀 Welcome to Humansoft Open API Documentation

Create OT Template

สร้าง OT Template เก็บรูปแบบงวดโอทีไว้ใช้ซ้ำทุกเดือน

ตั้งค่าครั้งเดียวว่างวดเริ่มวันที่เท่าไร จบวันที่เท่าไร และเลื่อนกี่เดือนจากงวดเงินเดือน จากนั้นสร้างงวดจริงของแต่ละเดือนได้ด้วย Create Round from Template

Endpoint

POST /api/v1/open-apis/calculation-ot/create-ot-round-template

สิทธิ์ที่ต้องการ: API Key ต้องมีสิทธิ์ ข้อมูลเงินเดือนทั้งองค์กร (payroll:read:all)

Request Parameters

Required Parameters

ParameterTypeRequiredDescriptionExample
master_salary_ot_template_namestringYesชื่อ Template — ห้ามมีเครื่องหมายจุด (.)งวดโอที 21-20
ot_template_start_dtstringYesวันที่ของเดือนที่เริ่มรอบ21
ot_template_end_dtstringYesวันที่ของเดือนที่จบรอบ หรือ EOM = สิ้นเดือน20
ot_template_start_monthintYesจำนวนเดือนที่เลื่อนจากงวดเงินเดือน รับจำนวนเต็มรวมค่าติดลบ (-1 = เริ่มเดือนก่อนหน้า, 0 = เดือนเดียวกัน) — ทศนิยมถูกปฏิเสธ-1

Request Body Example

{ "master_salary_ot_template_name": "งวดโอที 21-20", "ot_template_start_dt": "21", "ot_template_end_dt": "20", "ot_template_start_month": -1 }

รอบเต็มเดือน (1 ถึงสิ้นเดือน)

{ "master_salary_ot_template_name": "งวดโอทีเต็มเดือน", "ot_template_start_dt": "1", "ot_template_end_dt": "EOM", "ot_template_start_month": 0 }

Response Format

Success Response (HTTP 200)

{ "code": 200, "message": "Create OT template Accept", "payload": { "master_salary_ot_report_template_id": "20251127T8891F6A3D024", "master_salary_ot_template_code": "OT-T001", "master_salary_ot_template_name": "งวดโอที 21-20", "ot_template_start_dt": "21", "ot_template_end_dt": "20", "ot_template_start_month": -1 } }

Error Response - Validation Failed (HTTP 400)

{ "code": 400, "message": "ไม่สำเร็จ", "errors": [ "กรุณาระบุ 'master_salary_ot_template_name'" ] }

วิธีแก้: ตรวจสอบว่าส่งพารามิเตอร์ที่จำเป็นครบทุกตัว

Error Response - Unauthorized (HTTP 401)

{ "code": 401, "message": "Unauthorized", "payload": [] }

วิธีแก้: ตรวจสอบว่า API Key ถูกต้องและมีสิทธิ์ตามที่ระบุไว้ด้านบน — ดูวิธีตั้งค่าได้ที่ Get Started

Response Fields

FieldTypeDescription
master_salary_ot_report_template_idstringรหัส Template (ต้องแปลงเป็น Base64 ก่อนส่งกลับเข้า request)
master_salary_ot_template_codestringรหัสอ้างอิงที่ระบบสร้างให้
master_salary_ot_template_namestringชื่อ Template
ot_template_start_dtstringวันที่ของเดือนที่เริ่มรอบ เช่น 21
ot_template_end_dtstringวันที่ของเดือนที่จบรอบ เช่น 20 หรือ EOM = สิ้นเดือน
ot_template_start_monthintจำนวนเดือนที่เลื่อนจากงวดเงินเดือน เช่น -1 = เริ่มเดือนก่อนหน้า

Code Examples

curl -X POST "https://openapi.humansoft.co.th/api/v1/open-apis/calculation-ot/create-ot-round-template" \ -H "Ocp-Apim-Subscription-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "master_salary_ot_template_name": "งวดโอที 21-20", "ot_template_start_dt": "21", "ot_template_end_dt": "20", "ot_template_start_month": -1 }'

Validation Rules

ParameterValidationError Message
master_salary_ot_template_nameต้องระบุกรุณาระบุ 'master_salary_ot_template_name'
ot_template_start_dtต้องระบุ เป็นวันที่ของเดือนกรุณาระบุ 'ot_template_start_dt' (วันที่ของเดือน เช่น 21)
ot_template_end_dtต้องระบุ เป็นวันที่ของเดือน หรือ EOMกรุณาระบุ 'ot_template_end_dt' (วันที่ของเดือน หรือ EOM = สิ้นเดือน)
ot_template_start_monthต้องเป็นจำนวนเต็ม ทศนิยมไม่ผ่านกรุณาระบุ 'ot_template_start_month' เป็นตัวเลข (จำนวนเดือนที่เลื่อนจากงวดเงินเดือน เช่น -1)
master_salary_ot_template_nameห้ามมีเครื่องหมายจุด (.)'master_salary_ot_template_name' ห้ามมีเครื่องหมายจุด (.)

Notes

  • สร้างเสร็จแล้ว Template ยังไม่มีรายชื่อพนักงาน ให้เรียก Save Template Employees ต่อ
  • ถ้าวันจบน้อยกว่าวันเริ่ม ระบบจะเข้าใจว่ารอบคร่อมเดือนและคำนวณวันสิ้นรอบเป็นเดือนถัดไปให้เอง
  • EOM จะถูกแทนด้วยจำนวนวันจริงของเดือนนั้นตอนสร้างงวด จึงรองรับเดือนที่มี 28/30/31 วันได้เอง
Last updated on